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

Side by Side Diff: net/base/cert_verify_proc_win.cc

Issue 10836150: Revert 150375 - Implement SHA-256 fingerprint support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/base/cert_verify_proc_unittest.cc ('k') | net/base/cert_verify_result.h » ('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) 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/base/cert_verify_proc_win.h" 5 #include "net/base/cert_verify_proc_win.h"
6 6
7 #include <string>
8 #include <vector>
9
10 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
11 #include "base/sha1.h" 8 #include "base/sha1.h"
12 #include "base/string_util.h" 9 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
14 #include "crypto/capi_util.h" 11 #include "crypto/capi_util.h"
15 #include "crypto/scoped_capi_types.h" 12 #include "crypto/scoped_capi_types.h"
16 #include "crypto/sha2.h" 13 #include "crypto/sha2.h"
17 #include "net/base/asn1_util.h" 14 #include "net/base/asn1_util.h"
18 #include "net/base/cert_status_flags.h" 15 #include "net/base/cert_status_flags.h"
19 #include "net/base/cert_verify_result.h" 16 #include "net/base/cert_verify_result.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // which we recognise as a standard root. 275 // which we recognise as a standard root.
279 // static 276 // static
280 bool IsIssuedByKnownRoot(PCCERT_CHAIN_CONTEXT chain_context) { 277 bool IsIssuedByKnownRoot(PCCERT_CHAIN_CONTEXT chain_context) {
281 PCERT_SIMPLE_CHAIN first_chain = chain_context->rgpChain[0]; 278 PCERT_SIMPLE_CHAIN first_chain = chain_context->rgpChain[0];
282 int num_elements = first_chain->cElement; 279 int num_elements = first_chain->cElement;
283 if (num_elements < 1) 280 if (num_elements < 1)
284 return false; 281 return false;
285 PCERT_CHAIN_ELEMENT* element = first_chain->rgpElement; 282 PCERT_CHAIN_ELEMENT* element = first_chain->rgpElement;
286 PCCERT_CONTEXT cert = element[num_elements - 1]->pCertContext; 283 PCCERT_CONTEXT cert = element[num_elements - 1]->pCertContext;
287 284
288 SHA1HashValue hash = X509Certificate::CalculateFingerprint(cert); 285 SHA1Fingerprint hash = X509Certificate::CalculateFingerprint(cert);
289 return IsSHA1HashInSortedArray( 286 return IsSHA1HashInSortedArray(
290 hash, &kKnownRootCertSHA1Hashes[0][0], sizeof(kKnownRootCertSHA1Hashes)); 287 hash, &kKnownRootCertSHA1Hashes[0][0], sizeof(kKnownRootCertSHA1Hashes));
291 } 288 }
292 289
293 // Saves some information about the certificate chain |chain_context| in 290 // Saves some information about the certificate chain |chain_context| in
294 // |*verify_result|. The caller MUST initialize |*verify_result| before 291 // |*verify_result|. The caller MUST initialize |*verify_result| before
295 // calling this function. 292 // calling this function.
296 void GetCertChainInfo(PCCERT_CHAIN_CONTEXT chain_context, 293 void GetCertChainInfo(PCCERT_CHAIN_CONTEXT chain_context,
297 CertVerifyResult* verify_result) { 294 CertVerifyResult* verify_result) {
298 if (chain_context->cChain == 0) 295 if (chain_context->cChain == 0)
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 default: 434 default:
438 NOTREACHED(); 435 NOTREACHED();
439 continue; 436 continue;
440 } 437 }
441 } 438 }
442 439
443 return true; 440 return true;
444 } 441 }
445 442
446 void AppendPublicKeyHashes(PCCERT_CHAIN_CONTEXT chain, 443 void AppendPublicKeyHashes(PCCERT_CHAIN_CONTEXT chain,
447 std::vector<HashValueVector>* hashes) { 444 std::vector<SHA1Fingerprint>* hashes) {
448 if (chain->cChain == 0) 445 if (chain->cChain == 0)
449 return; 446 return;
450 447
451 PCERT_SIMPLE_CHAIN first_chain = chain->rgpChain[0]; 448 PCERT_SIMPLE_CHAIN first_chain = chain->rgpChain[0];
452 PCERT_CHAIN_ELEMENT* const element = first_chain->rgpElement; 449 PCERT_CHAIN_ELEMENT* const element = first_chain->rgpElement;
453 450
454 const DWORD num_elements = first_chain->cElement; 451 const DWORD num_elements = first_chain->cElement;
455 for (DWORD i = 0; i < num_elements; i++) { 452 for (DWORD i = 0; i < num_elements; i++) {
456 PCCERT_CONTEXT cert = element[i]->pCertContext; 453 PCCERT_CONTEXT cert = element[i]->pCertContext;
457 454
458 base::StringPiece der_bytes( 455 base::StringPiece der_bytes(
459 reinterpret_cast<const char*>(cert->pbCertEncoded), 456 reinterpret_cast<const char*>(cert->pbCertEncoded),
460 cert->cbCertEncoded); 457 cert->cbCertEncoded);
461 base::StringPiece spki_bytes; 458 base::StringPiece spki_bytes;
462 if (!asn1::ExtractSPKIFromDERCert(der_bytes, &spki_bytes)) 459 if (!asn1::ExtractSPKIFromDERCert(der_bytes, &spki_bytes))
463 continue; 460 continue;
464 461
465 HashValue sha1; 462 SHA1Fingerprint hash;
466 sha1.tag = HASH_VALUE_SHA1;
467 base::SHA1HashBytes(reinterpret_cast<const uint8*>(spki_bytes.data()), 463 base::SHA1HashBytes(reinterpret_cast<const uint8*>(spki_bytes.data()),
468 spki_bytes.size(), sha1.data()); 464 spki_bytes.size(), hash.data);
469 (*hashes)[HASH_VALUE_SHA1].push_back(sha1); 465 hashes->push_back(hash);
470
471 HashValue sha256;
472 sha256.tag = HASH_VALUE_SHA256;
473 crypto::SHA256HashString(spki_bytes, sha1.data(), crypto::kSHA256Length);
474 (*hashes)[HASH_VALUE_SHA256].push_back(sha256);
475 } 466 }
476 } 467 }
477 468
478 // Returns true if the certificate is an extended-validation certificate. 469 // Returns true if the certificate is an extended-validation certificate.
479 // 470 //
480 // This function checks the certificatePolicies extensions of the 471 // This function checks the certificatePolicies extensions of the
481 // certificates in the certificate chain according to Section 7 (pp. 11-12) 472 // certificates in the certificate chain according to Section 7 (pp. 11-12)
482 // of the EV Certificate Guidelines Version 1.0 at 473 // of the EV Certificate Guidelines Version 1.0 at
483 // http://cabforum.org/EV_Certificate_Guidelines.pdf. 474 // http://cabforum.org/EV_Certificate_Guidelines.pdf.
484 bool CheckEV(PCCERT_CHAIN_CONTEXT chain_context, 475 bool CheckEV(PCCERT_CHAIN_CONTEXT chain_context,
(...skipping 20 matching lines...) Expand all
505 // Check the end certificate simple chain (chain_context->rgpChain[0]). 496 // Check the end certificate simple chain (chain_context->rgpChain[0]).
506 // If the end certificate's certificatePolicies extension contains the 497 // If the end certificate's certificatePolicies extension contains the
507 // EV policy OID of the root CA, return true. 498 // EV policy OID of the root CA, return true.
508 PCERT_CHAIN_ELEMENT* element = chain_context->rgpChain[0]->rgpElement; 499 PCERT_CHAIN_ELEMENT* element = chain_context->rgpChain[0]->rgpElement;
509 int num_elements = chain_context->rgpChain[0]->cElement; 500 int num_elements = chain_context->rgpChain[0]->cElement;
510 if (num_elements < 2) 501 if (num_elements < 2)
511 return false; 502 return false;
512 503
513 // Look up the EV policy OID of the root CA. 504 // Look up the EV policy OID of the root CA.
514 PCCERT_CONTEXT root_cert = element[num_elements - 1]->pCertContext; 505 PCCERT_CONTEXT root_cert = element[num_elements - 1]->pCertContext;
515 SHA1HashValue fingerprint = 506 SHA1Fingerprint fingerprint =
516 X509Certificate::CalculateFingerprint(root_cert); 507 X509Certificate::CalculateFingerprint(root_cert);
517 EVRootCAMetadata* metadata = EVRootCAMetadata::GetInstance(); 508 EVRootCAMetadata* metadata = EVRootCAMetadata::GetInstance();
518 return metadata->HasEVPolicyOID(fingerprint, policy_oid); 509 return metadata->HasEVPolicyOID(fingerprint, policy_oid);
519 } 510 }
520 511
521 } // namespace 512 } // namespace
522 513
523 CertVerifyProcWin::CertVerifyProcWin() {} 514 CertVerifyProcWin::CertVerifyProcWin() {}
524 515
525 CertVerifyProcWin::~CertVerifyProcWin() {} 516 CertVerifyProcWin::~CertVerifyProcWin() {}
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 verify_result->is_issued_by_known_root = IsIssuedByKnownRoot(chain_context); 733 verify_result->is_issued_by_known_root = IsIssuedByKnownRoot(chain_context);
743 734
744 if (ev_policy_oid && 735 if (ev_policy_oid &&
745 CheckEV(chain_context, rev_checking_enabled, ev_policy_oid)) { 736 CheckEV(chain_context, rev_checking_enabled, ev_policy_oid)) {
746 verify_result->cert_status |= CERT_STATUS_IS_EV; 737 verify_result->cert_status |= CERT_STATUS_IS_EV;
747 } 738 }
748 return OK; 739 return OK;
749 } 740 }
750 741
751 } // namespace net 742 } // namespace net
OLDNEW
« no previous file with comments | « net/base/cert_verify_proc_unittest.cc ('k') | net/base/cert_verify_result.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698