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

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

Issue 2627523002: Refactor the assignment of CertVerifyResult::has_md2, etc. (Closed)
Patch Set: fix PrintTo() 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
« no previous file with comments | « net/cert/cert_verify_proc_android.cc ('k') | net/cert/cert_verify_proc_mac.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) 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 trust_ref->swap(scoped_tmp_trust); 98 trust_ref->swap(scoped_tmp_trust);
99 *trust_result = tmp_trust_result; 99 *trust_result = tmp_trust_result;
100 verified_chain->reset(tmp_verified_chain.release()); 100 verified_chain->reset(tmp_verified_chain.release());
101 return OK; 101 return OK;
102 } 102 }
103 103
104 void GetCertChainInfo(CFArrayRef cert_chain, CertVerifyResult* verify_result) { 104 void GetCertChainInfo(CFArrayRef cert_chain, CertVerifyResult* verify_result) {
105 DCHECK_LT(0, CFArrayGetCount(cert_chain)); 105 DCHECK_LT(0, CFArrayGetCount(cert_chain));
106 106
107 verify_result->has_md2 = false;
108 verify_result->has_md4 = false;
109 verify_result->has_md5 = false;
110 verify_result->has_sha1 = false;
111 verify_result->has_sha1_leaf = false;
112
113 SecCertificateRef verified_cert = nullptr; 107 SecCertificateRef verified_cert = nullptr;
114 std::vector<SecCertificateRef> verified_chain; 108 std::vector<SecCertificateRef> verified_chain;
115 for (CFIndex i = 0, count = CFArrayGetCount(cert_chain); i < count; ++i) { 109 for (CFIndex i = 0, count = CFArrayGetCount(cert_chain); i < count; ++i) {
116 SecCertificateRef chain_cert = reinterpret_cast<SecCertificateRef>( 110 SecCertificateRef chain_cert = reinterpret_cast<SecCertificateRef>(
117 const_cast<void*>(CFArrayGetValueAtIndex(cert_chain, i))); 111 const_cast<void*>(CFArrayGetValueAtIndex(cert_chain, i)));
118 if (i == 0) { 112 if (i == 0) {
119 verified_cert = chain_cert; 113 verified_cert = chain_cert;
120 } else { 114 } else {
121 verified_chain.push_back(chain_cert); 115 verified_chain.push_back(chain_cert);
122 } 116 }
(...skipping 12 matching lines...) Expand all
135 129
136 HashValue sha256(HASH_VALUE_SHA256); 130 HashValue sha256(HASH_VALUE_SHA256);
137 CC_SHA256(spki_bytes.data(), spki_bytes.size(), sha256.data()); 131 CC_SHA256(spki_bytes.data(), spki_bytes.size(), sha256.data());
138 verify_result->public_key_hashes.push_back(sha256); 132 verify_result->public_key_hashes.push_back(sha256);
139 133
140 // Ignore the signature algorithm for the trust anchor. 134 // Ignore the signature algorithm for the trust anchor.
141 if ((verify_result->cert_status & CERT_STATUS_AUTHORITY_INVALID) == 0 && 135 if ((verify_result->cert_status & CERT_STATUS_AUTHORITY_INVALID) == 0 &&
142 i == count - 1) { 136 i == count - 1) {
143 continue; 137 continue;
144 } 138 }
145 FillCertVerifyResultWeakSignature(chain_cert, i == 0, verify_result);
146 } 139 }
147 if (!verified_cert) { 140 if (!verified_cert) {
148 NOTREACHED(); 141 NOTREACHED();
149 return; 142 return;
150 } 143 }
151 144
152 verify_result->verified_cert = 145 verify_result->verified_cert =
153 X509Certificate::CreateFromHandle(verified_cert, verified_chain); 146 X509Certificate::CreateFromHandle(verified_cert, verified_chain);
154 } 147 }
155 148
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 274
282 verify_result->is_issued_by_known_root = false; 275 verify_result->is_issued_by_known_root = false;
283 276
284 if (IsCertStatusError(verify_result->cert_status)) 277 if (IsCertStatusError(verify_result->cert_status))
285 return MapCertStatusToNetError(verify_result->cert_status); 278 return MapCertStatusToNetError(verify_result->cert_status);
286 279
287 return OK; 280 return OK;
288 } 281 }
289 282
290 } // namespace net 283 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/cert_verify_proc_android.cc ('k') | net/cert/cert_verify_proc_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698