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 #ifndef NET_BASE_TRANSPORT_SECURITY_STATE_H_ | 5 #ifndef NET_BASE_TRANSPORT_SECURITY_STATE_H_ |
6 #define NET_BASE_TRANSPORT_SECURITY_STATE_H_ | 6 #define NET_BASE_TRANSPORT_SECURITY_STATE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // any one of which is sufficient to validate the certificate chain in | 84 // any one of which is sufficient to validate the certificate chain in |
85 // question. The public keys could be of a root CA, intermediate CA, or | 85 // question. The public keys could be of a root CA, intermediate CA, or |
86 // leaf certificate, depending on the security vs. disaster recovery | 86 // leaf certificate, depending on the security vs. disaster recovery |
87 // tradeoff selected. (Pinning only to leaf certifiates increases | 87 // tradeoff selected. (Pinning only to leaf certifiates increases |
88 // security because you no longer trust any CAs, but it hampers disaster | 88 // security because you no longer trust any CAs, but it hampers disaster |
89 // recovery because you can't just get a new certificate signed by the | 89 // recovery because you can't just get a new certificate signed by the |
90 // CA.) | 90 // CA.) |
91 // | 91 // |
92 // |bad_static_spki_hashes| contains public keys that we don't want to | 92 // |bad_static_spki_hashes| contains public keys that we don't want to |
93 // trust. | 93 // trust. |
94 bool IsChainOfPublicKeysPermitted(const FingerprintVector& hashes) const; | 94 bool IsChainOfPublicKeysPermitted( |
| 95 const std::vector<HashValueVector>& hashes) const; |
95 | 96 |
96 // Returns true if any of the FingerprintVectors |static_spki_hashes|, | 97 // Returns true if any of the HashValueVectors |static_spki_hashes|, |
97 // |bad_static_spki_hashes|, or |dynamic_spki_hashes| contains any | 98 // |bad_static_spki_hashes|, or |dynamic_spki_hashes| contains any |
98 // items. | 99 // items. |
99 bool HasPins() const; | 100 bool HasPins() const; |
100 | 101 |
101 // ShouldRedirectHTTPToHTTPS returns true iff, given the |mode| of this | 102 // ShouldRedirectHTTPToHTTPS returns true iff, given the |mode| of this |
102 // DomainState, HTTP requests should be internally redirected to HTTPS. | 103 // DomainState, HTTP requests should be internally redirected to HTTPS. |
103 bool ShouldRedirectHTTPToHTTPS() const; | 104 bool ShouldRedirectHTTPToHTTPS() const; |
104 | 105 |
105 bool Equals(const DomainState& other) const; | 106 bool Equals(const DomainState& other) const; |
106 | 107 |
(...skipping 17 matching lines...) Expand all Loading... |
124 bool include_subdomains; | 125 bool include_subdomains; |
125 | 126 |
126 // Optional; hashes of static pinned SubjectPublicKeyInfos. Unless both | 127 // Optional; hashes of static pinned SubjectPublicKeyInfos. Unless both |
127 // are empty, at least one of |static_spki_hashes| and | 128 // are empty, at least one of |static_spki_hashes| and |
128 // |dynamic_spki_hashes| MUST intersect with the set of SPKIs in the TLS | 129 // |dynamic_spki_hashes| MUST intersect with the set of SPKIs in the TLS |
129 // server's certificate chain. | 130 // server's certificate chain. |
130 // | 131 // |
131 // |dynamic_spki_hashes| take precedence over |static_spki_hashes|. | 132 // |dynamic_spki_hashes| take precedence over |static_spki_hashes|. |
132 // That is, |IsChainOfPublicKeysPermitted| first checks dynamic pins and | 133 // That is, |IsChainOfPublicKeysPermitted| first checks dynamic pins and |
133 // then checks static pins. | 134 // then checks static pins. |
134 FingerprintVector static_spki_hashes; | 135 HashValueVector static_spki_hashes; |
135 | 136 |
136 // Optional; hashes of dynamically pinned SubjectPublicKeyInfos. | 137 // Optional; hashes of dynamically pinned SubjectPublicKeyInfos. |
137 FingerprintVector dynamic_spki_hashes; | 138 HashValueVector dynamic_spki_hashes; |
138 | 139 |
139 // The absolute time (UTC) when the |dynamic_spki_hashes| expire. | 140 // The absolute time (UTC) when the |dynamic_spki_hashes| expire. |
140 base::Time dynamic_spki_hashes_expiry; | 141 base::Time dynamic_spki_hashes_expiry; |
141 | 142 |
142 // Optional; hashes of static known-bad SubjectPublicKeyInfos which | 143 // Optional; hashes of static known-bad SubjectPublicKeyInfos which |
143 // MUST NOT intersect with the set of SPKIs in the TLS server's | 144 // MUST NOT intersect with the set of SPKIs in the TLS server's |
144 // certificate chain. | 145 // certificate chain. |
145 FingerprintVector bad_static_spki_hashes; | 146 HashValueVector bad_static_spki_hashes; |
146 | 147 |
147 // The following members are not valid when stored in |enabled_hosts_|: | 148 // The following members are not valid when stored in |enabled_hosts_|: |
148 | 149 |
149 // The domain which matched during a search for this DomainState entry. | 150 // The domain which matched during a search for this DomainState entry. |
150 // Updated by |GetDomainState| and |GetStaticDomainState|. | 151 // Updated by |GetDomainState| and |GetStaticDomainState|. |
151 std::string domain; | 152 std::string domain; |
152 }; | 153 }; |
153 | 154 |
154 class Iterator { | 155 class Iterator { |
155 public: | 156 public: |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // SNI-using hosts as well as the rest of the pins. | 249 // SNI-using hosts as well as the rest of the pins. |
249 // | 250 // |
250 // If |host| matches both an exact entry and is a subdomain of another | 251 // If |host| matches both an exact entry and is a subdomain of another |
251 // entry, the exact match determines the return value. | 252 // entry, the exact match determines the return value. |
252 static bool IsGooglePinnedProperty(const std::string& host, | 253 static bool IsGooglePinnedProperty(const std::string& host, |
253 bool sni_enabled); | 254 bool sni_enabled); |
254 | 255 |
255 // Decodes a pin string |value| (e.g. "sha1/hvfkN/qlp/zhXR3cuerq6jd2Z7g="). | 256 // Decodes a pin string |value| (e.g. "sha1/hvfkN/qlp/zhXR3cuerq6jd2Z7g="). |
256 // If parsing succeeded, updates |*out| and returns true; otherwise returns | 257 // If parsing succeeded, updates |*out| and returns true; otherwise returns |
257 // false without updating |*out|. | 258 // false without updating |*out|. |
258 static bool ParsePin(const std::string& value, Fingerprint* out); | 259 static bool ParsePin(const std::string& value, HashValue* out); |
259 | 260 |
260 // The maximum number of seconds for which we'll cache an HSTS request. | 261 // The maximum number of seconds for which we'll cache an HSTS request. |
261 static const long int kMaxHSTSAgeSecs; | 262 static const long int kMaxHSTSAgeSecs; |
262 | 263 |
263 // Converts |hostname| from dotted form ("www.google.com") to the form | 264 // Converts |hostname| from dotted form ("www.google.com") to the form |
264 // used in DNS: "\x03www\x06google\x03com", lowercases that, and returns | 265 // used in DNS: "\x03www\x06google\x03com", lowercases that, and returns |
265 // the result. | 266 // the result. |
266 static std::string CanonicalizeHost(const std::string& hostname); | 267 static std::string CanonicalizeHost(const std::string& hostname); |
267 | 268 |
268 // Send an UMA report on pin validation failure, if the host is in a | 269 // Send an UMA report on pin validation failure, if the host is in a |
(...skipping 19 matching lines...) Expand all Loading... |
288 std::map<std::string, DomainState> forced_hosts_; | 289 std::map<std::string, DomainState> forced_hosts_; |
289 | 290 |
290 Delegate* delegate_; | 291 Delegate* delegate_; |
291 | 292 |
292 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState); | 293 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState); |
293 }; | 294 }; |
294 | 295 |
295 } // namespace net | 296 } // namespace net |
296 | 297 |
297 #endif // NET_BASE_TRANSPORT_SECURITY_STATE_H_ | 298 #endif // NET_BASE_TRANSPORT_SECURITY_STATE_H_ |
OLD | NEW |