OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/quic/test_tools/fake_proof_source.h" | 5 #include "net/quic/test_tools/fake_proof_source.h" |
6 #include "net/quic/test_tools/crypto_test_utils.h" | 6 #include "net/quic/test_tools/crypto_test_utils.h" |
7 | 7 |
8 using std::string; | 8 using std::string; |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 namespace test { | 11 namespace test { |
12 | 12 |
13 FakeProofSource::FakeProofSource() | 13 FakeProofSource::FakeProofSource() |
14 : delegate_(CryptoTestUtils::ProofSourceForTesting()) {} | 14 : delegate_(CryptoTestUtils::ProofSourceForTesting()) {} |
15 | 15 |
16 FakeProofSource::~FakeProofSource() {} | 16 FakeProofSource::~FakeProofSource() {} |
17 | 17 |
18 FakeProofSource::Params::Params(const IPAddress& server_ip, | 18 FakeProofSource::Params::Params(const IPAddress& server_ip, |
19 std::string hostname, | 19 std::string hostname, |
20 std::string server_config, | 20 std::string server_config, |
21 QuicVersion quic_version, | 21 QuicVersion quic_version, |
22 std::string chlo_hash, | 22 std::string chlo_hash, |
| 23 const QuicTagVector& connection_options, |
23 std::unique_ptr<ProofSource::Callback> callback) | 24 std::unique_ptr<ProofSource::Callback> callback) |
24 : server_ip(server_ip), | 25 : server_ip(server_ip), |
25 hostname(hostname), | 26 hostname(hostname), |
26 server_config(server_config), | 27 server_config(server_config), |
27 quic_version(quic_version), | 28 quic_version(quic_version), |
28 chlo_hash(chlo_hash), | 29 chlo_hash(chlo_hash), |
| 30 connection_options(connection_options), |
29 callback(std::move(callback)) {} | 31 callback(std::move(callback)) {} |
30 | 32 |
31 FakeProofSource::Params::~Params() {} | 33 FakeProofSource::Params::~Params() {} |
32 | 34 |
33 FakeProofSource::Params::Params(FakeProofSource::Params&& other) = default; | 35 FakeProofSource::Params::Params(FakeProofSource::Params&& other) = default; |
34 | 36 |
35 FakeProofSource::Params& FakeProofSource::Params::operator=( | 37 FakeProofSource::Params& FakeProofSource::Params::operator=( |
36 FakeProofSource::Params&& other) = default; | 38 FakeProofSource::Params&& other) = default; |
37 | 39 |
38 void FakeProofSource::Activate() { | 40 void FakeProofSource::Activate() { |
39 active_ = true; | 41 active_ = true; |
40 } | 42 } |
41 | 43 |
42 bool FakeProofSource::GetProof(const IPAddress& server_ip, | 44 bool FakeProofSource::GetProof(const IPAddress& server_ip, |
43 const string& hostname, | 45 const string& hostname, |
44 const string& server_config, | 46 const string& server_config, |
45 QuicVersion quic_version, | 47 QuicVersion quic_version, |
46 StringPiece chlo_hash, | 48 StringPiece chlo_hash, |
| 49 const QuicTagVector& connection_options, |
47 scoped_refptr<ProofSource::Chain>* out_chain, | 50 scoped_refptr<ProofSource::Chain>* out_chain, |
48 string* out_signature, | 51 string* out_signature, |
49 string* out_leaf_cert_sct) { | 52 string* out_leaf_cert_sct) { |
50 LOG(WARNING) << "Synchronous GetProof called"; | 53 LOG(WARNING) << "Synchronous GetProof called"; |
51 return delegate_->GetProof(server_ip, hostname, server_config, quic_version, | 54 return delegate_->GetProof(server_ip, hostname, server_config, quic_version, |
52 chlo_hash, out_chain, out_signature, | 55 chlo_hash, connection_options, out_chain, |
53 out_leaf_cert_sct); | 56 out_signature, out_leaf_cert_sct); |
54 } | 57 } |
55 | 58 |
56 void FakeProofSource::GetProof( | 59 void FakeProofSource::GetProof( |
57 const IPAddress& server_ip, | 60 const IPAddress& server_ip, |
58 const string& hostname, | 61 const string& hostname, |
59 const string& server_config, | 62 const string& server_config, |
60 QuicVersion quic_version, | 63 QuicVersion quic_version, |
61 StringPiece chlo_hash, | 64 StringPiece chlo_hash, |
| 65 const QuicTagVector& connection_options, |
62 std::unique_ptr<ProofSource::Callback> callback) { | 66 std::unique_ptr<ProofSource::Callback> callback) { |
63 if (!active_) { | 67 if (!active_) { |
64 scoped_refptr<Chain> chain; | 68 scoped_refptr<Chain> chain; |
65 string signature; | 69 string signature; |
66 string leaf_cert_sct; | 70 string leaf_cert_sct; |
67 const bool ok = GetProof(server_ip, hostname, server_config, quic_version, | 71 const bool ok = |
68 chlo_hash, &chain, &signature, &leaf_cert_sct); | 72 GetProof(server_ip, hostname, server_config, quic_version, chlo_hash, |
| 73 connection_options, &chain, &signature, &leaf_cert_sct); |
69 callback->Run(ok, chain, signature, leaf_cert_sct, | 74 callback->Run(ok, chain, signature, leaf_cert_sct, |
70 /* details = */ nullptr); | 75 /* details = */ nullptr); |
71 return; | 76 return; |
72 } | 77 } |
73 | 78 |
74 LOG(WARNING) << "Asynchronous GetProof called"; | 79 LOG(WARNING) << "Asynchronous GetProof called"; |
75 params_.push_back(Params{server_ip, hostname, server_config, quic_version, | 80 params_.push_back(Params{server_ip, hostname, server_config, quic_version, |
76 chlo_hash.as_string(), std::move(callback)}); | 81 chlo_hash.as_string(), connection_options, |
| 82 std::move(callback)}); |
77 } | 83 } |
78 | 84 |
79 int FakeProofSource::NumPendingCallbacks() const { | 85 int FakeProofSource::NumPendingCallbacks() const { |
80 return params_.size(); | 86 return params_.size(); |
81 } | 87 } |
82 | 88 |
83 void FakeProofSource::InvokePendingCallback(int n) { | 89 void FakeProofSource::InvokePendingCallback(int n) { |
84 CHECK(NumPendingCallbacks() > n); | 90 CHECK(NumPendingCallbacks() > n); |
85 | 91 |
86 const Params& params = params_[n]; | 92 const Params& params = params_[n]; |
87 | 93 |
88 scoped_refptr<ProofSource::Chain> chain; | 94 scoped_refptr<ProofSource::Chain> chain; |
89 string signature; | 95 string signature; |
90 string leaf_cert_sct; | 96 string leaf_cert_sct; |
91 const bool ok = | 97 const bool ok = delegate_->GetProof( |
92 delegate_->GetProof(params.server_ip, params.hostname, | 98 params.server_ip, params.hostname, params.server_config, |
93 params.server_config, params.quic_version, | 99 params.quic_version, params.chlo_hash, params.connection_options, &chain, |
94 params.chlo_hash, &chain, &signature, &leaf_cert_sct); | 100 &signature, &leaf_cert_sct); |
95 | 101 |
96 params.callback->Run(ok, chain, signature, leaf_cert_sct, | 102 params.callback->Run(ok, chain, signature, leaf_cert_sct, |
97 /* details = */ nullptr); | 103 /* details = */ nullptr); |
98 auto it = params_.begin() + n; | 104 auto it = params_.begin() + n; |
99 params_.erase(it); | 105 params_.erase(it); |
100 } | 106 } |
101 | 107 |
102 } // namespace test | 108 } // namespace test |
103 } // namespace net | 109 } // namespace net |
OLD | NEW |