OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/cert/cert_verify_proc_mac.h" | 5 #include "net/cert/cert_verify_proc_mac.h" |
6 | 6 |
7 #include <CommonCrypto/CommonDigest.h> | 7 #include <CommonCrypto/CommonDigest.h> |
8 #include <CoreServices/CoreServices.h> | 8 #include <CoreServices/CoreServices.h> |
9 #include <Security/Security.h> | 9 #include <Security/Security.h> |
10 | 10 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 if ((chain_info[i].StatusBits & CSSM_CERT_STATUS_IS_IN_ANCHORS) || | 208 if ((chain_info[i].StatusBits & CSSM_CERT_STATUS_IS_IN_ANCHORS) || |
209 (chain_info[i].StatusBits & CSSM_CERT_STATUS_IS_ROOT)) { | 209 (chain_info[i].StatusBits & CSSM_CERT_STATUS_IS_ROOT)) { |
210 // The current certificate is either in the user's trusted store or is | 210 // The current certificate is either in the user's trusted store or is |
211 // a root (self-signed) certificate. Ignore the signature algorithm for | 211 // a root (self-signed) certificate. Ignore the signature algorithm for |
212 // these certificates, as it is meaningless for security. We allow | 212 // these certificates, as it is meaningless for security. We allow |
213 // self-signed certificates (i == 0 & IS_ROOT), since we accept that | 213 // self-signed certificates (i == 0 & IS_ROOT), since we accept that |
214 // any security assertions by such a cert are inherently meaningless. | 214 // any security assertions by such a cert are inherently meaningless. |
215 continue; | 215 continue; |
216 } | 216 } |
217 | 217 |
218 x509_util::CSSMCachedCertificate cached_cert; | 218 bool is_leaf = i == 0; |
219 OSStatus status = cached_cert.Init(chain_cert); | 219 auto hash_is_weak = |
Ryan Sleevi
2017/01/05 22:48:24
I would definitely argue this use of "auto" is not
eroman
2017/01/05 23:21:53
Agreed auto is wrong here (left over from earlier
eroman
2017/01/05 23:36:30
Done.
| |
220 if (status) | 220 FillCertVerifyResultWeakSignature(chain_cert, is_leaf, verify_result); |
221 continue; | 221 if (is_leaf && hash_is_weak) |
222 x509_util::CSSMFieldValue signature_field; | 222 *leaf_is_weak = hash_is_weak; |
223 status = cached_cert.GetField(&CSSMOID_X509V1SignatureAlgorithm, | |
224 &signature_field); | |
225 if (status || !signature_field.field()) | |
226 continue; | |
227 // Match the behaviour of OS X system tools and defensively check that | |
228 // sizes are appropriate. This would indicate a critical failure of the | |
229 // OS X certificate library, but based on history, it is best to play it | |
230 // safe. | |
231 const CSSM_X509_ALGORITHM_IDENTIFIER* sig_algorithm = | |
232 signature_field.GetAs<CSSM_X509_ALGORITHM_IDENTIFIER>(); | |
233 if (!sig_algorithm) | |
234 continue; | |
235 | |
236 const CSSM_OID* alg_oid = &sig_algorithm->algorithm; | |
237 if (CSSMOIDEqual(alg_oid, &CSSMOID_MD2WithRSA)) { | |
238 verify_result->has_md2 = true; | |
239 if (i == 0) | |
240 *leaf_is_weak = true; | |
241 } else if (CSSMOIDEqual(alg_oid, &CSSMOID_MD4WithRSA)) { | |
242 verify_result->has_md4 = true; | |
243 if (i == 0) | |
244 *leaf_is_weak = true; | |
245 } else if (CSSMOIDEqual(alg_oid, &CSSMOID_MD5WithRSA)) { | |
246 verify_result->has_md5 = true; | |
247 if (i == 0) | |
248 *leaf_is_weak = true; | |
249 } else if (CSSMOIDEqual(alg_oid, &CSSMOID_SHA1WithRSA) || | |
250 CSSMOIDEqual(alg_oid, &CSSMOID_SHA1WithRSA_OIW) || | |
251 CSSMOIDEqual(alg_oid, &CSSMOID_SHA1WithDSA) || | |
252 CSSMOIDEqual(alg_oid, &CSSMOID_SHA1WithDSA_CMS) || | |
253 CSSMOIDEqual(alg_oid, &CSSMOID_SHA1WithDSA_JDK) || | |
254 CSSMOIDEqual(alg_oid, &CSSMOID_ECDSA_WithSHA1)) { | |
255 verify_result->has_sha1 = true; | |
256 if (i == 0) { | |
257 verify_result->has_sha1_leaf = true; | |
258 *leaf_is_weak = true; | |
259 } | |
260 } | |
261 } | 223 } |
262 if (!verified_cert) { | 224 if (!verified_cert) { |
263 NOTREACHED(); | 225 NOTREACHED(); |
264 return; | 226 return; |
265 } | 227 } |
266 | 228 |
267 verify_result->verified_cert = | 229 verify_result->verified_cert = |
268 X509Certificate::CreateFromHandle(verified_cert, verified_chain); | 230 X509Certificate::CreateFromHandle(verified_cert, verified_chain); |
269 } | 231 } |
270 | 232 |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1102 // EV cert and it was covered by CRLSets or revocation checking passed. | 1064 // EV cert and it was covered by CRLSets or revocation checking passed. |
1103 verify_result->cert_status |= CERT_STATUS_IS_EV; | 1065 verify_result->cert_status |= CERT_STATUS_IS_EV; |
1104 } | 1066 } |
1105 | 1067 |
1106 return OK; | 1068 return OK; |
1107 } | 1069 } |
1108 | 1070 |
1109 } // namespace net | 1071 } // namespace net |
1110 | 1072 |
1111 #pragma clang diagnostic pop // "-Wdeprecated-declarations" | 1073 #pragma clang diagnostic pop // "-Wdeprecated-declarations" |
OLD | NEW |