| 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_HTTP_HTTP_SECURITY_HEADERS_H_ | 5 #ifndef NET_HTTP_HTTP_SECURITY_HEADERS_H_ |
| 6 #define NET_HTTP_HTTP_SECURITY_HEADERS_H_ | 6 #define NET_HTTP_HTTP_SECURITY_HEADERS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "net/base/hash_value.h" | 14 #include "net/base/hash_value.h" |
| 15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
| 16 | 16 |
| 17 class GURL; |
| 18 |
| 17 namespace net { | 19 namespace net { |
| 18 | 20 |
| 19 const int64 kMaxHSTSAgeSecs = 86400 * 365; // 1 year | 21 const int64 kMaxHSTSAgeSecs = 86400 * 365; // 1 year |
| 20 | 22 |
| 21 // Parses |value| as a Strict-Transport-Security header value. If successful, | 23 // Parses |value| as a Strict-Transport-Security header value. If successful, |
| 22 // returns true and sets |*max_age| and |*include_subdomains|. | 24 // returns true and sets |*max_age| and |*include_subdomains|. |
| 23 // Otherwise returns false and leaves the output parameters unchanged. | 25 // Otherwise returns false and leaves the output parameters unchanged. |
| 24 // | 26 // |
| 25 // value is the right-hand side of: | 27 // value is the right-hand side of: |
| 26 // | 28 // |
| 27 // "Strict-Transport-Security" ":" | 29 // "Strict-Transport-Security" ":" |
| 28 // [ directive ] *( ";" [ directive ] ) | 30 // [ directive ] *( ";" [ directive ] ) |
| 29 bool NET_EXPORT_PRIVATE ParseHSTSHeader(const std::string& value, | 31 bool NET_EXPORT_PRIVATE ParseHSTSHeader(const std::string& value, |
| 30 base::TimeDelta* max_age, | 32 base::TimeDelta* max_age, |
| 31 bool* include_subdomains); | 33 bool* include_subdomains); |
| 32 | 34 |
| 33 // Parses |value| as a Public-Key-Pins header value. If successful, returns | 35 // Parses |value| as a Public-Key-Pins header value. If successful, returns |
| 34 // true and populates the |*max_age|, |*include_subdomains|, and |*hashes| | 36 // true and populates the |*max_age|, |*include_subdomains|, and |*hashes| |
| 35 // values. Otherwise returns false and leaves the output parameters | 37 // values. Otherwise returns false and leaves the output parameters |
| 36 // unchanged. | 38 // unchanged. |
| 37 // | 39 // |
| 38 // value is the right-hand side of: | 40 // value is the right-hand side of: |
| 39 // | 41 // |
| 40 // "Public-Key-Pins" ":" | 42 // "Public-Key-Pins" ":" |
| 41 // "max-age" "=" delta-seconds ";" | 43 // "max-age" "=" delta-seconds ";" |
| 42 // "pin-" algo "=" base64 [ ";" ... ] | 44 // "pin-" algo "=" base64 [ ";" ... ] |
| 43 // [ ";" "includeSubdomains" ] | 45 // [ ";" "includeSubdomains" ] |
| 46 // [ ";" "report-uri" "=" uri-reference ] |
| 44 // | 47 // |
| 45 // For this function to return true, the key hashes specified by the HPKP | 48 // For this function to return true, the key hashes specified by the HPKP |
| 46 // header must pass two additional checks. There MUST be at least one key | 49 // header must pass two additional checks. There MUST be at least one key |
| 47 // hash which matches the SSL certificate chain of the current site (as | 50 // hash which matches the SSL certificate chain of the current site (as |
| 48 // specified by the chain_hashes) parameter. In addition, there MUST be at | 51 // specified by the chain_hashes) parameter. In addition, there MUST be at |
| 49 // least one key hash which does NOT match the site's SSL certificate chain | 52 // least one key hash which does NOT match the site's SSL certificate chain |
| 50 // (this is the "backup pin"). | 53 // (this is the "backup pin"). |
| 51 bool NET_EXPORT_PRIVATE ParseHPKPHeader(const std::string& value, | 54 bool NET_EXPORT_PRIVATE ParseHPKPHeader(const std::string& value, |
| 52 const HashValueVector& chain_hashes, | 55 const HashValueVector& chain_hashes, |
| 53 base::TimeDelta* max_age, | 56 base::TimeDelta* max_age, |
| 54 bool* include_subdomains, | 57 bool* include_subdomains, |
| 55 HashValueVector* hashes); | 58 HashValueVector* hashes, |
| 59 GURL* report_uri); |
| 56 | 60 |
| 57 } // namespace net | 61 } // namespace net |
| 58 | 62 |
| 59 #endif // NET_HTTP_HTTP_SECURITY_HEADERS_H_ | 63 #endif // NET_HTTP_HTTP_SECURITY_HEADERS_H_ |
| OLD | NEW |