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

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

Issue 2760723002: Check X509Certificate::CreateFromHandle result. (Closed)
Patch Set: 2nd round of updates Created 3 years, 9 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 | « no previous file | net/cert/cert_verify_proc_builtin.cc » ('j') | net/cert/cert_verify_proc_ios.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_android.h" 5 #include "net/cert/cert_verify_proc_android.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 293
294 // Save the verified chain. 294 // Save the verified chain.
295 if (!verified_chain.empty()) { 295 if (!verified_chain.empty()) {
296 std::vector<base::StringPiece> verified_chain_pieces(verified_chain.size()); 296 std::vector<base::StringPiece> verified_chain_pieces(verified_chain.size());
297 for (size_t i = 0; i < verified_chain.size(); i++) { 297 for (size_t i = 0; i < verified_chain.size(); i++) {
298 verified_chain_pieces[i] = base::StringPiece(verified_chain[i]); 298 verified_chain_pieces[i] = base::StringPiece(verified_chain[i]);
299 } 299 }
300 scoped_refptr<X509Certificate> verified_cert = 300 scoped_refptr<X509Certificate> verified_cert =
301 X509Certificate::CreateFromDERCertChain(verified_chain_pieces); 301 X509Certificate::CreateFromDERCertChain(verified_chain_pieces);
302 if (verified_cert.get()) 302 if (verified_cert.get())
303 verify_result->verified_cert = verified_cert; 303 verify_result->verified_cert = std::move(verified_cert);
304 else
305 verify_result->cert_status |= CERT_STATUS_INVALID;
304 } 306 }
305 307
306 // Extract the public key hashes. 308 // Extract the public key hashes.
307 for (size_t i = 0; i < verified_chain.size(); i++) { 309 for (size_t i = 0; i < verified_chain.size(); i++) {
308 base::StringPiece spki_bytes; 310 base::StringPiece spki_bytes;
309 if (!asn1::ExtractSPKIFromDERCert(verified_chain[i], &spki_bytes)) 311 if (!asn1::ExtractSPKIFromDERCert(verified_chain[i], &spki_bytes)) {
312 verify_result->cert_status |= CERT_STATUS_INVALID;
310 continue; 313 continue;
314 }
311 315
312 HashValue sha1(HASH_VALUE_SHA1); 316 HashValue sha1(HASH_VALUE_SHA1);
313 base::SHA1HashBytes(reinterpret_cast<const uint8_t*>(spki_bytes.data()), 317 base::SHA1HashBytes(reinterpret_cast<const uint8_t*>(spki_bytes.data()),
314 spki_bytes.size(), sha1.data()); 318 spki_bytes.size(), sha1.data());
315 verify_result->public_key_hashes.push_back(sha1); 319 verify_result->public_key_hashes.push_back(sha1);
316 320
317 HashValue sha256(HASH_VALUE_SHA256); 321 HashValue sha256(HASH_VALUE_SHA256);
318 crypto::SHA256HashString(spki_bytes, sha256.data(), crypto::kSHA256Length); 322 crypto::SHA256HashString(spki_bytes, sha256.data(), crypto::kSHA256Length);
319 verify_result->public_key_hashes.push_back(sha256); 323 verify_result->public_key_hashes.push_back(sha256);
320 } 324 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 return ERR_FAILED; 403 return ERR_FAILED;
400 } 404 }
401 405
402 if (IsCertStatusError(verify_result->cert_status)) 406 if (IsCertStatusError(verify_result->cert_status))
403 return MapCertStatusToNetError(verify_result->cert_status); 407 return MapCertStatusToNetError(verify_result->cert_status);
404 408
405 return OK; 409 return OK;
406 } 410 }
407 411
408 } // namespace net 412 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/cert/cert_verify_proc_builtin.cc » ('j') | net/cert/cert_verify_proc_ios.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698