Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/internal/verify_certificate_chain.h" | 5 #include "net/cert/internal/verify_certificate_chain.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "net/cert/internal/cert_errors.h" | 10 #include "net/cert/internal/cert_errors.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 | 153 |
| 154 // Verify the digital signature using the previous certificate's key (RFC | 154 // Verify the digital signature using the previous certificate's key (RFC |
| 155 // 5280 section 6.1.3 step a.1). | 155 // 5280 section 6.1.3 step a.1). |
| 156 if (!cert.has_valid_supported_signature_algorithm()) { | 156 if (!cert.has_valid_supported_signature_algorithm()) { |
| 157 errors->AddWith1DerParam(kInvalidOrUnsupportedAlgorithm, | 157 errors->AddWith1DerParam(kInvalidOrUnsupportedAlgorithm, |
| 158 cert.signature_algorithm_tlv()); | 158 cert.signature_algorithm_tlv()); |
| 159 return false; | 159 return false; |
| 160 } | 160 } |
| 161 | 161 |
| 162 if (!VerifySignedData(cert.signature_algorithm(), cert.tbs_certificate_tlv(), | 162 if (!VerifySignedData(cert.signature_algorithm(), cert.tbs_certificate_tlv(), |
| 163 cert.signature_value(), working_spki, | 163 cert.signature_value(), working_spki, signature_policy, |
| 164 signature_policy)) { | 164 errors)) { |
| 165 errors->Add(kSignatureVerificationFailed); | 165 errors->Add(kVerifySignedDataFailed); |
|
eroman
2016/08/30 21:57:40
I will explore making errors hiearchical in a foll
| |
| 166 return false; | 166 return false; |
| 167 } | 167 } |
| 168 | 168 |
| 169 // Check the time range for the certificate's validity, ensuring it is valid | 169 // Check the time range for the certificate's validity, ensuring it is valid |
| 170 // at |time|. | 170 // at |time|. |
| 171 // (RFC 5280 section 6.1.3 step a.2) | 171 // (RFC 5280 section 6.1.3 step a.2) |
| 172 if (!VerifyTimeValidity(cert, time, errors)) | 172 if (!VerifyTimeValidity(cert, time, errors)) |
| 173 return false; | 173 return false; |
| 174 | 174 |
| 175 // TODO(eroman): Check revocation (RFC 5280 section 6.1.3 step a.3) | 175 // TODO(eroman): Check revocation (RFC 5280 section 6.1.3 step a.3) |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 DEFINE_CERT_ERROR_TYPE(kKeyCertSignBitNotSet, "keyCertSign bit is not set"); | 581 DEFINE_CERT_ERROR_TYPE(kKeyCertSignBitNotSet, "keyCertSign bit is not set"); |
| 582 DEFINE_CERT_ERROR_TYPE(kMaxPathLengthViolated, "max_path_length reached"); | 582 DEFINE_CERT_ERROR_TYPE(kMaxPathLengthViolated, "max_path_length reached"); |
| 583 DEFINE_CERT_ERROR_TYPE(kBasicConstraintsIndicatesNotCa, | 583 DEFINE_CERT_ERROR_TYPE(kBasicConstraintsIndicatesNotCa, |
| 584 "Basic Constraints indicates not a CA"); | 584 "Basic Constraints indicates not a CA"); |
| 585 DEFINE_CERT_ERROR_TYPE(kMissingBasicConstraints, | 585 DEFINE_CERT_ERROR_TYPE(kMissingBasicConstraints, |
| 586 "Does not have Basic Constraints"); | 586 "Does not have Basic Constraints"); |
| 587 DEFINE_CERT_ERROR_TYPE(kNotPermittedByNameConstraints, | 587 DEFINE_CERT_ERROR_TYPE(kNotPermittedByNameConstraints, |
| 588 "Not permitted by name constraints"); | 588 "Not permitted by name constraints"); |
| 589 DEFINE_CERT_ERROR_TYPE(kSubjectDoesNotMatchIssuer, | 589 DEFINE_CERT_ERROR_TYPE(kSubjectDoesNotMatchIssuer, |
| 590 "subject does not match issuer"); | 590 "subject does not match issuer"); |
| 591 DEFINE_CERT_ERROR_TYPE(kSignatureVerificationFailed, | 591 DEFINE_CERT_ERROR_TYPE(kVerifySignedDataFailed, "VerifySignedData failed"); |
| 592 "Signature verification failed"); | |
| 593 DEFINE_CERT_ERROR_TYPE(kValidityFailedNotAfter, "Time is after notAfter"); | 592 DEFINE_CERT_ERROR_TYPE(kValidityFailedNotAfter, "Time is after notAfter"); |
| 594 DEFINE_CERT_ERROR_TYPE(kValidityFailedNotBefore, "Time is before notBefore"); | 593 DEFINE_CERT_ERROR_TYPE(kValidityFailedNotBefore, "Time is before notBefore"); |
| 595 DEFINE_CERT_ERROR_TYPE(kSignatureAlgorithmsDifferentEncoding, | 594 DEFINE_CERT_ERROR_TYPE(kSignatureAlgorithmsDifferentEncoding, |
| 596 "Certificate.signatureAlgorithm is encoded differently " | 595 "Certificate.signatureAlgorithm is encoded differently " |
| 597 "than TBSCertificate.signature"); | 596 "than TBSCertificate.signature"); |
| 598 DEFINE_CERT_ERROR_TYPE(kNullTrustAnchor, "Missing trust anchor"); | 597 DEFINE_CERT_ERROR_TYPE(kNullTrustAnchor, "Missing trust anchor"); |
| 599 | 598 |
| 600 } // verify_certificate_chain_errors | 599 } // verify_certificate_chain_errors |
| 601 | 600 |
| 602 } // namespace net | 601 } // namespace net |
| OLD | NEW |