Index: crypto/rsa_private_key_nss.cc |
diff --git a/crypto/rsa_private_key_nss.cc b/crypto/rsa_private_key_nss.cc |
index 3b8bd4489a2446265d54cebe845b5fe1947ffc29..ea2b432b10e88a17f3bbee3aeff088be8b17bbc5 100644 |
--- a/crypto/rsa_private_key_nss.cc |
+++ b/crypto/rsa_private_key_nss.cc |
@@ -81,6 +81,22 @@ RSAPrivateKey* RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo( |
} |
// static |
+RSAPrivateKey* RSAPrivateKey::CreateFromKey(SECKEYPrivateKey* key) { |
+ DCHECK(key); |
+ if (SECKEY_GetPrivateKeyType(key) != rsaKey) |
+ return NULL; |
+ RSAPrivateKey* copy = new RSAPrivateKey(); |
+ copy->key_ = SECKEY_CopyPrivateKey(key); |
+ copy->public_key_ = SECKEY_ConvertToPublicKey(key); |
+ if (!copy->key_ || !copy->public_key_) { |
+ NOTREACHED(); |
+ delete copy; |
+ return NULL; |
+ } |
+ return copy; |
+} |
+ |
+// static |
RSAPrivateKey* RSAPrivateKey::FindFromPublicKeyInfo( |
const std::vector<uint8>& input) { |
EnsureNSSInit(); |