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

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

Issue 1845113003: Certificate Transparency: Start tracking logs' state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ready for review Created 4 years, 8 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
(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/memory/scoped_ptr.h"
13 #include "base/time/time.h"
14 #include "net/cert/ct_observer.h"
15 #include "net/cert/signed_tree_head.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.
32 class SingleTreeTracker : public net::ct::CTObserver {
33 public:
34 // TODO(eranm): This enum will expand to include check success/failure,
35 // see crbug.com/506227
36 enum SCTInclusionStatus {
37 // SCT was not observed by this class.
38 SCT_NOT_OBSERVED,
39 // SCT was observed but the STH known to this class is not old
Ryan Sleevi 2016/04/14 16:56:16 Readability: Newlines between 38/39, 41/42
Eran Messeri 2016/04/18 22:02:12 Done.
40 // enough to check for inclusion.
41 SCT_PENDING_NEWER_STH,
42 // SCT is known and there's a new-enough STH to check inclusion against.
43 // Actual inclusion check has to be performed.
44 SCT_PENDING_INCLUSION_CHECK
45 };
46
47 explicit SingleTreeTracker(scoped_refptr<const net::CTLogVerifier>& ct_log);
Ryan Sleevi 2016/04/14 16:56:16 If you're passing by ref, pass it const. But in th
Eran Messeri 2016/04/18 22:02:12 Done.
48 ~SingleTreeTracker() override;
49
50 // net::ct::CTVerifier::Observer implementation.
51 // Performs an inclusion check for the given certificate if the latest
52 // STH known for this log is older than sct.timestamp + MMD, enqueues
53 // the SCT for future checking later on.
Ryan Sleevi 2016/04/14 16:56:16 Does this do the checking synchronously? CT is alr
Eran Messeri 2016/04/18 22:02:12 No - it does not do the checking synchronously. Ri
54 void OnSCTVerified(net::X509Certificate* cert,
55 const net::ct::SignedCertificateTimestamp* sct) override;
56
57 // net::ct::STHObserver implementation.
58 // After verification of the signature over the |sth|, uses this
59 // STH for future inclusion checks.
60 void NewSTHObserved(const net::ct::SignedTreeHead& sth) override;
61
62 // Returns the status of a given log entry (that is assembled from
63 // |cert| and |sct|).
64 SCTInclusionStatus GetLogEntryInclusionStatus(
65 net::X509Certificate* cert,
66 const net::ct::SignedCertificateTimestamp* sct);
67
68 private:
69 // Logs an error and aborts if the provided log_id is not the same as the
70 // log id this instance knows of.
71 void CheckLogId(const std::string& log_id);
72
73 // Holds the latest STH fetched and verified for each log.
74 net::ct::SignedTreeHead verified_sth_;
75 // The log tracked.
76 scoped_refptr<const net::CTLogVerifier> ct_log_;
77 // List of log entries pending inclusion check.
78 // TODO(eranm): Rather than rely on the timestamp, extend to to use the
79 // whole MerkleTreeLeaf (RFC6962, section 3.4.) as a key. See crbug.com/506227
80 std::map<base::Time, SCTInclusionStatus> entries_status_;
81
82 DISALLOW_COPY_AND_ASSIGN(SingleTreeTracker);
83 };
84
85 } // namespace certificate_transparency
86
87 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_SINGLE_TREE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698