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

Unified Diff: net/base/x509_certificate_mac.cc

Issue 8568040: Refuse to accept certificate chains containing any RSA public key smaller (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
Index: net/base/x509_certificate_mac.cc
===================================================================
--- net/base/x509_certificate_mac.cc (revision 114571)
+++ net/base/x509_certificate_mac.cc (working copy)
@@ -812,7 +812,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);
@@ -1514,4 +1514,49 @@
cert_data.Length);
}
+// static
+void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle,
+ size_t* size_bits,
+ PublicKeyType* type) {
+ // Since we might fail, set the output parameters to default values first.
+ *type = kPublicKeyTypeUnknown;
+ *size_bits = 0;
+
+ SecKeyRef key;
+ OSStatus status = SecCertificateCopyPublicKey(cert_handle, &key);
+ if (status) {
+ NOTREACHED() << "SecCertificateCopyPublicKey failed: " << status;
+ return;
+ }
+ ScopedCFTypeRef<SecKeyRef> scoped_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;
+ *size_bits = 0;
+ break;
+ }
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698