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

Unified Diff: net/base/x509_certificate_nss.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
« no previous file with comments | « net/base/x509_certificate_mac.cc ('k') | net/base/x509_certificate_openssl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/x509_certificate_nss.cc
===================================================================
--- net/base/x509_certificate_nss.cc (revision 114571)
+++ net/base/x509_certificate_nss.cc (working copy)
@@ -1142,4 +1142,38 @@
cert_handle->derCert.len);
}
+// 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;
+
+ SECKEYPublicKey* key = CERT_ExtractPublicKey(cert_handle);
+ if (!key)
+ return;
+
+ *size_bits = SECKEY_PublicKeyStrengthInBits(key);
+
+ switch (key->keyType) {
+ case rsaKey:
+ *type = kPublicKeyTypeRSA;
+ break;
+ case dsaKey:
+ *type = kPublicKeyTypeDSA;
+ break;
+ case dhKey:
+ *type = kPublicKeyTypeDH;
+ break;
+ case ecKey:
+ *type = kPublicKeyTypeECDSA;
+ break;
+ default:
+ *type = kPublicKeyTypeUnknown;
+ *size_bits = 0;
+ break;
+ }
Timur Iskhodzhanov 2011/12/16 08:35:39 forgotten to SECKEY_DestroyPublicKey(key) ?
+}
+
} // namespace net
« no previous file with comments | « net/base/x509_certificate_mac.cc ('k') | net/base/x509_certificate_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698