Index: net/base/x509_certificate_mac.cc |
=================================================================== |
--- net/base/x509_certificate_mac.cc (revision 110129) |
+++ net/base/x509_certificate_mac.cc (working copy) |
@@ -733,7 +733,7 @@ |
} |
CSSM_BOOL confirmRequired; |
- CSSM_TP_RESULT_SET *resultSet = NULL; |
+ CSSM_TP_RESULT_SET* resultSet = NULL; |
crtn = CSSM_TP_RetrieveCredResult(tp_handle, &refId, NULL, &estTime, |
&confirmRequired, &resultSet); |
ScopedEncodedCertResults scopedResults(resultSet); |
@@ -1437,4 +1437,43 @@ |
cert_data.Length); |
} |
+// static |
+void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, |
+ size_t* size_bits, |
+ PublicKeyType* type) { |
+ SecKeyRef key; |
+ OSStatus status = SecCertificateCopyPublicKey(cert_handle, &key); |
+ if (status) { |
+ NOTREACHED() << "SecCertificateCopyPublicKey failed: " << status; |
+ return; |
wtc
2011/11/17 02:52:18
Since this function returns void, it should always
|
+ } |
+ ScopedCFTypeRef<SecKeyRef> scoped_key; |
Ryan Sleevi
2011/11/17 03:20:33
ScopedCFTypeRef<SecKeyRef> scoped_key(key);
|
+ |
+ const CSSM_KEY* cssm_key; |
+ status = SecKeyGetCSSMKey(key, &cssm_key); |
+ if (status) { |
+ NOTREACHED() << "SecKeyGetCSSMKey failed: " << status; |
+ return; |
+ } |
+ |
+ *size_bits = cssm_key->KeyHeader.LogicalKeySizeInBits; |
+ |
+ switch (cssm_key->KeyHeader.AlgorithmId) { |
+ case CSSM_ALGID_RSA: |
+ *type = kPublicKeyTypeRSA; |
+ break; |
+ case CSSM_ALGID_DSA: |
+ *type = kPublicKeyTypeDSA; |
+ break; |
+ case CSSM_ALGID_ECDSA: |
+ *type = kPublicKeyTypeECDSA; |
+ break; |
+ case CSSM_ALGID_DH: |
+ *type = kPublicKeyTypeDH; |
+ break; |
+ default: |
+ *type = kPublicKeyTypeUnknown; |
wtc
2011/11/17 02:52:18
Nit: add a break statement.
Make the same change
|
+ } |
+} |
+ |
} // namespace net |