OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/core/quic_crypto_client_stream.h" | 5 #include "net/quic/core/quic_crypto_client_stream.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" | 9 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" |
10 #include "net/quic/core/crypto/quic_decrypter.h" | 10 #include "net/quic/core/crypto/quic_decrypter.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 QuicCryptoServerConfig crypto_config( | 245 QuicCryptoServerConfig crypto_config( |
246 QuicCryptoServerConfig::TESTING, QuicRandom::GetInstance(), | 246 QuicCryptoServerConfig::TESTING, QuicRandom::GetInstance(), |
247 crypto_test_utils::ProofSourceForTesting()); | 247 crypto_test_utils::ProofSourceForTesting()); |
248 crypto_test_utils::FakeServerOptions options; | 248 crypto_test_utils::FakeServerOptions options; |
249 crypto_test_utils::SetupCryptoServerConfigForTest( | 249 crypto_test_utils::SetupCryptoServerConfigForTest( |
250 connection_->clock(), QuicRandom::GetInstance(), &crypto_config, options); | 250 connection_->clock(), QuicRandom::GetInstance(), &crypto_config, options); |
251 SourceAddressTokens tokens; | 251 SourceAddressTokens tokens; |
252 QuicCompressedCertsCache cache(1); | 252 QuicCompressedCertsCache cache(1); |
253 CachedNetworkParameters network_params; | 253 CachedNetworkParameters network_params; |
254 CryptoHandshakeMessage server_config_update; | 254 CryptoHandshakeMessage server_config_update; |
255 EXPECT_TRUE(crypto_config.BuildServerConfigUpdateMessage( | 255 |
| 256 class Callback : public BuildServerConfigUpdateMessageResultCallback { |
| 257 public: |
| 258 Callback(bool* ok, CryptoHandshakeMessage* message) |
| 259 : ok_(ok), message_(message) {} |
| 260 void Run(bool ok, const CryptoHandshakeMessage& message) override { |
| 261 *ok_ = ok; |
| 262 *message_ = message; |
| 263 } |
| 264 |
| 265 private: |
| 266 bool* ok_; |
| 267 CryptoHandshakeMessage* message_; |
| 268 }; |
| 269 |
| 270 // Note: relies on the callback being invoked synchronously |
| 271 bool ok = false; |
| 272 crypto_config.BuildServerConfigUpdateMessage( |
256 session_->connection()->version(), stream()->chlo_hash(), tokens, | 273 session_->connection()->version(), stream()->chlo_hash(), tokens, |
257 QuicSocketAddress(QuicIpAddress::Loopback6(), 1234), | 274 QuicSocketAddress(QuicIpAddress::Loopback6(), 1234), |
258 QuicIpAddress::Loopback6(), connection_->clock(), | 275 QuicIpAddress::Loopback6(), connection_->clock(), |
259 QuicRandom::GetInstance(), &cache, stream()->crypto_negotiated_params(), | 276 QuicRandom::GetInstance(), &cache, stream()->crypto_negotiated_params(), |
260 &network_params, QuicTagVector(), &server_config_update)); | 277 &network_params, QuicTagVector(), |
| 278 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback>( |
| 279 new Callback(&ok, &server_config_update))); |
| 280 EXPECT_TRUE(ok); |
261 | 281 |
262 std::unique_ptr<QuicData> data( | 282 std::unique_ptr<QuicData> data( |
263 CryptoFramer::ConstructHandshakeMessage(server_config_update)); | 283 CryptoFramer::ConstructHandshakeMessage(server_config_update)); |
264 stream()->OnStreamFrame(QuicStreamFrame(kCryptoStreamId, /*fin=*/false, | 284 stream()->OnStreamFrame(QuicStreamFrame(kCryptoStreamId, /*fin=*/false, |
265 /*offset=*/0, data->AsStringPiece())); | 285 /*offset=*/0, data->AsStringPiece())); |
266 | 286 |
267 // Recreate connection with the new config and verify a 0-RTT attempt. | 287 // Recreate connection with the new config and verify a 0-RTT attempt. |
268 CreateConnection(); | 288 CreateConnection(); |
269 | 289 |
270 stream()->CryptoConnect(); | 290 stream()->CryptoConnect(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 client_state->GetNextServerDesignatedConnectionId(); | 446 client_state->GetNextServerDesignatedConnectionId(); |
427 QuicConnectionId expected_id = | 447 QuicConnectionId expected_id = |
428 server_session_->connection()->random_generator()->RandUint64(); | 448 server_session_->connection()->random_generator()->RandUint64(); |
429 EXPECT_EQ(expected_id, server_designated_id); | 449 EXPECT_EQ(expected_id, server_designated_id); |
430 EXPECT_FALSE(client_state->has_server_designated_connection_id()); | 450 EXPECT_FALSE(client_state->has_server_designated_connection_id()); |
431 } | 451 } |
432 | 452 |
433 } // namespace | 453 } // namespace |
434 } // namespace test | 454 } // namespace test |
435 } // namespace net | 455 } // namespace net |
OLD | NEW |