OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef NET_CERT_CERT_POLICY_ENFORCER_H | 4 #ifndef NET_CERT_CERT_POLICY_ENFORCER_H |
5 #define NET_CERT_CERT_POLICY_ENFORCER_H | 5 #define NET_CERT_CERT_POLICY_ENFORCER_H |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "net/base/net_export.h" | 9 #include "net/base/net_export.h" |
10 #include "net/base/net_log.h" | |
10 | 11 |
11 namespace net { | 12 namespace net { |
12 | 13 |
13 namespace ct { | 14 namespace ct { |
14 | 15 |
15 struct CTVerifyResult; | 16 struct CTVerifyResult; |
16 class EVCertsWhitelist; | 17 class EVCertsWhitelist; |
17 | 18 |
18 } // namespace ct | 19 } // namespace ct |
19 | 20 |
20 class X509Certificate; | 21 class X509Certificate; |
21 | 22 |
23 namespace { | |
24 | |
25 struct PolicyComplianceResult; | |
26 | |
27 } // namespace | |
Ryan Sleevi
2014/12/10 20:09:26
This is a .h file. You can't use unnamed namespace
Eran Messeri
2014/12/12 12:44:56
Done.
| |
28 | |
22 // Class for checking that a given certificate conforms to security-related | 29 // Class for checking that a given certificate conforms to security-related |
23 // policies. | 30 // policies. |
24 class NET_EXPORT CertPolicyEnforcer { | 31 class NET_EXPORT CertPolicyEnforcer { |
25 public: | 32 public: |
26 // Set the parameters for this policy enforcer: | 33 // Set the parameters for this policy enforcer: |
27 // |num_ct_logs| is the number of Certificate Transparency log currently | 34 // |num_ct_logs| is the number of Certificate Transparency log currently |
28 // known to Chrome. | 35 // known to Chrome. |
29 // |require_ct_for_ev| indicates whether Certificate Transparency presence | 36 // |require_ct_for_ev| indicates whether Certificate Transparency presence |
30 // is required for EV certificates. | 37 // is required for EV certificates. |
31 CertPolicyEnforcer(size_t num_ct_logs, bool require_ct_for_ev); | 38 CertPolicyEnforcer(size_t num_ct_logs, bool require_ct_for_ev); |
32 virtual ~CertPolicyEnforcer(); | 39 virtual ~CertPolicyEnforcer(); |
33 | 40 |
34 // Returns true if the collection of SCTs for the given certificate | 41 // Returns true if the collection of SCTs for the given certificate |
35 // conforms with the CT/EV policy. | 42 // conforms with the CT/EV policy. If it is non-conforming, the certificate |
43 // is logged to |net_log|. | |
36 // |cert| is the certificate for which the SCTs apply. | 44 // |cert| is the certificate for which the SCTs apply. |
37 // |ct_result| must contain the result of verifying any SCTs associated with | 45 // |ct_result| must contain the result of verifying any SCTs associated with |
38 // |cert| prior to invoking this method. | 46 // |cert| prior to invoking this method. |
39 bool DoesConformToCTEVPolicy(X509Certificate* cert, | 47 bool DoesConformToCTEVPolicy(X509Certificate* cert, |
40 const ct::EVCertsWhitelist* ev_whitelist, | 48 const ct::EVCertsWhitelist* ev_whitelist, |
41 const ct::CTVerifyResult& ct_result); | 49 const ct::CTVerifyResult& ct_result, |
50 const BoundNetLog& net_log); | |
42 | 51 |
43 private: | 52 private: |
44 bool IsCertificateInWhitelist(X509Certificate* cert, | 53 bool IsCertificateInWhitelist(X509Certificate* cert, |
45 const ct::EVCertsWhitelist* ev_whitelist); | 54 const ct::EVCertsWhitelist* ev_whitelist); |
46 | 55 |
47 bool HasRequiredNumberOfSCTs(X509Certificate* cert, | 56 bool HasRequiredNumberOfSCTs(X509Certificate* cert, |
48 const ct::CTVerifyResult& ct_result); | 57 const ct::CTVerifyResult& ct_result); |
49 | 58 |
59 void CheckCTEVPolicyCompliance(X509Certificate* cert, | |
60 const ct::EVCertsWhitelist* ev_whitelist, | |
61 const ct::CTVerifyResult& ct_result, | |
62 PolicyComplianceResult* result); | |
63 | |
50 size_t num_ct_logs_; | 64 size_t num_ct_logs_; |
51 bool require_ct_for_ev_; | 65 bool require_ct_for_ev_; |
52 }; | 66 }; |
53 | 67 |
54 } // namespace net | 68 } // namespace net |
55 | 69 |
56 #endif // NET_CERT_CERT_POLICY_ENFORCER_H | 70 #endif // NET_CERT_CERT_POLICY_ENFORCER_H |
OLD | NEW |