| 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 <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/metrics/histogram_samples.h" | 13 #include "base/metrics/histogram_samples.h" |
| 14 #include "base/metrics/statistics_recorder.h" | 14 #include "base/metrics/statistics_recorder.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.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/net_log.h" | 24 #include "net/log/net_log.h" |
| 25 #include "net/log/net_log_source_type.h" |
| 25 #include "net/log/test_net_log.h" | 26 #include "net/log/test_net_log.h" |
| 26 #include "net/log/test_net_log_entry.h" | 27 #include "net/log/test_net_log_entry.h" |
| 27 #include "net/test/cert_test_util.h" | 28 #include "net/test/cert_test_util.h" |
| 28 #include "net/test/ct_test_util.h" | 29 #include "net/test/ct_test_util.h" |
| 29 #include "net/test/test_data_directory.h" | 30 #include "net/test/test_data_directory.h" |
| 30 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 32 | 33 |
| 33 using testing::_; | 34 using testing::_; |
| 34 using testing::Mock; | 35 using testing::Mock; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 std::string(), | 118 std::string(), |
| 118 std::string(), | 119 std::string(), |
| 119 result, | 120 result, |
| 120 bound_net_log) == OK; | 121 bound_net_log) == OK; |
| 121 } | 122 } |
| 122 | 123 |
| 123 bool VerifySinglePrecertificateChain(scoped_refptr<X509Certificate> chain) { | 124 bool VerifySinglePrecertificateChain(scoped_refptr<X509Certificate> chain) { |
| 124 ct::CTVerifyResult result; | 125 ct::CTVerifyResult result; |
| 125 TestNetLog net_log; | 126 TestNetLog net_log; |
| 126 BoundNetLog bound_net_log = | 127 BoundNetLog bound_net_log = |
| 127 BoundNetLog::Make(&net_log, NetLog::SOURCE_CONNECT_JOB); | 128 BoundNetLog::Make(&net_log, NetLogSourceType::CONNECT_JOB); |
| 128 | 129 |
| 129 return verifier_->Verify(chain.get(), | 130 return verifier_->Verify(chain.get(), |
| 130 std::string(), | 131 std::string(), |
| 131 std::string(), | 132 std::string(), |
| 132 &result, | 133 &result, |
| 133 bound_net_log) == OK; | 134 bound_net_log) == OK; |
| 134 } | 135 } |
| 135 | 136 |
| 136 bool CheckPrecertificateVerification(scoped_refptr<X509Certificate> chain) { | 137 bool CheckPrecertificateVerification(scoped_refptr<X509Certificate> chain) { |
| 137 ct::CTVerifyResult result; | 138 ct::CTVerifyResult result; |
| 138 TestNetLog net_log; | 139 TestNetLog net_log; |
| 139 BoundNetLog bound_net_log = | 140 BoundNetLog bound_net_log = |
| 140 BoundNetLog::Make(&net_log, NetLog::SOURCE_CONNECT_JOB); | 141 BoundNetLog::Make(&net_log, NetLogSourceType::CONNECT_JOB); |
| 141 return (VerifySinglePrecertificateChain(chain, bound_net_log, &result) && | 142 return (VerifySinglePrecertificateChain(chain, bound_net_log, &result) && |
| 142 ct::CheckForSingleVerifiedSCTInResult(result, kLogDescription) && | 143 ct::CheckForSingleVerifiedSCTInResult(result, kLogDescription) && |
| 143 ct::CheckForSCTOrigin( | 144 ct::CheckForSCTOrigin( |
| 144 result, ct::SignedCertificateTimestamp::SCT_EMBEDDED) && | 145 result, ct::SignedCertificateTimestamp::SCT_EMBEDDED) && |
| 145 CheckForEmbeddedSCTInNetLog(net_log)); | 146 CheckForEmbeddedSCTInNetLog(net_log)); |
| 146 } | 147 } |
| 147 | 148 |
| 148 // Histogram-related helper methods | 149 // Histogram-related helper methods |
| 149 int GetValueFromHistogram(const std::string& histogram_name, | 150 int GetValueFromHistogram(const std::string& histogram_name, |
| 150 int sample_index) { | 151 int sample_index) { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 Mock::VerifyAndClearExpectations(&observer); | 298 Mock::VerifyAndClearExpectations(&observer); |
| 298 | 299 |
| 299 EXPECT_CALL(observer, OnSCTVerified(embedded_sct_chain_.get(), _)).Times(0); | 300 EXPECT_CALL(observer, OnSCTVerified(embedded_sct_chain_.get(), _)).Times(0); |
| 300 verifier_->SetObserver(nullptr); | 301 verifier_->SetObserver(nullptr); |
| 301 ASSERT_TRUE(VerifySinglePrecertificateChain(embedded_sct_chain_)); | 302 ASSERT_TRUE(VerifySinglePrecertificateChain(embedded_sct_chain_)); |
| 302 } | 303 } |
| 303 | 304 |
| 304 } // namespace | 305 } // namespace |
| 305 | 306 |
| 306 } // namespace net | 307 } // namespace net |
| OLD | NEW |