OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 NET_CERT_MULTI_LOG_CT_VERIFIER_H_ | 5 #ifndef NET_CERT_MULTI_LOG_CT_VERIFIER_H_ |
6 #define NET_CERT_MULTI_LOG_CT_VERIFIER_H_ | 6 #define NET_CERT_MULTI_LOG_CT_VERIFIER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
15 #include "net/cert/ct_verifier.h" | 15 #include "net/cert/ct_verifier.h" |
16 #include "net/cert/signed_certificate_timestamp.h" | 16 #include "net/cert/signed_certificate_timestamp.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 namespace ct { | 20 namespace ct { |
21 struct LogEntry; | 21 struct SignedEntryData; |
22 } // namespace ct | 22 } // namespace ct |
23 | 23 |
24 class CTLogVerifier; | 24 class CTLogVerifier; |
25 | 25 |
26 // A Certificate Transparency verifier that can verify Signed Certificate | 26 // A Certificate Transparency verifier that can verify Signed Certificate |
27 // Timestamps from multiple logs. | 27 // Timestamps from multiple logs. |
28 // It must be initialized with a list of logs by calling AddLogs. | 28 // It must be initialized with a list of logs by calling AddLogs. |
29 class NET_EXPORT MultiLogCTVerifier : public CTVerifier { | 29 class NET_EXPORT MultiLogCTVerifier : public CTVerifier { |
30 public: | 30 public: |
31 MultiLogCTVerifier(); | 31 MultiLogCTVerifier(); |
32 ~MultiLogCTVerifier() override; | 32 ~MultiLogCTVerifier() override; |
33 | 33 |
34 void AddLogs( | 34 void AddLogs( |
35 const std::vector<scoped_refptr<const CTLogVerifier>>& log_verifiers); | 35 const std::vector<scoped_refptr<const CTLogVerifier>>& log_verifiers); |
36 | 36 |
37 // CTVerifier implementation: | 37 // CTVerifier implementation: |
38 void Verify(X509Certificate* cert, | 38 void Verify(X509Certificate* cert, |
39 base::StringPiece stapled_ocsp_response, | 39 base::StringPiece stapled_ocsp_response, |
40 base::StringPiece sct_list_from_tls_extension, | 40 base::StringPiece sct_list_from_tls_extension, |
41 SignedCertificateTimestampAndStatusList* output_scts, | 41 SignedCertificateTimestampAndStatusList* output_scts, |
42 const NetLogWithSource& net_log) override; | 42 const NetLogWithSource& net_log) override; |
43 | 43 |
44 void SetObserver(Observer* observer) override; | 44 void SetObserver(Observer* observer) override; |
45 | 45 |
46 private: | 46 private: |
47 // Verify a list of SCTs from |encoded_sct_list| over |expected_entry|, | 47 // Verify a list of SCTs from |encoded_sct_list| over |expected_entry|, |
48 // placing the verification results in |output_scts|. The SCTs in the list | 48 // placing the verification results in |output_scts|. The SCTs in the list |
49 // come from |origin| (as will be indicated in the origin field of each SCT). | 49 // come from |origin| (as will be indicated in the origin field of each SCT). |
50 void VerifySCTs(base::StringPiece encoded_sct_list, | 50 void VerifySCTs(base::StringPiece encoded_sct_list, |
51 const ct::LogEntry& expected_entry, | 51 const ct::SignedEntryData& expected_entry, |
52 ct::SignedCertificateTimestamp::Origin origin, | 52 ct::SignedCertificateTimestamp::Origin origin, |
53 X509Certificate* cert, | 53 X509Certificate* cert, |
54 SignedCertificateTimestampAndStatusList* output_scts); | 54 SignedCertificateTimestampAndStatusList* output_scts); |
55 | 55 |
56 // Verifies a single, parsed SCT against all logs. | 56 // Verifies a single, parsed SCT against all logs. |
57 bool VerifySingleSCT(scoped_refptr<ct::SignedCertificateTimestamp> sct, | 57 bool VerifySingleSCT(scoped_refptr<ct::SignedCertificateTimestamp> sct, |
58 const ct::LogEntry& expected_entry, | 58 const ct::SignedEntryData& expected_entry, |
59 X509Certificate* cert, | 59 X509Certificate* cert, |
60 SignedCertificateTimestampAndStatusList* output_scts); | 60 SignedCertificateTimestampAndStatusList* output_scts); |
61 | 61 |
62 // Mapping from a log's ID to the verifier for this log. | 62 // Mapping from a log's ID to the verifier for this log. |
63 // A log's ID is the SHA-256 of the log's key, as defined in section 3.2. | 63 // A log's ID is the SHA-256 of the log's key, as defined in section 3.2. |
64 // of RFC6962. | 64 // of RFC6962. |
65 std::map<std::string, scoped_refptr<const CTLogVerifier>> logs_; | 65 std::map<std::string, scoped_refptr<const CTLogVerifier>> logs_; |
66 | 66 |
67 Observer* observer_; | 67 Observer* observer_; |
68 | 68 |
69 DISALLOW_COPY_AND_ASSIGN(MultiLogCTVerifier); | 69 DISALLOW_COPY_AND_ASSIGN(MultiLogCTVerifier); |
70 }; | 70 }; |
71 | 71 |
72 } // namespace net | 72 } // namespace net |
73 | 73 |
74 #endif // NET_CERT_MULTI_LOG_CT_VERIFIER_H_ | 74 #endif // NET_CERT_MULTI_LOG_CT_VERIFIER_H_ |
OLD | NEW |