Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_ | |
| 6 #define COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/time/time.h" | |
| 13 #include "net/cert/ct_verifier.h" | |
| 14 #include "net/cert/signed_tree_head.h" | |
| 15 #include "net/cert/sth_observer.h" | |
| 16 | |
| 17 namespace net { | |
| 18 class CTLogVerifier; | |
| 19 class X509Certificate; | |
| 20 | |
| 21 namespace ct { | |
| 22 struct SignedCertificateTimestamp; | |
| 23 } // namespace ct | |
| 24 | |
| 25 } // namespace net | |
| 26 | |
| 27 namespace certificate_transparency { | |
| 28 | |
| 29 // Tracks the state of an individual CT log's Merkle Tree. By keeping the | |
| 30 // latest Signed Tree Head for a log, this class can check inclusion for | |
| 31 // observed SCTs. | |
|
Ryan Sleevi
2016/05/09 17:03:49
Can you expand this comment more? What is involve
Eran Messeri
2016/05/10 20:01:10
Done - used your text with some adaptations.
| |
| 32 class SingleTreeTracker : public net::CTVerifier::Observer, | |
| 33 public net::ct::STHObserver { | |
| 34 public: | |
| 35 // TODO(eranm): This enum will expand to include check success/failure, | |
| 36 // see crbug.com/506227 | |
| 37 enum SCTInclusionStatus { | |
| 38 // SCT was not observed by this class. | |
| 39 SCT_NOT_OBSERVED, | |
| 40 | |
| 41 // SCT was observed but the STH known to this class is not old | |
| 42 // enough to check for inclusion. | |
| 43 SCT_PENDING_NEWER_STH, | |
| 44 | |
| 45 // SCT is known and there's a new-enough STH to check inclusion against. | |
| 46 // Actual inclusion check has to be performed. | |
| 47 SCT_PENDING_INCLUSION_CHECK | |
| 48 }; | |
| 49 | |
| 50 explicit SingleTreeTracker(scoped_refptr<const net::CTLogVerifier> ct_log); | |
| 51 ~SingleTreeTracker() override; | |
| 52 | |
| 53 // net::ct::CTVerifier::Observer implementation. | |
|
Ryan Sleevi
2016/05/09 17:03:49
Now that we have net::ct::STHObserver, it does mak
Eran Messeri
2016/05/10 20:01:10
Acknowledged - can this be done in a follow-up CL?
| |
| 54 // Performs an inclusion check for the given certificate if the latest | |
| 55 // STH known for this log is older than sct.timestamp + MMD, enqueues | |
| 56 // the SCT for future checking later on. | |
| 57 // TODO(eranm): Make sure not to perform any synchronous, blocking operation | |
| 58 // here as this callback is invoked during certificate validation. | |
| 59 void OnSCTVerified(net::X509Certificate* cert, | |
| 60 const net::ct::SignedCertificateTimestamp* sct) override; | |
| 61 | |
| 62 // net::ct::STHObserver implementation. | |
| 63 // After verification of the signature over the |sth|, uses this | |
| 64 // STH for future inclusion checks. | |
| 65 void NewSTHObserved(const net::ct::SignedTreeHead& sth) override; | |
| 66 | |
| 67 // Returns the status of a given log entry (that is assembled from | |
| 68 // |cert| and |sct|). | |
|
Ryan Sleevi
2016/05/09 17:03:49
You're implicitly dropping something here, which i
Eran Messeri
2016/05/10 20:01:10
I don't quite grasp the reasoning behind this - ri
| |
| 69 SCTInclusionStatus GetLogEntryInclusionStatus( | |
| 70 net::X509Certificate* cert, | |
| 71 const net::ct::SignedCertificateTimestamp* sct); | |
| 72 | |
| 73 private: | |
| 74 // Logs an error and aborts if the provided log_id is not the same as the | |
| 75 // log id this instance knows of. | |
| 76 void CheckLogId(const std::string& log_id); | |
| 77 | |
| 78 // Holds the latest STH fetched and verified for each log. | |
| 79 net::ct::SignedTreeHead verified_sth_; | |
| 80 // The log tracked. | |
| 81 scoped_refptr<const net::CTLogVerifier> ct_log_; | |
| 82 // List of log entries pending inclusion check. | |
|
Ryan Sleevi
2016/05/09 17:03:49
Some newlines between each of these members would
Eran Messeri
2016/05/10 20:01:10
Done.
| |
| 83 // TODO(eranm): Rather than rely on the timestamp, extend to to use the | |
| 84 // whole MerkleTreeLeaf (RFC6962, section 3.4.) as a key. See crbug.com/506227 | |
| 85 std::map<base::Time, SCTInclusionStatus> entries_status_; | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(SingleTreeTracker); | |
| 88 }; | |
| 89 | |
| 90 } // namespace certificate_transparency | |
| 91 | |
| 92 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_ | |
| OLD | NEW |