Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: components/certificate_transparency/single_tree_tracker.h

Issue 2017563002: Add Certificate Transparency logs auditing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switching to TimestampedLeaf Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 4
5 #ifndef COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_ 5 #ifndef COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_
6 #define COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_ 6 #define COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_
7 7
8 #include <map> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "components/certificate_transparency/timestamped_leaf.h"
13 #include "net/cert/ct_verifier.h" 14 #include "net/cert/ct_verifier.h"
14 #include "net/cert/signed_tree_head.h" 15 #include "net/cert/signed_tree_head.h"
15 #include "net/cert/sth_observer.h" 16 #include "net/cert/sth_observer.h"
16 17
17 namespace net { 18 namespace net {
18 class CTLogVerifier; 19 class CTLogVerifier;
19 class X509Certificate; 20 class X509Certificate;
20 21
21 namespace ct { 22 namespace ct {
22 struct SignedCertificateTimestamp; 23 struct SignedCertificateTimestamp;
23 } // namespace ct 24 } // namespace ct
24 25
25 } // namespace net 26 } // namespace net
26 27
27 namespace certificate_transparency { 28 namespace certificate_transparency {
29 struct OrderByTimestamp {
30 bool operator()(const TimestampedLeaf& lhs, const TimestampedLeaf& rhs);
31 };
28 32
29 // Tracks the state of an individual Certificate Transparency Log's Merkle Tree. 33 // Tracks the state of an individual Certificate Transparency Log's Merkle Tree.
30 // A CT Log constantly issues Signed Tree Heads, for which every older STH must 34 // A CT Log constantly issues Signed Tree Heads, for which every older STH must
31 // be incorporated into the current/newer STH. As new certificates are logged, 35 // be incorporated into the current/newer STH. As new certificates are logged,
32 // new SCTs are produced, and eventually, those SCTs are incorporated into the 36 // new SCTs are produced, and eventually, those SCTs are incorporated into the
33 // log and a new STH is produced, with there being an inclusion proof between 37 // log and a new STH is produced, with there being an inclusion proof between
34 // the SCTs and the new STH, and a consistency proof between the old STH and the 38 // the SCTs and the new STH, and a consistency proof between the old STH and the
35 // new STH. 39 // new STH.
36 // This class receives STHs provided by/observed by the embedder, with the 40 // This class receives STHs provided by/observed by the embedder, with the
37 // assumption that STHs have been checked for consistency already. As SCTs are 41 // assumption that STHs have been checked for consistency already. As SCTs are
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 93
90 // Returns the status of a given log entry that is assembled from 94 // Returns the status of a given log entry that is assembled from
91 // |cert| and |sct|. If |cert| and |sct| were not previously observed, 95 // |cert| and |sct|. If |cert| and |sct| were not previously observed,
92 // |sct| is not an SCT for |cert| or |sct| is not for this log, 96 // |sct| is not an SCT for |cert| or |sct| is not for this log,
93 // SCT_NOT_OBSERVED will be returned. 97 // SCT_NOT_OBSERVED will be returned.
94 SCTInclusionStatus GetLogEntryInclusionStatus( 98 SCTInclusionStatus GetLogEntryInclusionStatus(
95 net::X509Certificate* cert, 99 net::X509Certificate* cert,
96 const net::ct::SignedCertificateTimestamp* sct); 100 const net::ct::SignedCertificateTimestamp* sct);
97 101
98 private: 102 private:
103 // Returns true if |leaf| is pending a newer STH.
104 bool EntryPendingNewSTH(const net::ct::MerkleTreeLeaf& leaf);
105
106 // Returns true if |leaf| is pending inclusion check.
107 bool EntryPendingInclusionProof(const net::ct::MerkleTreeLeaf& leaf);
108
99 // Holds the latest STH fetched and verified for this log. 109 // Holds the latest STH fetched and verified for this log.
100 net::ct::SignedTreeHead verified_sth_; 110 net::ct::SignedTreeHead verified_sth_;
101 111
102 // The log being tracked. 112 // The log being tracked.
103 scoped_refptr<const net::CTLogVerifier> ct_log_; 113 scoped_refptr<const net::CTLogVerifier> ct_log_;
104 114
105 // List of log entries pending inclusion check. 115 // Set of log entries pending a fresh STH.
106 // TODO(eranm): Rather than rely on the timestamp, extend to to use the 116 std::set<TimestampedLeaf, OrderByTimestamp> pending_new_sth_;
107 // whole MerkleTreeLeaf (RFC6962, section 3.4.) as a key. See 117
108 // https://crbug.com/506227#c22 and https://crbug.com/613495 118 // Set of log entries pending inclusion check.
109 std::map<base::Time, SCTInclusionStatus> entries_status_; 119 std::set<TimestampedLeaf, OrderByTimestamp> pending_inclusion_check_;
110 120
111 DISALLOW_COPY_AND_ASSIGN(SingleTreeTracker); 121 DISALLOW_COPY_AND_ASSIGN(SingleTreeTracker);
112 }; 122 };
113 123
114 } // namespace certificate_transparency 124 } // namespace certificate_transparency
115 125
116 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_ 126 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698