| 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 { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 active_ = true; | 41 active_ = true; |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool FakeProofSource::GetProof(const IPAddress& server_ip, | 44 bool FakeProofSource::GetProof(const IPAddress& server_ip, |
| 45 const string& hostname, | 45 const string& hostname, |
| 46 const string& server_config, | 46 const string& server_config, |
| 47 QuicVersion quic_version, | 47 QuicVersion quic_version, |
| 48 StringPiece chlo_hash, | 48 StringPiece chlo_hash, |
| 49 const QuicTagVector& connection_options, | 49 const QuicTagVector& connection_options, |
| 50 scoped_refptr<ProofSource::Chain>* out_chain, | 50 scoped_refptr<ProofSource::Chain>* out_chain, |
| 51 string* out_signature, | 51 QuicCryptoProof* out_proof) { |
| 52 string* out_leaf_cert_sct) { | |
| 53 LOG(WARNING) << "Synchronous GetProof called"; | 52 LOG(WARNING) << "Synchronous GetProof called"; |
| 54 return delegate_->GetProof(server_ip, hostname, server_config, quic_version, | 53 return delegate_->GetProof(server_ip, hostname, server_config, quic_version, |
| 55 chlo_hash, connection_options, out_chain, | 54 chlo_hash, connection_options, out_chain, |
| 56 out_signature, out_leaf_cert_sct); | 55 out_proof); |
| 57 } | 56 } |
| 58 | 57 |
| 59 void FakeProofSource::GetProof( | 58 void FakeProofSource::GetProof( |
| 60 const IPAddress& server_ip, | 59 const IPAddress& server_ip, |
| 61 const string& hostname, | 60 const string& hostname, |
| 62 const string& server_config, | 61 const string& server_config, |
| 63 QuicVersion quic_version, | 62 QuicVersion quic_version, |
| 64 StringPiece chlo_hash, | 63 StringPiece chlo_hash, |
| 65 const QuicTagVector& connection_options, | 64 const QuicTagVector& connection_options, |
| 66 std::unique_ptr<ProofSource::Callback> callback) { | 65 std::unique_ptr<ProofSource::Callback> callback) { |
| 67 if (!active_) { | 66 if (!active_) { |
| 68 scoped_refptr<Chain> chain; | 67 scoped_refptr<Chain> chain; |
| 69 string signature; | 68 QuicCryptoProof proof; |
| 70 string leaf_cert_sct; | 69 const bool ok = GetProof(server_ip, hostname, server_config, quic_version, |
| 71 const bool ok = | 70 chlo_hash, connection_options, &chain, &proof); |
| 72 GetProof(server_ip, hostname, server_config, quic_version, chlo_hash, | 71 callback->Run(ok, chain, proof, /* details = */ nullptr); |
| 73 connection_options, &chain, &signature, &leaf_cert_sct); | |
| 74 callback->Run(ok, chain, signature, leaf_cert_sct, | |
| 75 /* details = */ nullptr); | |
| 76 return; | 72 return; |
| 77 } | 73 } |
| 78 | 74 |
| 79 LOG(WARNING) << "Asynchronous GetProof called"; | 75 LOG(WARNING) << "Asynchronous GetProof called"; |
| 80 params_.push_back(Params{server_ip, hostname, server_config, quic_version, | 76 params_.push_back(Params{server_ip, hostname, server_config, quic_version, |
| 81 chlo_hash.as_string(), connection_options, | 77 chlo_hash.as_string(), connection_options, |
| 82 std::move(callback)}); | 78 std::move(callback)}); |
| 83 } | 79 } |
| 84 | 80 |
| 85 int FakeProofSource::NumPendingCallbacks() const { | 81 int FakeProofSource::NumPendingCallbacks() const { |
| 86 return params_.size(); | 82 return params_.size(); |
| 87 } | 83 } |
| 88 | 84 |
| 89 void FakeProofSource::InvokePendingCallback(int n) { | 85 void FakeProofSource::InvokePendingCallback(int n) { |
| 90 CHECK(NumPendingCallbacks() > n); | 86 CHECK(NumPendingCallbacks() > n); |
| 91 | 87 |
| 92 const Params& params = params_[n]; | 88 const Params& params = params_[n]; |
| 93 | 89 |
| 94 scoped_refptr<ProofSource::Chain> chain; | 90 scoped_refptr<ProofSource::Chain> chain; |
| 95 string signature; | 91 QuicCryptoProof proof; |
| 96 string leaf_cert_sct; | |
| 97 const bool ok = delegate_->GetProof( | 92 const bool ok = delegate_->GetProof( |
| 98 params.server_ip, params.hostname, params.server_config, | 93 params.server_ip, params.hostname, params.server_config, |
| 99 params.quic_version, params.chlo_hash, params.connection_options, &chain, | 94 params.quic_version, params.chlo_hash, params.connection_options, &chain, |
| 100 &signature, &leaf_cert_sct); | 95 &proof); |
| 101 | 96 |
| 102 params.callback->Run(ok, chain, signature, leaf_cert_sct, | 97 params.callback->Run(ok, chain, proof, /* details = */ nullptr); |
| 103 /* details = */ nullptr); | |
| 104 auto it = params_.begin() + n; | 98 auto it = params_.begin() + n; |
| 105 params_.erase(it); | 99 params_.erase(it); |
| 106 } | 100 } |
| 107 | 101 |
| 108 } // namespace test | 102 } // namespace test |
| 109 } // namespace net | 103 } // namespace net |
| OLD | NEW |