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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/x509_certificate_mac.cc ('k') | net/base/x509_certificate_openssl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/x509_certificate.h" 5 #include "net/base/x509_certificate.h"
6 6
7 #include <cert.h> 7 #include <cert.h>
8 #include <cryptohi.h> 8 #include <cryptohi.h>
9 #include <keyhi.h> 9 #include <keyhi.h>
10 #include <nss.h> 10 #include <nss.h>
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 } 1135 }
1136 1136
1137 // static 1137 // static
1138 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, 1138 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle,
1139 Pickle* pickle) { 1139 Pickle* pickle) {
1140 return pickle->WriteData( 1140 return pickle->WriteData(
1141 reinterpret_cast<const char*>(cert_handle->derCert.data), 1141 reinterpret_cast<const char*>(cert_handle->derCert.data),
1142 cert_handle->derCert.len); 1142 cert_handle->derCert.len);
1143 } 1143 }
1144 1144
1145 // static
1146 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle,
1147 size_t* size_bits,
1148 PublicKeyType* type) {
1149 // Since we might fail, set the output parameters to default values first.
1150 *type = kPublicKeyTypeUnknown;
1151 *size_bits = 0;
1152
1153 SECKEYPublicKey* key = CERT_ExtractPublicKey(cert_handle);
1154 if (!key)
1155 return;
1156
1157 *size_bits = SECKEY_PublicKeyStrengthInBits(key);
1158
1159 switch (key->keyType) {
1160 case rsaKey:
1161 *type = kPublicKeyTypeRSA;
1162 break;
1163 case dsaKey:
1164 *type = kPublicKeyTypeDSA;
1165 break;
1166 case dhKey:
1167 *type = kPublicKeyTypeDH;
1168 break;
1169 case ecKey:
1170 *type = kPublicKeyTypeECDSA;
1171 break;
1172 default:
1173 *type = kPublicKeyTypeUnknown;
1174 *size_bits = 0;
1175 break;
1176 }
Timur Iskhodzhanov 2011/12/16 08:35:39 forgotten to SECKEY_DestroyPublicKey(key) ?
1177 }
1178
1145 } // namespace net 1179 } // namespace net
OLDNEW
« 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