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

Side by Side Diff: net/cert/cert_verify_proc_ios.cc

Issue 2610903003: [refactor] Extract the CertVerifyResult assignment of has_md2, has_md4, (Closed)
Patch Set: moar Created 3 years, 11 months 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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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_ios.h" 5 #include "net/cert/cert_verify_proc_ios.h"
6 6
7 #include <CommonCrypto/CommonDigest.h> 7 #include <CommonCrypto/CommonDigest.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/scoped_cftyperef.h" 10 #include "base/mac/scoped_cftyperef.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (i == 0) { 118 if (i == 0) {
119 verified_cert = chain_cert; 119 verified_cert = chain_cert;
120 } else { 120 } else {
121 verified_chain.push_back(chain_cert); 121 verified_chain.push_back(chain_cert);
122 } 122 }
123 123
124 std::string der_bytes; 124 std::string der_bytes;
125 if (!X509Certificate::GetDEREncoded(chain_cert, &der_bytes)) 125 if (!X509Certificate::GetDEREncoded(chain_cert, &der_bytes))
126 return; 126 return;
127 const uint8_t* bytes = reinterpret_cast<const uint8_t*>(der_bytes.data()); 127 const uint8_t* bytes = reinterpret_cast<const uint8_t*>(der_bytes.data());
128 bssl::UniquePtr<X509> x509_cert(d2i_X509(NULL, &bytes, der_bytes.size()));
129 128
130 base::StringPiece spki_bytes; 129 base::StringPiece spki_bytes;
131 if (!asn1::ExtractSPKIFromDERCert(der_bytes, &spki_bytes)) 130 if (!asn1::ExtractSPKIFromDERCert(der_bytes, &spki_bytes))
132 continue; 131 continue;
133 132
134 HashValue sha1(HASH_VALUE_SHA1); 133 HashValue sha1(HASH_VALUE_SHA1);
135 CC_SHA1(spki_bytes.data(), spki_bytes.size(), sha1.data()); 134 CC_SHA1(spki_bytes.data(), spki_bytes.size(), sha1.data());
136 verify_result->public_key_hashes.push_back(sha1); 135 verify_result->public_key_hashes.push_back(sha1);
137 136
138 HashValue sha256(HASH_VALUE_SHA256); 137 HashValue sha256(HASH_VALUE_SHA256);
139 CC_SHA256(spki_bytes.data(), spki_bytes.size(), sha256.data()); 138 CC_SHA256(spki_bytes.data(), spki_bytes.size(), sha256.data());
140 verify_result->public_key_hashes.push_back(sha256); 139 verify_result->public_key_hashes.push_back(sha256);
141 140
142 // Ignore the signature algorithm for the trust anchor. 141 // Ignore the signature algorithm for the trust anchor.
143 if ((verify_result->cert_status & CERT_STATUS_AUTHORITY_INVALID) == 0 && 142 if ((verify_result->cert_status & CERT_STATUS_AUTHORITY_INVALID) == 0 &&
144 i == count - 1) { 143 i == count - 1) {
145 continue; 144 continue;
146 } 145 }
147 146 FillCertVerifyResultWeakSignature(chain_cert, i == 0, verify_result);
148 int sig_alg = OBJ_obj2nid(x509_cert->sig_alg->algorithm);
149 if (sig_alg == NID_md2WithRSAEncryption) {
150 verify_result->has_md2 = true;
151 } else if (sig_alg == NID_md4WithRSAEncryption) {
152 verify_result->has_md4 = true;
153 } else if (sig_alg == NID_md5WithRSAEncryption ||
154 sig_alg == NID_md5WithRSA) {
155 verify_result->has_md5 = true;
156 } else if (sig_alg == NID_sha1WithRSAEncryption ||
157 sig_alg == NID_dsaWithSHA || sig_alg == NID_dsaWithSHA1 ||
158 sig_alg == NID_dsaWithSHA1_2 || sig_alg == NID_sha1WithRSA ||
159 sig_alg == NID_ecdsa_with_SHA1) {
160 verify_result->has_sha1 = true;
161 if (i == 0)
162 verify_result->has_sha1_leaf = true;
163 }
164 } 147 }
165 if (!verified_cert) { 148 if (!verified_cert) {
166 NOTREACHED(); 149 NOTREACHED();
167 return; 150 return;
168 } 151 }
169 152
170 verify_result->verified_cert = 153 verify_result->verified_cert =
171 X509Certificate::CreateFromHandle(verified_cert, verified_chain); 154 X509Certificate::CreateFromHandle(verified_cert, verified_chain);
172 } 155 }
173 156
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 282
300 verify_result->is_issued_by_known_root = false; 283 verify_result->is_issued_by_known_root = false;
301 284
302 if (IsCertStatusError(verify_result->cert_status)) 285 if (IsCertStatusError(verify_result->cert_status))
303 return MapCertStatusToNetError(verify_result->cert_status); 286 return MapCertStatusToNetError(verify_result->cert_status);
304 287
305 return OK; 288 return OK;
306 } 289 }
307 290
308 } // namespace net 291 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698