1 // Copyright 2013 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.
5 #ifndef NET_CERT_SIGNED_CERTIFICATE_TIMESTAMP_H_
6 #define NET_CERT_SIGNED_CERTIFICATE_TIMESTAMP_H_
11 #include "base/memory/ref_counted.h"
12 #include "base/time/time.h"
13 #include "net/base/hash_value.h"
14 #include "net/base/net_export.h"
21 // Structures related to Certificate Transparency (RFC6962).
24 // LogEntry struct in RFC 6962, Section 3.1
25 struct NET_EXPORT LogEntry
{
26 // LogEntryType enum in RFC 6962, Section 3.1
28 LOG_ENTRY_TYPE_X509
= 0,
29 LOG_ENTRY_TYPE_PRECERT
= 1
38 // Set if type == LOG_ENTRY_TYPE_X509
39 std::string leaf_certificate
;
41 // Set if type == LOG_ENTRY_TYPE_PRECERT
42 SHA256HashValue issuer_key_hash
;
43 std::string tbs_certificate
;
46 // Helper structure to represent Digitally Signed data, as described in
47 // Sections 4.7 and 7.4.1.4.1 of RFC 5246.
48 struct NET_EXPORT_PRIVATE DigitallySigned
{
59 enum SignatureAlgorithm
{
60 SIG_ALGO_ANONYMOUS
= 0,
69 HashAlgorithm hash_algorithm
;
70 SignatureAlgorithm signature_algorithm
;
72 std::string signature_data
;
75 // SignedCertificateTimestamp struct in RFC 6962, Section 3.2.
76 struct NET_EXPORT SignedCertificateTimestamp
77 : public base::RefCountedThreadSafe
<SignedCertificateTimestamp
> {
78 // Predicate functor used in maps when SignedCertificateTimestamp is used as
80 struct NET_EXPORT LessThan
{
81 bool operator()(const scoped_refptr
<SignedCertificateTimestamp
>& lhs
,
82 const scoped_refptr
<SignedCertificateTimestamp
>& rhs
) const;
85 // Version enum in RFC 6962, Section 3.2.
90 // Source of the SCT - supplementary, not defined in CT RFC.
91 // Note: The numeric values are used within histograms and should not change
95 SCT_FROM_TLS_EXTENSION
= 1,
96 SCT_FROM_OCSP_RESPONSE
= 2,
100 SignedCertificateTimestamp();
102 void Persist(Pickle
* pickle
);
103 static scoped_refptr
<SignedCertificateTimestamp
> CreateFromPickle(
104 PickleIterator
* iter
);
108 base::Time timestamp
;
109 std::string extensions
;
110 DigitallySigned signature
;
111 // The origin should not participate in equality checks
112 // as the same SCT can be provided from multiple sources.
114 // The log description is not one of the SCT fields, but a user-readable
115 // name defined alongside the log key. It should not participate
116 // in equality checks as the log's description could change while
117 // the SCT would be the same.
118 std::string log_description
;
121 friend class base::RefCountedThreadSafe
<SignedCertificateTimestamp
>;
123 ~SignedCertificateTimestamp();
125 DISALLOW_COPY_AND_ASSIGN(SignedCertificateTimestamp
);
132 #endif // NET_CERT_SIGNED_CERTIFICATE_TIMESTAMP_H_