Index: chrome/browser/chromeos/platform_keys/platform_keys_nss.cc |
diff --git a/chrome/browser/chromeos/platform_keys/platform_keys_nss.cc b/chrome/browser/chromeos/platform_keys/platform_keys_nss.cc |
index 5678bafc5fe2217f5d03438aff3b40c365ed67da..a7ce5b5d6adb9f3489c19ea060efe419aa65dc6f 100644 |
--- a/chrome/browser/chromeos/platform_keys/platform_keys_nss.cc |
+++ b/chrome/browser/chromeos/platform_keys/platform_keys_nss.cc |
@@ -451,14 +451,16 @@ void SignRSAOnWorkerThread(scoped_ptr<SignRSAState> state) { |
std::vector<uint8> public_key_vector( |
public_key_uint8, public_key_uint8 + state->public_key_.size()); |
- // TODO(pneubeck): This searches all slots. Change to look only at |slot_|. |
- crypto::ScopedSECKEYPrivateKey rsa_key( |
- crypto::FindNSSKeyFromPublicKeyInfo(public_key_vector)); |
- |
- // Fail if the key was not found. If a specific slot was requested, also fail |
- // if the key was found in the wrong slot. |
- if (!rsa_key || SECKEY_GetPrivateKeyType(rsa_key.get()) != rsaKey || |
- (state->slot_ && rsa_key->pkcs11Slot != state->slot_)) { |
+ crypto::ScopedSECKEYPrivateKey rsa_key; |
+ if (state->slot_) { |
+ rsa_key = crypto::FindNSSKeyFromPublicKeyInfoInSlot(public_key_vector, |
+ state->slot_.get()); |
+ } else { |
+ rsa_key = crypto::FindNSSKeyFromPublicKeyInfo(public_key_vector); |
+ } |
+ |
+ // Fail if the key was not found or is of the wrong type. |
+ if (!rsa_key || SECKEY_GetPrivateKeyType(rsa_key.get()) != rsaKey) { |
state->OnError(FROM_HERE, kErrorKeyNotFound); |
return; |
} |