Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Unified Diff: net/third_party/mozilla_security_manager/nsKeygenHandler.cpp

Issue 2838010: Add a unit test to check KeygenHandler's thread-safety (Closed)
Patch Set: Another revision Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« base/nss_util.cc ('K') | « net/net.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/third_party/mozilla_security_manager/nsKeygenHandler.cpp
diff --git a/net/third_party/mozilla_security_manager/nsKeygenHandler.cpp b/net/third_party/mozilla_security_manager/nsKeygenHandler.cpp
index e6ab574643bc4be80cb4362d2cc65823a3836172..2477ac0c41bd996f58ec12f7631bef83ce0cbb44 100644
--- a/net/third_party/mozilla_security_manager/nsKeygenHandler.cpp
+++ b/net/third_party/mozilla_security_manager/nsKeygenHandler.cpp
@@ -41,6 +41,7 @@
#include "net/third_party/mozilla_security_manager/nsKeygenHandler.h"
#include <pk11pub.h>
+#include <prerror.h> // PR_GetError()
#include <secmod.h>
#include <secder.h> // DER_Encode()
#include <cryptohi.h> // SEC_DerSignData()
@@ -164,13 +165,16 @@ std::string GenKeyAndSignChallenge(int key_size_in_bits,
}
LOG(INFO) << "Creating key pair...";
- privateKey = PK11_GenerateKeyPair(slot,
- keyGenMechanism,
- keyGenParams,
- &publicKey,
- PR_TRUE, // isPermanent?
- PR_TRUE, // isSensitive?
- NULL);
+ {
+ base::AutoNSSWriteLock lock;
+ privateKey = PK11_GenerateKeyPair(slot,
+ keyGenMechanism,
+ keyGenParams,
+ &publicKey,
+ PR_TRUE, // isPermanent?
+ PR_TRUE, // isSensitive?
+ NULL);
+ }
LOG(INFO) << "done.";
if (!privateKey) {
@@ -245,7 +249,7 @@ std::string GenKeyAndSignChallenge(int key_size_in_bits,
failure:
if (!isSuccess) {
- LOG(ERROR) << "SSL Keygen failed!";
+ LOG(ERROR) << "SSL Keygen failed! (NSS error code " << PR_GetError() << ")";
} else {
LOG(INFO) << "SSL Keygen succeeded!";
}
@@ -255,6 +259,7 @@ std::string GenKeyAndSignChallenge(int key_size_in_bits,
// On successful keygen we need to keep the private key, of course,
// or we won't be able to use the client certificate.
if (!isSuccess || !stores_key) {
+ base::AutoNSSWriteLock lock;
PK11_DestroyTokenObject(privateKey->pkcs11Slot, privateKey->pkcs11ID);
}
SECKEY_DestroyPrivateKey(privateKey);
@@ -262,6 +267,7 @@ std::string GenKeyAndSignChallenge(int key_size_in_bits,
if (publicKey) {
if (!isSuccess || !stores_key) {
+ base::AutoNSSWriteLock lock;
PK11_DestroyTokenObject(publicKey->pkcs11Slot, publicKey->pkcs11ID);
}
SECKEY_DestroyPublicKey(publicKey);
« base/nss_util.cc ('K') | « net/net.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698