Chromium Code Reviews| 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/base/cert_verify_proc_win.h" | 5 #include "net/base/cert_verify_proc_win.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "crypto/capi_util.h" | 11 #include "crypto/capi_util.h" |
| 12 #include "crypto/scoped_capi_types.h" | 12 #include "crypto/scoped_capi_types.h" |
| 13 #include "crypto/sha2.h" | 13 #include "crypto/sha2.h" |
| 14 #include "net/base/asn1_util.h" | 14 #include "net/base/asn1_util.h" |
| 15 #include "net/base/cert_status_flags.h" | 15 #include "net/base/cert_status_flags.h" |
| 16 #include "net/base/cert_verify_result.h" | 16 #include "net/base/cert_verify_result.h" |
| 17 #include "net/base/crl_set.h" | 17 #include "net/base/crl_set.h" |
| 18 #include "net/base/ev_root_ca_metadata.h" | 18 #include "net/base/ev_root_ca_metadata.h" |
| 19 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 20 #include "net/base/test_root_certs.h" | 20 #include "net/base/test_root_certs.h" |
| 21 #include "net/base/x509_certificate.h" | 21 #include "net/base/x509_certificate.h" |
| 22 #include "net/base/x509_certificate_known_roots_win.h" | 22 #include "net/base/x509_certificate_known_roots_win.h" |
| 23 | 23 |
| 24 #pragma comment(lib, "crypt32.lib") | 24 #pragma comment(lib, "crypt32.lib") |
| 25 | 25 |
| 26 #if !defined(CERT_TRUST_HAS_WEAK_SIGNATURE) | |
| 27 // This was introduced in Windows 8 / Windows Server 2012, but retroactively | |
| 28 // ported as far back as Windows XP via system update. | |
| 29 #define CERT_TRUST_HAS_WEAK_SIGNATURE 0x00100000 | |
| 30 #endif | |
| 31 | |
| 26 namespace net { | 32 namespace net { |
| 27 | 33 |
| 28 namespace { | 34 namespace { |
| 29 | 35 |
| 30 struct FreeChainEngineFunctor { | 36 struct FreeChainEngineFunctor { |
| 31 void operator()(HCERTCHAINENGINE engine) const { | 37 void operator()(HCERTCHAINENGINE engine) const { |
| 32 if (engine) | 38 if (engine) |
| 33 CertFreeCertificateChainEngine(engine); | 39 CertFreeCertificateChainEngine(engine); |
| 34 } | 40 } |
| 35 }; | 41 }; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 if (error_status & CERT_TRUST_IS_REVOKED) | 139 if (error_status & CERT_TRUST_IS_REVOKED) |
| 134 cert_status |= CERT_STATUS_REVOKED; | 140 cert_status |= CERT_STATUS_REVOKED; |
| 135 | 141 |
| 136 const DWORD kWrongUsageErrors = CERT_TRUST_IS_NOT_VALID_FOR_USAGE | | 142 const DWORD kWrongUsageErrors = CERT_TRUST_IS_NOT_VALID_FOR_USAGE | |
| 137 CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE; | 143 CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE; |
| 138 if (error_status & kWrongUsageErrors) { | 144 if (error_status & kWrongUsageErrors) { |
| 139 // TODO(wtc): Should we add CERT_STATUS_WRONG_USAGE? | 145 // TODO(wtc): Should we add CERT_STATUS_WRONG_USAGE? |
| 140 cert_status |= CERT_STATUS_INVALID; | 146 cert_status |= CERT_STATUS_INVALID; |
| 141 } | 147 } |
| 142 | 148 |
| 149 if (error_status & CERT_TRUST_IS_NOT_SIGNATURE_VALID) { | |
| 150 // Check for a signature that does not meet the OS criteria for strong | |
| 151 // signatures. | |
| 152 // Note: These checks may be more restrictive than the current weak key | |
| 153 // criteria implemented within CertVerifier, such as excluding SHA-1 or | |
| 154 // excluding RSA keys < 2048 bits. However, if the user has configured | |
|
wtc
2012/06/14 00:33:16
This comment is a little confusing because it's no
| |
| 155 // these more stringent checks, respect that configuration and err on the | |
| 156 // more restrictive criteria. | |
| 157 if (error_status & CERT_TRUST_HAS_WEAK_SIGNATURE) { | |
| 158 cert_status |= CERT_STATUS_WEAK_KEY; | |
|
wtc
2012/06/14 00:33:16
Could also be CERT_STATUS_WEAK_SIGNATURE_ALGORITHM
| |
| 159 } else { | |
| 160 cert_status |= CERT_STATUS_INVALID; | |
| 161 } | |
| 162 } | |
| 163 | |
| 143 // The rest of the errors. | 164 // The rest of the errors. |
| 144 const DWORD kCertInvalidErrors = | 165 const DWORD kCertInvalidErrors = |
| 145 CERT_TRUST_IS_NOT_SIGNATURE_VALID | | |
| 146 CERT_TRUST_IS_CYCLIC | | 166 CERT_TRUST_IS_CYCLIC | |
| 147 CERT_TRUST_INVALID_EXTENSION | | 167 CERT_TRUST_INVALID_EXTENSION | |
| 148 CERT_TRUST_INVALID_POLICY_CONSTRAINTS | | 168 CERT_TRUST_INVALID_POLICY_CONSTRAINTS | |
| 149 CERT_TRUST_INVALID_BASIC_CONSTRAINTS | | 169 CERT_TRUST_INVALID_BASIC_CONSTRAINTS | |
| 150 CERT_TRUST_INVALID_NAME_CONSTRAINTS | | 170 CERT_TRUST_INVALID_NAME_CONSTRAINTS | |
| 151 CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID | | 171 CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID | |
| 152 CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT | | 172 CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT | |
| 153 CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT | | 173 CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT | |
| 154 CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT | | 174 CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT | |
| 155 CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT | | 175 CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT | |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 713 verify_result->is_issued_by_known_root = IsIssuedByKnownRoot(chain_context); | 733 verify_result->is_issued_by_known_root = IsIssuedByKnownRoot(chain_context); |
| 714 | 734 |
| 715 if (ev_policy_oid && | 735 if (ev_policy_oid && |
| 716 CheckEV(chain_context, rev_checking_enabled, ev_policy_oid)) { | 736 CheckEV(chain_context, rev_checking_enabled, ev_policy_oid)) { |
| 717 verify_result->cert_status |= CERT_STATUS_IS_EV; | 737 verify_result->cert_status |= CERT_STATUS_IS_EV; |
| 718 } | 738 } |
| 719 return OK; | 739 return OK; |
| 720 } | 740 } |
| 721 | 741 |
| 722 } // namespace net | 742 } // namespace net |
| OLD | NEW |