| 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_CT_POLICY_ENFORCER_H | 4 #ifndef NET_CERT_CT_POLICY_ENFORCER_H |
| 5 #define NET_CERT_CT_POLICY_ENFORCER_H | 5 #define NET_CERT_CT_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/cert/signed_certificate_timestamp.h" |
| 10 #include "net/log/net_log.h" | 11 #include "net/log/net_log.h" |
| 11 | 12 |
| 12 namespace net { | 13 namespace net { |
| 13 | 14 |
| 14 namespace ct { | 15 namespace ct { |
| 15 | 16 |
| 16 struct CTVerifyResult; | |
| 17 class EVCertsWhitelist; | 17 class EVCertsWhitelist; |
| 18 | 18 |
| 19 } // namespace ct | 19 } // namespace ct |
| 20 | 20 |
| 21 class X509Certificate; | 21 class X509Certificate; |
| 22 | 22 |
| 23 using SCTList = std::vector<scoped_refptr<ct::SignedCertificateTimestamp>>; |
| 24 |
| 23 // Class for checking that a given certificate conforms to security-related | 25 // Class for checking that a given certificate conforms to security-related |
| 24 // policies. | 26 // policies. |
| 25 class NET_EXPORT CTPolicyEnforcer { | 27 class NET_EXPORT CTPolicyEnforcer { |
| 26 public: | 28 public: |
| 29 // Information about the connection's compliance with the EV |
| 30 // certificate policy. |
| 31 enum EVPolicyCompliance { |
| 32 // The certificate was not EV, so the EV policy doesn't apply. |
| 33 EV_POLICY_DOES_NOT_APPLY = 0, |
| 34 // The connection complied with the EV certificate policy by being |
| 35 // included on the EV whitelist. |
| 36 EV_POLICY_COMPLIES_VIA_WHITELIST, |
| 37 // The connection complied with the EV certificate policy by |
| 38 // including SCTs that satisfy the policy. |
| 39 EV_POLICY_COMPLIES_VIA_SCTS, |
| 40 // The connection did not have enough SCTs to retain its EV |
| 41 // status. |
| 42 EV_POLICY_NOT_ENOUGH_SCTS, |
| 43 // The connection did not have diverse enough SCTs to retain its |
| 44 // EV status. |
| 45 EV_POLICY_NOT_DIVERSE_SCTS, |
| 46 // The connection cannot be considered compliant because the build |
| 47 // isn't timely and therefore log information might be out of date |
| 48 // (for example a log might no longer be considered trustworthy). |
| 49 EV_POLICY_BUILD_NOT_TIMELY, |
| 50 }; |
| 51 |
| 27 CTPolicyEnforcer() {} | 52 CTPolicyEnforcer() {} |
| 28 virtual ~CTPolicyEnforcer() {} | 53 virtual ~CTPolicyEnforcer() {} |
| 29 | 54 |
| 30 // Returns true if the collection of SCTs for the given certificate | 55 // Returns an enum indicating if the collection of SCTs for the given |
| 31 // conforms with the CT/EV policy. Conformance details are logged to | 56 // certificate conforms with the CT/EV policy. Conformance details are logged |
| 32 // |net_log|. | 57 // to |net_log|. |
| 33 // |cert| is the certificate for which the SCTs apply. | 58 // |cert| is the certificate for which the SCTs apply. |
| 34 // |ct_result| must contain the result of verifying any SCTs associated with | 59 // |verified_scts| contains any SCTs associated with |cert| that were |
| 35 // |cert| prior to invoking this method. | 60 // verified prior to invoking this method and found to be valid. |
| 36 virtual bool DoesConformToCTEVPolicy(X509Certificate* cert, | 61 virtual EVPolicyCompliance DoesConformToCTEVPolicy( |
| 37 const ct::EVCertsWhitelist* ev_whitelist, | 62 X509Certificate* cert, |
| 38 const ct::CTVerifyResult& ct_result, | 63 const ct::EVCertsWhitelist* ev_whitelist, |
| 39 const BoundNetLog& net_log); | 64 const SCTList& verified_scts, |
| 65 const BoundNetLog& net_log); |
| 40 }; | 66 }; |
| 41 | 67 |
| 42 } // namespace net | 68 } // namespace net |
| 43 | 69 |
| 44 #endif // NET_CERT_CT_POLICY_ENFORCER_H | 70 #endif // NET_CERT_CT_POLICY_ENFORCER_H |
| OLD | NEW |