OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "components/certificate_reporting/error_reporter.h" | 5 #include "components/certificate_reporting/error_reporter.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
18 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
19 #include "base/test/histogram_tester.h" | 19 #include "base/test/histogram_tester.h" |
20 #include "components/certificate_reporting/encrypted_cert_logger.pb.h" | 20 #include "components/certificate_reporting/encrypted_cert_logger.pb.h" |
21 #include "crypto/curve25519.h" | |
22 #include "net/test/url_request/url_request_failed_job.h" | 21 #include "net/test/url_request/url_request_failed_job.h" |
23 #include "net/url_request/report_sender.h" | 22 #include "net/url_request/report_sender.h" |
24 #include "net/url_request/url_request_test_util.h" | 23 #include "net/url_request/url_request_test_util.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "third_party/boringssl/src/include/openssl/curve25519.h" |
26 | 26 |
27 namespace certificate_reporting { | 27 namespace certificate_reporting { |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 const char kDummyHttpReportUri[] = "http://example.test"; | 31 const char kDummyHttpReportUri[] = "http://example.test"; |
32 const char kDummyHttpsReportUri[] = "https://example.test"; | 32 const char kDummyHttpsReportUri[] = "https://example.test"; |
33 const char kDummyReport[] = "a dummy report"; | 33 const char kDummyReport[] = "a dummy report"; |
34 const uint32_t kServerPublicKeyTestVersion = 16; | 34 const uint32_t kServerPublicKeyTestVersion = 16; |
35 const char kFailureHistogramName[] = "SSL.CertificateErrorReportFailure"; | 35 const char kFailureHistogramName[] = "SSL.CertificateErrorReportFailure"; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 private: | 83 private: |
84 base::Closure url_request_destroyed_callback_; | 84 base::Closure url_request_destroyed_callback_; |
85 | 85 |
86 DISALLOW_COPY_AND_ASSIGN(TestCertificateReporterNetworkDelegate); | 86 DISALLOW_COPY_AND_ASSIGN(TestCertificateReporterNetworkDelegate); |
87 }; | 87 }; |
88 | 88 |
89 class ErrorReporterTest : public ::testing::Test { | 89 class ErrorReporterTest : public ::testing::Test { |
90 public: | 90 public: |
91 ErrorReporterTest() { | 91 ErrorReporterTest() { |
92 memset(server_private_key_, 1, sizeof(server_private_key_)); | 92 memset(server_private_key_, 1, sizeof(server_private_key_)); |
93 crypto::curve25519::ScalarBaseMult(server_private_key_, server_public_key_); | 93 X25519_public_from_private(server_public_key_, server_private_key_); |
94 } | 94 } |
95 | 95 |
96 ~ErrorReporterTest() override {} | 96 ~ErrorReporterTest() override {} |
97 | 97 |
98 protected: | 98 protected: |
99 base::MessageLoopForIO loop_; | 99 base::MessageLoopForIO loop_; |
100 uint8_t server_public_key_[32]; | 100 uint8_t server_public_key_[32]; |
101 uint8_t server_private_key_[32]; | 101 uint8_t server_private_key_[32]; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(ErrorReporterTest); | 103 DISALLOW_COPY_AND_ASSIGN(ErrorReporterTest); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 ASSERT_TRUE(encrypted_request.ParseFromString( | 326 ASSERT_TRUE(encrypted_request.ParseFromString( |
327 std::string(reinterpret_cast<const char*>(kSerializedEncryptedReport), | 327 std::string(reinterpret_cast<const char*>(kSerializedEncryptedReport), |
328 sizeof(kSerializedEncryptedReport)))); | 328 sizeof(kSerializedEncryptedReport)))); |
329 ASSERT_TRUE(ErrorReporter::DecryptErrorReport( | 329 ASSERT_TRUE(ErrorReporter::DecryptErrorReport( |
330 server_private_key_, encrypted_request, &decrypted_serialized_report)); | 330 server_private_key_, encrypted_request, &decrypted_serialized_report)); |
331 } | 331 } |
332 | 332 |
333 } // namespace | 333 } // namespace |
334 | 334 |
335 } // namespace certificate_reporting | 335 } // namespace certificate_reporting |
OLD | NEW |