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