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 #include "net/cert/multi_log_ct_verifier.h" | 5 #include "net/cert/multi_log_ct_verifier.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/metrics/histogram_samples.h" | 12 #include "base/metrics/histogram_samples.h" |
13 #include "base/metrics/statistics_recorder.h" | 13 #include "base/metrics/statistics_recorder.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
16 #include "net/base/test_data_directory.h" | 16 #include "net/base/test_data_directory.h" |
17 #include "net/cert/ct_log_verifier.h" | 17 #include "net/cert/ct_log_verifier.h" |
18 #include "net/cert/ct_serialization.h" | 18 #include "net/cert/ct_serialization.h" |
19 #include "net/cert/ct_verify_result.h" | 19 #include "net/cert/ct_verify_result.h" |
20 #include "net/cert/pem_tokenizer.h" | 20 #include "net/cert/pem_tokenizer.h" |
21 #include "net/cert/sct_status_flags.h" | 21 #include "net/cert/sct_status_flags.h" |
22 #include "net/cert/signed_certificate_timestamp.h" | 22 #include "net/cert/signed_certificate_timestamp.h" |
23 #include "net/cert/x509_certificate.h" | 23 #include "net/cert/x509_certificate.h" |
| 24 #include "net/log/captured_net_log_entry.h" |
24 #include "net/log/net_log.h" | 25 #include "net/log/net_log.h" |
25 #include "net/log/test_net_log.h" | 26 #include "net/log/test_net_log.h" |
26 #include "net/test/cert_test_util.h" | 27 #include "net/test/cert_test_util.h" |
27 #include "net/test/ct_test_util.h" | 28 #include "net/test/ct_test_util.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
29 | 30 |
30 namespace net { | 31 namespace net { |
31 | 32 |
32 namespace { | 33 namespace { |
33 | 34 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 66 } |
66 | 67 |
67 bool CheckForSCTOrigin( | 68 bool CheckForSCTOrigin( |
68 const ct::CTVerifyResult& result, | 69 const ct::CTVerifyResult& result, |
69 ct::SignedCertificateTimestamp::Origin origin) { | 70 ct::SignedCertificateTimestamp::Origin origin) { |
70 return (result.verified_scts.size() > 0) && | 71 return (result.verified_scts.size() > 0) && |
71 (result.verified_scts[0]->origin == origin); | 72 (result.verified_scts[0]->origin == origin); |
72 } | 73 } |
73 | 74 |
74 bool CheckForEmbeddedSCTInNetLog(TestNetLog& net_log) { | 75 bool CheckForEmbeddedSCTInNetLog(TestNetLog& net_log) { |
75 TestNetLog::CapturedEntryList entries; | 76 CapturedNetLogEntry::List entries; |
76 net_log.GetEntries(&entries); | 77 net_log.GetEntries(&entries); |
77 if (entries.size() != 2) | 78 if (entries.size() != 2) |
78 return false; | 79 return false; |
79 | 80 |
80 const TestNetLog::CapturedEntry& received = entries[0]; | 81 const CapturedNetLogEntry& received = entries[0]; |
81 std::string embedded_scts; | 82 std::string embedded_scts; |
82 if (!received.GetStringValue("embedded_scts", &embedded_scts)) | 83 if (!received.GetStringValue("embedded_scts", &embedded_scts)) |
83 return false; | 84 return false; |
84 if (embedded_scts.empty()) | 85 if (embedded_scts.empty()) |
85 return false; | 86 return false; |
86 | 87 |
87 const TestNetLog::CapturedEntry& parsed = entries[1]; | 88 const CapturedNetLogEntry& parsed = entries[1]; |
88 base::ListValue* verified_scts; | 89 base::ListValue* verified_scts; |
89 if (!parsed.GetListValue("verified_scts", &verified_scts) || | 90 if (!parsed.GetListValue("verified_scts", &verified_scts) || |
90 verified_scts->GetSize() != 1) { | 91 verified_scts->GetSize() != 1) { |
91 return false; | 92 return false; |
92 } | 93 } |
93 | 94 |
94 base::DictionaryValue* the_sct; | 95 base::DictionaryValue* the_sct; |
95 if (!verified_scts->GetDictionary(0, &the_sct)) | 96 if (!verified_scts->GetDictionary(0, &the_sct)) |
96 return false; | 97 return false; |
97 | 98 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 TEST_F(MultiLogCTVerifierTest, CountsZeroSCTsCorrectly) { | 295 TEST_F(MultiLogCTVerifierTest, CountsZeroSCTsCorrectly) { |
295 int connections_without_scts = GetValueFromHistogram(kSCTCountHistogram, 0); | 296 int connections_without_scts = GetValueFromHistogram(kSCTCountHistogram, 0); |
296 EXPECT_FALSE(VerifySinglePrecertificateChain(chain_)); | 297 EXPECT_FALSE(VerifySinglePrecertificateChain(chain_)); |
297 ASSERT_EQ(connections_without_scts + 1, | 298 ASSERT_EQ(connections_without_scts + 1, |
298 GetValueFromHistogram(kSCTCountHistogram, 0)); | 299 GetValueFromHistogram(kSCTCountHistogram, 0)); |
299 } | 300 } |
300 | 301 |
301 } // namespace | 302 } // namespace |
302 | 303 |
303 } // namespace net | 304 } // namespace net |
OLD | NEW |