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

Unified Diff: crypto/rsa_private_key_nss.cc

Issue 7066070: Search all slots when looking for a key in NSS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adding blank line Created 9 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
« crypto/nss_util_internal.h ('K') | « crypto/nss_util_internal.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 8157de254fc9e069069e02dba27ecf8efa462d84..0d79dbe84661831740ef43cdd66bf72696f26685 100644
--- a/crypto/rsa_private_key_nss.cc
+++ b/crypto/rsa_private_key_nss.cc
@@ -7,6 +7,7 @@
#include <cryptohi.h>
#include <keyhi.h>
#include <pk11pub.h>
+#include <secmod.h>
#include <list>
@@ -119,31 +120,22 @@ RSAPrivateKey* RSAPrivateKey::FindFromPublicKeyInfo(
return NULL;
}
- ScopedPK11Slot slot(GetPrivateNSSKeySlot());
- if (!slot.get()) {
- NOTREACHED();
- return NULL;
- }
-
- // Finally...Look for the key!
- result->key_ = PK11_FindKeyByKeyID(slot.get(), ck_id.get(), NULL);
-
- // If we don't find the matching key in the private slot, then we
- // look in the public slot.
- if (!result->key_) {
- slot.reset(GetPublicNSSKeySlot());
- if (!slot.get()) {
- NOTREACHED();
- return NULL;
+ // Search all slots in all modules for the key with the given ID.
+ AutoSECMODListReadLock auto_lock;
+ SECMODModuleList* head = SECMOD_GetDefaultModuleList();
+ for (SECMODModuleList* item = head; item != NULL; item = item->next) {
+ int slot_count = item->module->loaded ? item->module->slotCount : 0;
+ for (int i = 0; i < slot_count; i++) {
+ // Finally...Look for the key!
+ result->key_ = PK11_FindKeyByKeyID(item->module->slots[i],
+ ck_id.get(), NULL);
+ if (result->key_)
+ return result.release();
}
- result->key_ = PK11_FindKeyByKeyID(slot.get(), ck_id.get(), NULL);
}
- // If we didn't find it, that's ok.
- if (!result->key_)
- return NULL;
-
- return result.release();
+ // We didn't find the key.
+ return NULL;
}
« crypto/nss_util_internal.h ('K') | « crypto/nss_util_internal.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698