Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/observed_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 // Orders ObservedLeaf instances by the timestamp of the MerkleTreeLeaf they | |
| 30 // contain, *not* the observation time. | |
| 31 struct OrderByTimestamp { | |
| 32 bool operator()(const ObservedLeaf& lhs, const ObservedLeaf& rhs); | |
| 33 }; | |
|
Ryan Sleevi
2016/06/30 22:48:19
Does not need to be global; should be a private cl
Eran Messeri
2016/07/01 13:24:01
Done.
| |
| 28 | 34 |
| 29 // Tracks the state of an individual Certificate Transparency Log's Merkle Tree. | 35 // 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 | 36 // 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, | 37 // 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 | 38 // 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 | 39 // 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 | 40 // the SCTs and the new STH, and a consistency proof between the old STH and the |
| 35 // new STH. | 41 // new STH. |
| 36 // This class receives STHs provided by/observed by the embedder, with the | 42 // 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 | 43 // assumption that STHs have been checked for consistency already. As SCTs are |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 | 95 |
| 90 // Returns the status of a given log entry that is assembled from | 96 // Returns the status of a given log entry that is assembled from |
| 91 // |cert| and |sct|. If |cert| and |sct| were not previously observed, | 97 // |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, | 98 // |sct| is not an SCT for |cert| or |sct| is not for this log, |
| 93 // SCT_NOT_OBSERVED will be returned. | 99 // SCT_NOT_OBSERVED will be returned. |
| 94 SCTInclusionStatus GetLogEntryInclusionStatus( | 100 SCTInclusionStatus GetLogEntryInclusionStatus( |
| 95 net::X509Certificate* cert, | 101 net::X509Certificate* cert, |
| 96 const net::ct::SignedCertificateTimestamp* sct); | 102 const net::ct::SignedCertificateTimestamp* sct); |
| 97 | 103 |
| 98 private: | 104 private: |
| 105 // Returns true if |leaf| is pending a newer STH. | |
|
Ryan Sleevi
2016/06/30 22:48:19
From reading this header, it's unclear what this m
Eran Messeri
2016/07/01 13:24:01
This method is gone, replaced with LeafAlreadyEnco
| |
| 106 bool EntryPendingNewSTH(const ObservedLeaf& leaf); | |
| 107 | |
| 108 // Returns true if |leaf| is pending inclusion check. | |
|
Ryan Sleevi
2016/06/30 22:48:19
Grammatically, this reads weird. It feels like an
Eran Messeri
2016/07/01 13:24:00
This method is gone.
| |
| 109 bool EntryPendingInclusionProof(const ObservedLeaf& leaf); | |
| 110 | |
| 99 // Holds the latest STH fetched and verified for this log. | 111 // Holds the latest STH fetched and verified for this log. |
| 100 net::ct::SignedTreeHead verified_sth_; | 112 net::ct::SignedTreeHead verified_sth_; |
| 101 | 113 |
| 102 // The log being tracked. | 114 // The log being tracked. |
| 103 scoped_refptr<const net::CTLogVerifier> ct_log_; | 115 scoped_refptr<const net::CTLogVerifier> ct_log_; |
| 104 | 116 |
| 105 // List of log entries pending inclusion check. | 117 // Set of log entries pending a fresh STH. |
| 106 // TODO(eranm): Rather than rely on the timestamp, extend to to use the | 118 std::set<ObservedLeaf, OrderByTimestamp> pending_new_sth_; |
| 107 // whole MerkleTreeLeaf (RFC6962, section 3.4.) as a key. See | 119 |
| 108 // https://crbug.com/506227#c22 and https://crbug.com/613495 | 120 // Set of log entries pending inclusion check. |
|
Ryan Sleevi
2016/06/30 22:48:19
grammatically, this reads weird. It feels like the
Eran Messeri
2016/07/01 13:24:00
I now use a map of (MerkleTreeLeaf, LeafState), so
| |
| 109 std::map<base::Time, SCTInclusionStatus> entries_status_; | 121 std::set<ObservedLeaf, OrderByTimestamp> pending_inclusion_check_; |
| 110 | 122 |
| 111 DISALLOW_COPY_AND_ASSIGN(SingleTreeTracker); | 123 DISALLOW_COPY_AND_ASSIGN(SingleTreeTracker); |
| 112 }; | 124 }; |
| 113 | 125 |
| 114 } // namespace certificate_transparency | 126 } // namespace certificate_transparency |
| 115 | 127 |
| 116 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_ | 128 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_ |
| OLD | NEW |