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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 Result(); | 89 Result(); |
90 ~Result(); | 90 ~Result(); |
91 | 91 |
92 // Returns true if there was a valid path. | 92 // Returns true if there was a valid path. |
93 bool HasValidPath() const; | 93 bool HasValidPath() const; |
94 | 94 |
95 // Returns the ResultPath for the best valid path, or nullptr if there | 95 // Returns the ResultPath for the best valid path, or nullptr if there |
96 // was none. | 96 // was none. |
97 const ResultPath* GetBestValidPath() const; | 97 const ResultPath* GetBestValidPath() const; |
98 | 98 |
| 99 // Resets to the initial value. |
| 100 void Clear(); |
| 101 |
99 // List of paths that were attempted and the result for each. | 102 // List of paths that were attempted and the result for each. |
100 std::vector<std::unique_ptr<ResultPath>> paths; | 103 std::vector<std::unique_ptr<ResultPath>> paths; |
101 | 104 |
102 // Index into |paths|. Before use, |paths.empty()| must be checked. | 105 // Index into |paths|. Before use, |paths.empty()| must be checked. |
103 // NOTE: currently the definition of "best" is fairly limited. Valid is | 106 // NOTE: currently the definition of "best" is fairly limited. Valid is |
104 // better than invalid, but otherwise nothing is guaranteed. | 107 // better than invalid, but otherwise nothing is guaranteed. |
105 size_t best_result_index = 0; | 108 size_t best_result_index = 0; |
106 | 109 |
107 private: | 110 private: |
108 DISALLOW_COPY_AND_ASSIGN(Result); | 111 DISALLOW_COPY_AND_ASSIGN(Result); |
109 }; | 112 }; |
110 | 113 |
111 // TODO(mattm): allow caller specified hook/callback to extend path | 114 // TODO(mattm): allow caller specified hook/callback to extend path |
112 // verification. | 115 // verification. |
113 // | 116 // |
114 // TODO(eroman): The assumption is that |result| is default initialized. Can | |
115 // probably just internalize |result| into CertPathBuilder. | |
116 // | |
117 // 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 |
118 // trust anchor in |trust_store|, which satisfies |signature_policy| and is | 118 // trust anchor in |trust_store|, which satisfies |signature_policy| and is |
119 // 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|. |
120 // | 120 // |
121 // The caller must keep |trust_store|, |signature_policy|, and |*result| valid | 121 // The caller must keep |trust_store|, |signature_policy|, and |*result| valid |
122 // for the lifetime of the CertPathBuilder. | 122 // for the lifetime of the CertPathBuilder. |
123 CertPathBuilder(scoped_refptr<ParsedCertificate> cert, | 123 CertPathBuilder(scoped_refptr<ParsedCertificate> cert, |
124 TrustStore* trust_store, | 124 TrustStore* trust_store, |
125 const SignaturePolicy* signature_policy, | 125 const SignaturePolicy* signature_policy, |
126 const der::GeneralizedTime& time, | 126 const der::GeneralizedTime& time, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 State next_state_; | 171 State next_state_; |
172 | 172 |
173 Result* out_result_; | 173 Result* out_result_; |
174 | 174 |
175 DISALLOW_COPY_AND_ASSIGN(CertPathBuilder); | 175 DISALLOW_COPY_AND_ASSIGN(CertPathBuilder); |
176 }; | 176 }; |
177 | 177 |
178 } // namespace net | 178 } // namespace net |
179 | 179 |
180 #endif // NET_CERT_INTERNAL_PATH_BUILDER_H_ | 180 #endif // NET_CERT_INTERNAL_PATH_BUILDER_H_ |
OLD | NEW |