Index: crypto/rsa_private_key_openssl.cc |
diff --git a/crypto/rsa_private_key_openssl.cc b/crypto/rsa_private_key_openssl.cc |
index 63efb9c4f875e2e50b85ded1c7ed2664bca0aff7..5cfdcd3ce0b1040623e0ba7e19022b9df15d6706 100644 |
--- a/crypto/rsa_private_key_openssl.cc |
+++ b/crypto/rsa_private_key_openssl.cc |
@@ -124,6 +124,17 @@ RSAPrivateKey::~RSAPrivateKey() { |
EVP_PKEY_free(key_); |
} |
+RSAPrivateKey* RSAPrivateKey::Copy() const { |
+ scoped_ptr<RSAPrivateKey> copy(new RSAPrivateKey()); |
+ RSA* rsa = EVP_PKEY_get1_RSA(key_); |
+ if (!rsa) |
+ return NULL; |
+ copy->key_ = EVP_PKEY_new(); |
+ if (!EVP_PKEY_set1_RSA(copy->key_, rsa)) |
+ return NULL; |
+ return copy.release(); |
+} |
+ |
bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) { |
return ExportKey(key_, i2d_PKCS8PrivateKeyInfo_bio, output); |
} |