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

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: Created 4 years, 6 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 "net/cert/ct_verifier.h" 13 #include "net/cert/ct_verifier.h"
14 #include "net/cert/merkle_tree_leaf.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 net::ct::MerkleTreeLeaf& lhs,
31 const net::ct::MerkleTreeLeaf& rhs);
32 };
28 33
29 // Tracks the state of an individual Certificate Transparency Log's Merkle Tree. 34 // 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 35 // 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, 36 // 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 37 // 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 38 // 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 39 // the SCTs and the new STH, and a consistency proof between the old STH and the
35 // new STH. 40 // new STH.
36 // This class receives STHs provided by/observed by the embedder, with the 41 // 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 42 // 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 94
90 // Returns the status of a given log entry that is assembled from 95 // Returns the status of a given log entry that is assembled from
91 // |cert| and |sct|. If |cert| and |sct| were not previously observed, 96 // |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, 97 // |sct| is not an SCT for |cert| or |sct| is not for this log,
93 // SCT_NOT_OBSERVED will be returned. 98 // SCT_NOT_OBSERVED will be returned.
94 SCTInclusionStatus GetLogEntryInclusionStatus( 99 SCTInclusionStatus GetLogEntryInclusionStatus(
95 net::X509Certificate* cert, 100 net::X509Certificate* cert,
96 const net::ct::SignedCertificateTimestamp* sct); 101 const net::ct::SignedCertificateTimestamp* sct);
97 102
98 private: 103 private:
104 // Returns true if |leaf| is pending a newer STH.
105 bool EntryPendingNewSTH(const net::ct::MerkleTreeLeaf& leaf);
106
107 // Returns true if |leaf| is pending inclusion check.
108 bool EntryPendingInclusionProof(const net::ct::MerkleTreeLeaf& leaf);
109
99 // Holds the latest STH fetched and verified for this log. 110 // Holds the latest STH fetched and verified for this log.
100 net::ct::SignedTreeHead verified_sth_; 111 net::ct::SignedTreeHead verified_sth_;
101 112
102 // The log being tracked. 113 // The log being tracked.
103 scoped_refptr<const net::CTLogVerifier> ct_log_; 114 scoped_refptr<const net::CTLogVerifier> ct_log_;
104 115
105 // List of log entries pending inclusion check. 116 // Set of log entries pending a fresh STH.
106 // TODO(eranm): Rather than rely on the timestamp, extend to to use the 117 std::set<net::ct::MerkleTreeLeaf, OrderByTimestamp> pending_new_sth_;
Rob Percival 2016/05/26 17:33:15 Are you thinking of adding a timestamp to MerkleTr
Eran Messeri 2016/06/30 19:58:28 I've added another class.
107 // whole MerkleTreeLeaf (RFC6962, section 3.4.) as a key. See 118
108 // https://crbug.com/506227#c22 and https://crbug.com/613495 119 // Set of log entries pending inclusion check.
109 std::map<base::Time, SCTInclusionStatus> entries_status_; 120 std::set<net::ct::MerkleTreeLeaf, OrderByTimestamp> pending_inclusion_check_;
110 121
111 DISALLOW_COPY_AND_ASSIGN(SingleTreeTracker); 122 DISALLOW_COPY_AND_ASSIGN(SingleTreeTracker);
112 }; 123 };
113 124
114 } // namespace certificate_transparency 125 } // namespace certificate_transparency
115 126
116 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_ 127 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698