blob: 34f37b9f9213bc51ba69d5fd707878d694b06e5d [file] [log] [blame]
[email protected]6ed72be2013-01-08 22:07:331// 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
3// found in the LICENSE file.
4
5#ifndef NET_HTTP_HTTP_SECURITY_HEADERS_H_
6#define NET_HTTP_HTTP_SECURITY_HEADERS_H_
7
avic0279142015-12-04 22:38:528#include <stdint.h>
9
[email protected]6ed72be2013-01-08 22:07:3310#include <string>
11
[email protected]66e96c42013-06-28 15:20:3112#include "base/time/time.h"
[email protected]6ed72be2013-01-08 22:07:3313#include "base/values.h"
14#include "net/base/hash_value.h"
15#include "net/base/net_export.h"
16
estark83487b62015-07-27 17:11:1417class GURL;
18
[email protected]6ed72be2013-01-08 22:07:3319namespace net {
20
eromane8a43d82016-04-12 06:02:0621const uint32_t kMaxHSTSAgeSecs = 86400 * 365; // 1 year
[email protected]6ed72be2013-01-08 22:07:3322
elawrencea6c42bd2016-02-29 18:00:4223// RFC7469 suggests that 60 days is a reasonable maximum max-age value
24// http://tools.ietf.org/html/rfc7469#section-4.1
eromane8a43d82016-04-12 06:02:0625const uint32_t kMaxHPKPAgeSecs = 86400 * 60; // 60 days
elawrencea6c42bd2016-02-29 18:00:4226
[email protected]6ed72be2013-01-08 22:07:3327// Parses |value| as a Strict-Transport-Security header value. If successful,
[email protected]b4e1f7e2013-05-25 13:59:0928// returns true and sets |*max_age| and |*include_subdomains|.
[email protected]6ed72be2013-01-08 22:07:3329// Otherwise returns false and leaves the output parameters unchanged.
[email protected]6ed72be2013-01-08 22:07:3330//
31// value is the right-hand side of:
32//
33// "Strict-Transport-Security" ":"
34// [ directive ] *( ";" [ directive ] )
[email protected]b4e1f7e2013-05-25 13:59:0935bool NET_EXPORT_PRIVATE ParseHSTSHeader(const std::string& value,
36 base::TimeDelta* max_age,
[email protected]6ed72be2013-01-08 22:07:3337 bool* include_subdomains);
38
[email protected]37fd55fb2013-06-29 13:13:2739// Parses |value| as a Public-Key-Pins header value. If successful, returns
estark640590d42015-07-31 23:56:2440// true and populates the |*max_age|, |*include_subdomains|, |*hashes|, and
41// |*report_uri| values. Otherwise returns false and leaves the output
42// parameters unchanged.
[email protected]6ed72be2013-01-08 22:07:3343//
44// value is the right-hand side of:
45//
46// "Public-Key-Pins" ":"
47// "max-age" "=" delta-seconds ";"
48// "pin-" algo "=" base64 [ ";" ... ]
[email protected]37fd55fb2013-06-29 13:13:2749// [ ";" "includeSubdomains" ]
estark83487b62015-07-27 17:11:1450// [ ";" "report-uri" "=" uri-reference ]
[email protected]6ed72be2013-01-08 22:07:3351//
52// For this function to return true, the key hashes specified by the HPKP
[email protected]37fd55fb2013-06-29 13:13:2753// header must pass two additional checks. There MUST be at least one key
54// hash which matches the SSL certificate chain of the current site (as
55// specified by the chain_hashes) parameter. In addition, there MUST be at
56// least one key hash which does NOT match the site's SSL certificate chain
57// (this is the "backup pin").
[email protected]b4e1f7e2013-05-25 13:59:0958bool NET_EXPORT_PRIVATE ParseHPKPHeader(const std::string& value,
[email protected]6ed72be2013-01-08 22:07:3359 const HashValueVector& chain_hashes,
[email protected]b4e1f7e2013-05-25 13:59:0960 base::TimeDelta* max_age,
[email protected]37fd55fb2013-06-29 13:13:2761 bool* include_subdomains,
estark83487b62015-07-27 17:11:1462 HashValueVector* hashes,
63 GURL* report_uri);
[email protected]6ed72be2013-01-08 22:07:3364
estark640590d42015-07-31 23:56:2465// Parses |value| as a Public-Key-Pins-Report-Only header value. If
66// successful, returns true and populates the |*include_subdomains|,
67// |*hashes|, and |*report_uri| values. Otherwise returns false and
68// leaves the output parameters unchanged.
69//
70// value is the right-hand side of:
71//
72// "Public-Key-Pins-Report-Only" ":"
73// [ "max-age" "=" delta-seconds ";" ]
74// "pin-" algo "=" base64 [ ";" ... ]
75// [ ";" "includeSubdomains" ]
76// [ ";" "report-uri" "=" uri-reference ]
77//
78bool NET_EXPORT_PRIVATE ParseHPKPReportOnlyHeader(const std::string& value,
79 bool* include_subdomains,
80 HashValueVector* hashes,
81 GURL* report_uri);
[email protected]6ed72be2013-01-08 22:07:3382} // namespace net
83
84#endif // NET_HTTP_HTTP_SECURITY_HEADERS_H_