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

Unified Diff: base/crypto/rsa_private_key_mac.cc

Issue 6312157: Add ability to create self signed certs to mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 months 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: base/crypto/rsa_private_key_mac.cc
diff --git a/base/crypto/rsa_private_key_mac.cc b/base/crypto/rsa_private_key_mac.cc
index e46e93ee68c1e1618dfaf88a82f486b1c85cb242..75e09f13ea36774f53a53087c83bff5a7d8e17de 100644
--- a/base/crypto/rsa_private_key_mac.cc
+++ b/base/crypto/rsa_private_key_mac.cc
@@ -33,7 +33,7 @@ RSAPrivateKey* RSAPrivateKey::Create(uint16 num_bits) {
crtn = CSSM_GenerateKeyPair(cc_handle,
CSSM_KEYUSE_VERIFY,
CSSM_KEYATTR_RETURN_DATA | CSSM_KEYATTR_EXTRACTABLE, &label,
- &public_key, CSSM_KEYUSE_SIGN,
+ result->public_key(), CSSM_KEYUSE_SIGN,
CSSM_KEYATTR_RETURN_DATA | CSSM_KEYATTR_EXTRACTABLE, &label, NULL,
result->key());
CSSM_DeleteContext(cc_handle);
@@ -42,9 +42,6 @@ RSAPrivateKey* RSAPrivateKey::Create(uint16 num_bits) {
return NULL;
}
- // Public key is not needed.
- CSSM_FreeKey(GetSharedCSPHandle(), NULL, &public_key, CSSM_FALSE);
-
return result.release();
}
@@ -131,7 +128,9 @@ RSAPrivateKey::RSAPrivateKey() {
RSAPrivateKey::~RSAPrivateKey() {
if (key_.KeyData.Data) {
- CSSM_FreeKey(GetSharedCSPHandle(), NULL, &key_, CSSM_FALSE);
+ CSSM_CSP_HANDLE csp_handle = GetSharedCSPHandle();
+ CSSM_FreeKey(csp_handle, NULL, &key_, CSSM_FALSE);
+ CSSM_FreeKey(csp_handle, NULL, &public_key_, CSSM_FALSE);
}
}
@@ -146,12 +145,13 @@ bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) {
}
bool RSAPrivateKey::ExportPublicKey(std::vector<uint8>* output) {
- PrivateKeyInfoCodec private_key_info(true);
- std::vector<uint8> private_key_data;
- private_key_data.assign(key_.KeyData.Data,
- key_.KeyData.Data + key_.KeyData.Length);
- return (private_key_info.Import(private_key_data) &&
- private_key_info.ExportPublicKeyInfo(output));
+ if (!public_key_.KeyData.Data || !public_key_.KeyData.Length) {
+ return false;
+ }
+ output->clear();
+ output->insert(output->end(), public_key_.KeyData.Data,
+ public_key_.KeyData.Data + public_key_.KeyData.Length);
+ return true;
}
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698