File: ct_policy_enforcer.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (91 lines) | stat: -rw-r--r-- 2,999 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef NET_CERT_CT_POLICY_ENFORCER_H_
#define NET_CERT_CT_POLICY_ENFORCER_H_

#include <optional>
#include <string_view>

#include <stddef.h>

#include "base/memory/ref_counted.h"
#include "net/base/net_export.h"
#include "net/cert/signed_certificate_timestamp.h"

namespace net {

class NetLogWithSource;

namespace ct {
enum class CTPolicyCompliance;
}  // namespace ct

class X509Certificate;

// Interface for checking whether or not a given certificate conforms to any
// policies an application may have regarding Certificate Transparency.
//
// See //net/docs/certificate-transparency.md for more details regarding the
// usage of CT in //net and risks that may exist when defining a CT policy.
class NET_EXPORT CTPolicyEnforcer
    : public base::RefCountedThreadSafe<CTPolicyEnforcer> {
 public:
  // Returns the CT certificate policy compliance status for a given
  // certificate and collection of SCTs.
  // |cert| is the certificate for which to check compliance, and
  // ||verified_scts| contains any/all SCTs associated with |cert| that
  // |have been verified (well-formed, issued by known logs, and
  // |applying to |cert|).
  virtual ct::CTPolicyCompliance CheckCompliance(
      X509Certificate* cert,
      const ct::SCTList& verified_scts,
      base::Time current_time,
      const NetLogWithSource& net_log) const = 0;

  // Returns the timestamp that the log identified by |log_id| (the SHA-256
  // hash of the log's DER-encoded SPKI) has been disqualified, or nullopt if
  // the log has not been disqualified.
  // Any SCTs that are embedded in certificates issued after the
  // disqualification time should not be trusted, nor contribute to any
  // uniqueness or freshness
  virtual std::optional<base::Time> GetLogDisqualificationTime(
      std::string_view log_id) const = 0;

  // Returns true if Certificate Transparency enforcement is enabled.
  virtual bool IsCtEnabled() const = 0;

 protected:
  virtual ~CTPolicyEnforcer() = default;

 private:
  friend class base::RefCountedThreadSafe<CTPolicyEnforcer>;
};

// A default implementation of Certificate Transparency policies that is
// intended for use in applications without auto-update capabilities.
//
// See //net/docs/certificate-transparency.md for more details.
class NET_EXPORT DefaultCTPolicyEnforcer : public net::CTPolicyEnforcer {
 public:
  DefaultCTPolicyEnforcer() = default;

  ct::CTPolicyCompliance CheckCompliance(
      X509Certificate* cert,
      const ct::SCTList& verified_scts,
      base::Time current_time,
      const NetLogWithSource& net_log) const override;

  std::optional<base::Time> GetLogDisqualificationTime(
      std::string_view log_id) const override;

  bool IsCtEnabled() const override;

 protected:
  ~DefaultCTPolicyEnforcer() override = default;
};

}  // namespace net

#endif  // NET_CERT_CT_POLICY_ENFORCER_H_