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

Unified Diff: crypto/rsa_private_key_win.cc

Issue 8727014: Implement RSAPrivateKey::Copy() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years 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
« no previous file with comments | « crypto/rsa_private_key_unittest.cc ('k') | remoting/protocol/v1_authenticator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/rsa_private_key_win.cc
diff --git a/crypto/rsa_private_key_win.cc b/crypto/rsa_private_key_win.cc
index f7363422db8b18928e95c8b2bd98690a0bc7f3d4..d87c1ec058a79f849b22bc33482842c85d67d2ca 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,
« no previous file with comments | « crypto/rsa_private_key_unittest.cc ('k') | remoting/protocol/v1_authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698