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 #ifndef NET_CERT_INTERNAL_VERIFY_CERTIFICATE_CHAIN_H_ | 5 #ifndef NET_CERT_INTERNAL_VERIFY_CERTIFICATE_CHAIN_H_ |
6 #define NET_CERT_INTERNAL_VERIFY_CERTIFICATE_CHAIN_H_ | 6 #define NET_CERT_INTERNAL_VERIFY_CERTIFICATE_CHAIN_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 13 #include "net/cert/internal/cert_errors.h" |
13 #include "net/cert/internal/parsed_certificate.h" | 14 #include "net/cert/internal/parsed_certificate.h" |
14 #include "net/der/input.h" | 15 #include "net/der/input.h" |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 | 18 |
18 namespace der { | 19 namespace der { |
19 struct GeneralizedTime; | 20 struct GeneralizedTime; |
20 } | 21 } |
21 | 22 |
22 class SignaturePolicy; | 23 class SignaturePolicy; |
(...skipping 16 matching lines...) Expand all Loading... |
39 // | 40 // |
40 // cert_chain: | 41 // cert_chain: |
41 // A non-empty chain of N DER-encoded certificates, listed in the | 42 // A non-empty chain of N DER-encoded certificates, listed in the |
42 // "forward" direction. | 43 // "forward" direction. |
43 // | 44 // |
44 // * cert_chain[0] is the target certificate to verify. | 45 // * cert_chain[0] is the target certificate to verify. |
45 // * cert_chain[i+1] holds the certificate that issued cert_chain[i]. | 46 // * cert_chain[i+1] holds the certificate that issued cert_chain[i]. |
46 // * cert_chain[N-1] must be issued by the trust anchor. | 47 // * cert_chain[N-1] must be issued by the trust anchor. |
47 // | 48 // |
48 // trust_anchor: | 49 // trust_anchor: |
49 // Contains the trust anchor (root) used to verify the chain. | 50 // Contains the trust anchor (root) used to verify the chain. Must be |
| 51 // non-null. |
50 // | 52 // |
51 // signature_policy: | 53 // signature_policy: |
52 // The policy to use when verifying signatures (what hash algorithms are | 54 // The policy to use when verifying signatures (what hash algorithms are |
53 // allowed, what length keys, what named curves, etc). | 55 // allowed, what length keys, what named curves, etc). |
54 // | 56 // |
55 // time: | 57 // time: |
56 // The UTC time to use for expiration checks. | 58 // The UTC time to use for expiration checks. |
57 // | 59 // |
58 // --------- | 60 // --------- |
59 // Outputs | 61 // Outputs |
60 // --------- | 62 // --------- |
61 // | 63 // |
62 // Returns true if the target certificate can be verified. | 64 // Returns true if the target certificate can be verified. |
| 65 // |
| 66 // errors: |
| 67 // Must be non-null. The set of errors/warnings encountered while |
| 68 // validating the path are appended to this structure. There is no |
| 69 // guarantee that on success |errors| is empty, or conversely that |
| 70 // on failure |errors| is non-empty. Consumers must only use the |
| 71 // boolean return value to determine success/failure. |
63 NET_EXPORT bool VerifyCertificateChain(const ParsedCertificateList& certs, | 72 NET_EXPORT bool VerifyCertificateChain(const ParsedCertificateList& certs, |
64 const TrustAnchor* trust_anchor, | 73 const TrustAnchor* trust_anchor, |
65 const SignaturePolicy* signature_policy, | 74 const SignaturePolicy* signature_policy, |
66 const der::GeneralizedTime& time) | 75 const der::GeneralizedTime& time, |
67 WARN_UNUSED_RESULT; | 76 CertErrors* errors) WARN_UNUSED_RESULT; |
| 77 |
| 78 // ----------------------------------------------- |
| 79 // Errors/Warnings set by VerifyCertificateChain |
| 80 // ----------------------------------------------- |
| 81 |
| 82 namespace verify_certificate_chain_errors { |
| 83 |
| 84 // TODO(eroman): Document each of these and their parameters. |
| 85 extern CertErrorType kSignatureAlgorithmMismatch; |
| 86 extern CertErrorType kInvalidOrUnsupportedAlgorithm; |
| 87 extern CertErrorType kChainIsEmpty; |
| 88 extern CertErrorType kUnconsumedCriticalExtension; |
| 89 extern CertErrorType kTargetCertInconsistentCaBits; |
| 90 extern CertErrorType kKeyCertSignBitNotSet; |
| 91 extern CertErrorType kMaxPathLengthViolated; |
| 92 extern CertErrorType kBasicConstraintsIndicatesNotCa; |
| 93 extern CertErrorType kMissingBasicConstraints; |
| 94 extern CertErrorType kNotPermittedByNameConstraints; |
| 95 extern CertErrorType kSubjectDoesNotMatchIssuer; |
| 96 extern CertErrorType kSignatureVerificationFailed; |
| 97 extern CertErrorType kValidityFailedNotAfter; |
| 98 extern CertErrorType kValidityFailedNotBefore; |
| 99 extern CertErrorType kSignatureAlgorithmsDifferentEncoding; |
| 100 |
| 101 } // namespace verify_certificate_chain_errors |
68 | 102 |
69 } // namespace net | 103 } // namespace net |
70 | 104 |
71 #endif // NET_CERT_INTERNAL_VERIFY_CERTIFICATE_CHAIN_H_ | 105 #endif // NET_CERT_INTERNAL_VERIFY_CERTIFICATE_CHAIN_H_ |
OLD | NEW |