diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-03 01:12:08 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-03 01:12:08 +0000 |
commit | 587828804aee738c6c9a71daa531c8c63672e69d (patch) | |
tree | 38a3e5a65cd9c7faa5b0a57b55f97cfe7ef3665f /crypto/rsa_private_key_win.cc | |
parent | ef589afc44a9ce7ccedb1948eace1f2fbfe7ec49 (diff) | |
download | chromium_src-587828804aee738c6c9a71daa531c8c63672e69d.zip chromium_src-587828804aee738c6c9a71daa531c8c63672e69d.tar.gz chromium_src-587828804aee738c6c9a71daa531c8c63672e69d.tar.bz2 |
Implement RSAPrivateKey::Copy()
BUG=105220
Review URL: http://codereview.chromium.org/8727014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112837 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'crypto/rsa_private_key_win.cc')
-rw-r--r-- | crypto/rsa_private_key_win.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/crypto/rsa_private_key_win.cc b/crypto/rsa_private_key_win.cc index f736342..d87c1ec0 100644 --- a/crypto/rsa_private_key_win.cc +++ b/crypto/rsa_private_key_win.cc @@ -134,7 +134,19 @@ bool RSAPrivateKey::InitProvider() { PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); } -bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) { +RSAPrivateKey* RSAPrivateKey::Copy() const { + scoped_ptr<RSAPrivateKey> copy(new RSAPrivateKey()); + if (!CryptContextAddRef(provider_, NULL, 0)) { + NOTREACHED(); + return NULL; + } + copy->provider_.reset(provider_.get()); + if (!CryptDuplicateKey(key_.get(), NULL, 0, copy->key_.receive())) + return NULL; + return copy.release(); +} + +bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) const { // Export the key DWORD blob_length = 0; if (!CryptExportKey(key_, 0, PRIVATEKEYBLOB, 0, NULL, &blob_length)) { @@ -187,7 +199,7 @@ bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) { return pki.Export(output); } -bool RSAPrivateKey::ExportPublicKey(std::vector<uint8>* output) { +bool RSAPrivateKey::ExportPublicKey(std::vector<uint8>* output) const { DWORD key_info_len; if (!CryptExportPublicKeyInfo( provider_, AT_SIGNATURE, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, |