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

Unified Diff: net/base/x509_certificate_openssl.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_openssl.cc
===================================================================
--- net/base/x509_certificate_openssl.cc (revision 114041)
+++ net/base/x509_certificate_openssl.cc (working copy)
@@ -662,6 +662,36 @@
der_cache.data_length);
}
+// static
+void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle,
+ size_t* size_bits,
+ PublicKeyType* type) {
+ EVP_PKEY* key = X509_get_pubkey(cert_handle);
+ CHECK(key);
+
+ switch (key->type) {
+ case EVP_PKEY_RSA:
+ *type = kPublicKeyTypeRSA;
+ *size_bits = EVP_PKEY_size(key) * 8;
+ break;
+ case EVP_PKEY_DSA:
+ *type = kPublicKeyTypeDSA;
+ *size_bits = EVP_PKEY_size(key) * 8;
+ break;
+ case EVP_PKEY_EC:
+ *type = kPublicKeyTypeECDSA;
+ *size_bits = EVP_PKEY_size(key);
wtc 2011/12/13 21:56:18 It seems strange that EVP_PKEY_size returns a key
+ break;
+ case EVP_PKEY_DH:
+ *type = kPublicKeyTypeDH;
+ *size_bits = EVP_PKEY_size(key) * 8;
+ break;
+ default:
+ *type = kPublicKeyTypeUnknown;
+ *size_bits = 0;
+ }
+}
+
#if defined(OS_ANDROID)
void X509Certificate::GetChainDEREncodedBytes(
std::vector<std::string>* chain_bytes) const {

Powered by Google App Engine
This is Rietveld 408576698