OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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_TREE_STATE_TRACKER_H_ |
| 6 #define COMPONENTS_CERTIFICATE_TRANSPARENCY_TREE_STATE_TRACKER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "net/cert/ct_verifier.h" |
| 15 |
| 16 namespace net { |
| 17 class CTLogVerifier; |
| 18 class X509Certificate; |
| 19 |
| 20 namespace ct { |
| 21 struct SignedCertificateTimestamp; |
| 22 struct SignedTreeHead; |
| 23 } // namespace ct |
| 24 |
| 25 } // namespace net |
| 26 |
| 27 namespace certificate_transparency { |
| 28 |
| 29 class LogProofFetcher; |
| 30 |
| 31 // Tracks the state of the Merkle Trees of CT logs Chromium |
| 32 // knows about. For now, only stores Signed Tree Heads. |
| 33 class TreeStateTracker : public net::CTVerifier::Observer { |
| 34 public: |
| 35 TreeStateTracker( |
| 36 scoped_ptr<LogProofFetcher> fetcher, |
| 37 const std::vector<scoped_refptr<net::CTLogVerifier>>& ct_logs); |
| 38 ~TreeStateTracker() override; |
| 39 |
| 40 void OnSCTVerified(net::X509Certificate* cert, |
| 41 const net::ct::SignedCertificateTimestamp* sct) override; |
| 42 |
| 43 private: |
| 44 void RefreshSTHs(); |
| 45 void OnSTHFetched(const std::string& log_id, |
| 46 const net::ct::SignedTreeHead& unverified_sth); |
| 47 void OnSTHFetchingFailed(const std::string& log_id, |
| 48 int net_error, |
| 49 int http_response_code); |
| 50 |
| 51 // Holds the latest STH fetched and verified for each log. |
| 52 std::map<std::string, net::ct::SignedTreeHead> verified_sths_; |
| 53 // Holds STHs that were received but not checked for consistency. |
| 54 std::map<std::string, net::ct::SignedTreeHead> |
| 55 sths_pending_consistency_check_; |
| 56 // Fetcher for getting STHs and proofs from CT logs. |
| 57 scoped_ptr<LogProofFetcher> fetcher_; |
| 58 // List of CT logs to track. |
| 59 std::map<std::string, scoped_refptr<net::CTLogVerifier>> ct_logs_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(TreeStateTracker); |
| 62 }; |
| 63 |
| 64 } // namespace certificate_transparency |
| 65 |
| 66 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_TREE_STATE_TRACKER_H_ |
OLD | NEW |