OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_PATH_BUILDER_H_ | 5 #ifndef NET_CERT_INTERNAL_PATH_BUILDER_H_ |
6 #define NET_CERT_INTERNAL_PATH_BUILDER_H_ | 6 #define NET_CERT_INTERNAL_PATH_BUILDER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 class CertPathIter; | 26 class CertPathIter; |
27 class CertIssuerSource; | 27 class CertIssuerSource; |
28 class SignaturePolicy; | 28 class SignaturePolicy; |
29 | 29 |
30 // CertPath describes a chain of certificates in the "forward" direction. | 30 // CertPath describes a chain of certificates in the "forward" direction. |
31 // | 31 // |
32 // By convention: | 32 // By convention: |
33 // certs[0] is the target certificate | 33 // certs[0] is the target certificate |
34 // certs[i] was issued by certs[i+1] | 34 // certs[i] was issued by certs[i+1] |
35 // certs.back() was issued by trust_anchor | 35 // certs.back() is the root certificate. |
36 // | 36 // |
37 // TODO(eroman): The current code doesn't allow for the target certificate to | 37 // Note that the final certificate may or may not be a trust achor -- inspect |
38 // be the trust anchor. Should it? | 38 // |last_cert_trust| to determine it (or use GetTrustedCert()) |
39 struct NET_EXPORT CertPath { | 39 struct NET_EXPORT CertPath { |
40 CertPath(); | 40 CertPath(); |
41 ~CertPath(); | 41 ~CertPath(); |
42 | 42 |
43 scoped_refptr<TrustAnchor> trust_anchor; | 43 // Contains information on whether certs.back() is trusted. |
| 44 CertificateTrust last_cert_trust; |
44 | 45 |
45 // Path in the forward direction (path[0] is the target cert). | 46 // Path in the forward direction (see class description). |
46 ParsedCertificateList certs; | 47 ParsedCertificateList certs; |
47 | 48 |
48 // Resets the path to empty path (same as if default constructed). | 49 // Resets the path to empty path (same as if default constructed). |
49 void Clear(); | 50 void Clear(); |
50 | 51 |
51 // TODO(eroman): Can we remove this? Unclear on how this relates to validity. | 52 // TODO(eroman): Can we remove this? Unclear on how this relates to validity. |
52 bool IsEmpty() const; | 53 bool IsEmpty() const; |
| 54 |
| 55 // Returns the chain's root certificate or nullptr if the chain doesn't chain |
| 56 // to a trust anchor. |
| 57 const ParsedCertificate* GetTrustedCert() const; |
53 }; | 58 }; |
54 | 59 |
55 // Checks whether a certificate is trusted by building candidate paths to trust | 60 // Checks whether a certificate is trusted by building candidate paths to trust |
56 // anchors and verifying those paths according to RFC 5280. Each instance of | 61 // anchors and verifying those paths according to RFC 5280. Each instance of |
57 // CertPathBuilder is used for a single verification. | 62 // CertPathBuilder is used for a single verification. |
58 // | 63 // |
59 // WARNING: This implementation is currently experimental. Consult an OWNER | 64 // WARNING: This implementation is currently experimental. Consult an OWNER |
60 // before using it. | 65 // before using it. |
61 class NET_EXPORT CertPathBuilder { | 66 class NET_EXPORT CertPathBuilder { |
62 public: | 67 public: |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // TODO(eroman): The assumption is that |result| is default initialized. Can | 114 // TODO(eroman): The assumption is that |result| is default initialized. Can |
110 // probably just internalize |result| into CertPathBuilder. | 115 // probably just internalize |result| into CertPathBuilder. |
111 // | 116 // |
112 // Creates a CertPathBuilder that attempts to find a path from |cert| to a | 117 // Creates a CertPathBuilder that attempts to find a path from |cert| to a |
113 // trust anchor in |trust_store|, which satisfies |signature_policy| and is | 118 // trust anchor in |trust_store|, which satisfies |signature_policy| and is |
114 // valid at |time|. Details of attempted path(s) are stored in |*result|. | 119 // valid at |time|. Details of attempted path(s) are stored in |*result|. |
115 // | 120 // |
116 // The caller must keep |trust_store|, |signature_policy|, and |*result| valid | 121 // The caller must keep |trust_store|, |signature_policy|, and |*result| valid |
117 // for the lifetime of the CertPathBuilder. | 122 // for the lifetime of the CertPathBuilder. |
118 CertPathBuilder(scoped_refptr<ParsedCertificate> cert, | 123 CertPathBuilder(scoped_refptr<ParsedCertificate> cert, |
119 const TrustStore* trust_store, | 124 TrustStore* trust_store, |
120 const SignaturePolicy* signature_policy, | 125 const SignaturePolicy* signature_policy, |
121 const der::GeneralizedTime& time, | 126 const der::GeneralizedTime& time, |
122 KeyPurpose key_purpose, | 127 KeyPurpose key_purpose, |
123 Result* result); | 128 Result* result); |
124 ~CertPathBuilder(); | 129 ~CertPathBuilder(); |
125 | 130 |
126 // Adds a CertIssuerSource to provide intermediates for use in path building. | 131 // Adds a CertIssuerSource to provide intermediates for use in path building. |
127 // Multiple sources may be added. Must not be called after Run is called. | 132 // Multiple sources may be added. Must not be called after Run is called. |
128 // The |*cert_issuer_source| must remain valid for the lifetime of the | 133 // The |*cert_issuer_source| must remain valid for the lifetime of the |
129 // CertPathBuilder. | 134 // CertPathBuilder. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 State next_state_; | 171 State next_state_; |
167 | 172 |
168 Result* out_result_; | 173 Result* out_result_; |
169 | 174 |
170 DISALLOW_COPY_AND_ASSIGN(CertPathBuilder); | 175 DISALLOW_COPY_AND_ASSIGN(CertPathBuilder); |
171 }; | 176 }; |
172 | 177 |
173 } // namespace net | 178 } // namespace net |
174 | 179 |
175 #endif // NET_CERT_INTERNAL_PATH_BUILDER_H_ | 180 #endif // NET_CERT_INTERNAL_PATH_BUILDER_H_ |
OLD | NEW |