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

Unified Diff: crypto/rsa_private_key_openssl.cc

Issue 8727014: Implement RSAPrivateKey::Copy() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month 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
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);
}

Powered by Google App Engine
This is Rietveld 408576698