commit | db7726aee7993008dff742790337f950fb371ebf | [log] [tgz] |
---|---|---|
author | dougsteed <[email protected]> | Wed Sep 10 23:21:48 2014 |
committer | Commit bot <[email protected]> | Wed Sep 10 23:25:47 2014 |
tree | 0ab743ac87b4724b2b1a88df5a4c0edf53673c6b | |
parent | 7e8e1bc34c946f7f361bfd16c2628170b55dd45a [diff] [blame] |
Allow a crypto::RSAPrivateKey object to be wrapped round a pre-existing openssl key, as is currently supported for NSS. Change-Id: I36c848884273fe8e23451259655680b6b7d46a98 BUG=412427 [email protected] Review URL: https://codereview.chromium.org/559623002 Cr-Commit-Position: refs/heads/master@{#294254}
diff --git a/crypto/rsa_private_key_openssl.cc b/crypto/rsa_private_key_openssl.cc index 8dcde61..053c4a2 100644 --- a/crypto/rsa_private_key_openssl.cc +++ b/crypto/rsa_private_key_openssl.cc
@@ -98,6 +98,16 @@ return result.release(); } +// static +RSAPrivateKey* RSAPrivateKey::CreateFromKey(EVP_PKEY* key) { + DCHECK(key); + if (EVP_PKEY_type(key->type) != EVP_PKEY_RSA) + return NULL; + RSAPrivateKey* copy = new RSAPrivateKey(); + copy->key_ = EVP_PKEY_dup(key); + return copy; +} + RSAPrivateKey::RSAPrivateKey() : key_(NULL) { }