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

Unified Diff: crypto/rsa_private_key_nss.cc

Issue 7066032: Fixing FindFromPublicKeyInfo so that it searches the "Public" NSS database (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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
« no previous file with comments | « crypto/nss_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/rsa_private_key_nss.cc
diff --git a/crypto/rsa_private_key_nss.cc b/crypto/rsa_private_key_nss.cc
index bac72814fe16d1cc168c637a019ebda082dcd492..03cc254a4ada284957a7ce04b0c46fab00ee995c 100644
--- a/crypto/rsa_private_key_nss.cc
+++ b/crypto/rsa_private_key_nss.cc
@@ -105,32 +105,41 @@ RSAPrivateKey* RSAPrivateKey::FindFromPublicKeyInfo(
return NULL;
}
- // Now, look for the associated private key in the user's
- // hardware-backed NSS DB. If it's not there, consider that an
- // error.
- PK11SlotInfo *slot = GetPrivateNSSKeySlot();
- if (!slot) {
- NOTREACHED();
- return NULL;
- }
-
// Make sure the key is an RSA key. If not, that's an error
if (result->public_key_->keyType != rsaKey) {
- PK11_FreeSlot(slot);
NOTREACHED();
return NULL;
}
SECItem *ck_id = PK11_MakeIDFromPubKey(&(result->public_key_->u.rsa.modulus));
Ryan Sleevi 2011/05/25 05:58:25 You can make this a ScopedSECItem (see src/crypto/
Greg Spencer (Chromium) 2011/05/25 17:12:07 Good point. I forgot about the scoped nss types.
if (!ck_id) {
- PK11_FreeSlot(slot);
NOTREACHED();
return NULL;
}
+ PK11SlotInfo* slot = GetPrivateNSSKeySlot();
+ if (!slot) {
+ NOTREACHED();
+ SECITEM_FreeItem(ck_id, PR_TRUE);
+ return NULL;
+ }
+
// Finally...Look for the key!
result->key_ = PK11_FindKeyByKeyID(slot, ck_id, NULL);
+ // If we don't find the matching key in the private slot, then we
+ // look in the public slot.
+ if (!result->key_) {
+ PK11_FreeSlot(slot);
+ slot = GetPublicNSSKeySlot();
Ryan Sleevi 2011/05/25 05:58:25 According to the header comments for GetPublicNSSK
Greg Spencer (Chromium) 2011/05/25 17:12:07 Yes, I wrote those comments. The general policy f
+ if (!slot) {
+ NOTREACHED();
+ SECITEM_FreeItem(ck_id, PR_TRUE);
+ return NULL;
+ }
+ result->key_ = PK11_FindKeyByKeyID(slot, ck_id, NULL);
+ }
+
// Cleanup...
PK11_FreeSlot(slot);
SECITEM_FreeItem(ck_id, PR_TRUE);
« no previous file with comments | « crypto/nss_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698