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 <map> |
| 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" | |
| 13 #include "net/cert/ct_verifier.h" | 12 #include "net/cert/ct_verifier.h" |
| 14 #include "net/cert/signed_tree_head.h" | 13 #include "net/cert/signed_tree_head.h" |
| 15 #include "net/cert/sth_observer.h" | 14 #include "net/cert/sth_observer.h" |
| 16 | 15 |
| 17 namespace net { | 16 namespace net { |
| 18 class CTLogVerifier; | 17 class CTLogVerifier; |
| 19 class X509Certificate; | 18 class X509Certificate; |
| 20 | 19 |
| 21 namespace ct { | 20 namespace ct { |
| 22 struct SignedCertificateTimestamp; | 21 struct SignedCertificateTimestamp; |
| 23 } // namespace ct | 22 } // namespace ct |
| 24 | 23 |
| 25 } // namespace net | 24 } // namespace net |
| 26 | 25 |
| 27 namespace certificate_transparency { | 26 namespace certificate_transparency { |
| 28 | |
|
Ryan Sleevi
2016/07/18 23:38:01
keep this. Consider the examples in https://google
Eran Messeri
2016/09/21 21:10:43
Done - for consistency I've added newlines after e
| |
| 29 // Tracks the state of an individual Certificate Transparency Log's Merkle Tree. | 27 // 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 | 28 // 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, | 29 // 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 | 30 // 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 | 31 // 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 | 32 // the SCTs and the new STH, and a consistency proof between the old STH and the |
| 35 // new STH. | 33 // new STH. |
| 36 // This class receives STHs provided by/observed by the embedder, with the | 34 // 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 | 35 // assumption that STHs have been checked for consistency already. As SCTs are |
| 38 // observed, their status is checked against the latest STH to ensure they were | 36 // observed, their status is checked against the latest STH to ensure they were |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 | 87 |
| 90 // Returns the status of a given log entry that is assembled from | 88 // Returns the status of a given log entry that is assembled from |
| 91 // |cert| and |sct|. If |cert| and |sct| were not previously observed, | 89 // |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, | 90 // |sct| is not an SCT for |cert| or |sct| is not for this log, |
| 93 // SCT_NOT_OBSERVED will be returned. | 91 // SCT_NOT_OBSERVED will be returned. |
| 94 SCTInclusionStatus GetLogEntryInclusionStatus( | 92 SCTInclusionStatus GetLogEntryInclusionStatus( |
| 95 net::X509Certificate* cert, | 93 net::X509Certificate* cert, |
| 96 const net::ct::SignedCertificateTimestamp* sct); | 94 const net::ct::SignedCertificateTimestamp* sct); |
| 97 | 95 |
| 98 private: | 96 private: |
| 97 struct EntryToAudit; | |
| 98 | |
| 99 // Orders instances by the timestamp of the SCT they contain. | |
| 100 struct OrderByTimestamp { | |
| 101 bool operator()(const EntryToAudit& lhs, const EntryToAudit& rhs) const; | |
| 102 }; | |
| 103 | |
| 104 // Returns true if |leaf| has been observed in the past. | |
| 105 bool EntryAlreadyEncountered(const EntryToAudit& entry); | |
| 106 | |
| 99 // Holds the latest STH fetched and verified for this log. | 107 // Holds the latest STH fetched and verified for this log. |
| 100 net::ct::SignedTreeHead verified_sth_; | 108 net::ct::SignedTreeHead verified_sth_; |
| 101 | 109 |
| 102 // The log being tracked. | 110 // The log being tracked. |
| 103 scoped_refptr<const net::CTLogVerifier> ct_log_; | 111 scoped_refptr<const net::CTLogVerifier> ct_log_; |
| 104 | 112 |
| 105 // List of log entries pending inclusion check. | 113 // Map of log entries to their state. |
| 106 // TODO(eranm): Rather than rely on the timestamp, extend to to use the | 114 std::map<EntryToAudit, SCTInclusionStatus, OrderByTimestamp> |
| 107 // whole MerkleTreeLeaf (RFC6962, section 3.4.) as a key. See | 115 observed_entries_; |
| 108 // https://crbug.com/506227#c22 and https://crbug.com/613495 | |
| 109 std::map<base::Time, SCTInclusionStatus> entries_status_; | |
| 110 | 116 |
| 111 DISALLOW_COPY_AND_ASSIGN(SingleTreeTracker); | 117 DISALLOW_COPY_AND_ASSIGN(SingleTreeTracker); |
| 112 }; | 118 }; |
| 113 | 119 |
| 114 } // namespace certificate_transparency | 120 } // namespace certificate_transparency |
| 115 | 121 |
| 116 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_ | 122 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_ |
| OLD | NEW |