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/test_tools/crypto_test_utils.h" | 5 #include "net/quic/test_tools/crypto_test_utils.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "net/quic/core/crypto/channel_id.h" | 9 #include "net/quic/core/crypto/channel_id.h" |
10 #include "net/quic/core/crypto/common_cert_set.h" | 10 #include "net/quic/core/crypto/common_cert_set.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 &crypto_config, options); | 396 &crypto_config, options); |
397 | 397 |
398 TestQuicSpdyServerSession server_session(server_conn, *server_quic_config, | 398 TestQuicSpdyServerSession server_session(server_conn, *server_quic_config, |
399 &crypto_config, | 399 &crypto_config, |
400 &compressed_certs_cache); | 400 &compressed_certs_cache); |
401 | 401 |
402 // The client's handshake must have been started already. | 402 // The client's handshake must have been started already. |
403 CHECK_NE(0u, client_conn->encrypted_packets_.size()); | 403 CHECK_NE(0u, client_conn->encrypted_packets_.size()); |
404 | 404 |
405 CommunicateHandshakeMessages(client_conn, client, server_conn, | 405 CommunicateHandshakeMessages(client_conn, client, server_conn, |
406 server_session.GetCryptoStream()); | 406 server_session.GetMutableCryptoStream()); |
407 CompareClientAndServerKeys(client, server_session.GetCryptoStream()); | 407 CompareClientAndServerKeys(client, server_session.GetMutableCryptoStream()); |
408 | 408 |
409 return client->num_sent_client_hellos(); | 409 return client->num_sent_client_hellos(); |
410 } | 410 } |
411 | 411 |
412 int HandshakeWithFakeClient(MockQuicConnectionHelper* helper, | 412 int HandshakeWithFakeClient(MockQuicConnectionHelper* helper, |
413 MockAlarmFactory* alarm_factory, | 413 MockAlarmFactory* alarm_factory, |
414 PacketSavingConnection* server_conn, | 414 PacketSavingConnection* server_conn, |
415 QuicCryptoServerStream* server, | 415 QuicCryptoServerStream* server, |
416 const QuicServerId& server_id, | 416 const QuicServerId& server_id, |
417 const FakeClientOptions& options) { | 417 const FakeClientOptions& options) { |
(...skipping 13 matching lines...) Expand all Loading... |
431 crypto_config.SetChannelIDSource(source); | 431 crypto_config.SetChannelIDSource(source); |
432 } | 432 } |
433 if (!options.token_binding_params.empty()) { | 433 if (!options.token_binding_params.empty()) { |
434 crypto_config.tb_key_params = options.token_binding_params; | 434 crypto_config.tb_key_params = options.token_binding_params; |
435 } | 435 } |
436 TestQuicSpdyClientSession client_session(client_conn, DefaultQuicConfig(), | 436 TestQuicSpdyClientSession client_session(client_conn, DefaultQuicConfig(), |
437 server_id, &crypto_config); | 437 server_id, &crypto_config); |
438 | 438 |
439 EXPECT_CALL(client_session, OnProofValid(testing::_)) | 439 EXPECT_CALL(client_session, OnProofValid(testing::_)) |
440 .Times(testing::AnyNumber()); | 440 .Times(testing::AnyNumber()); |
441 client_session.GetCryptoStream()->CryptoConnect(); | 441 client_session.GetMutableCryptoStream()->CryptoConnect(); |
442 CHECK_EQ(1u, client_conn->encrypted_packets_.size()); | 442 CHECK_EQ(1u, client_conn->encrypted_packets_.size()); |
443 | 443 |
444 CommunicateHandshakeMessagesAndRunCallbacks( | 444 CommunicateHandshakeMessagesAndRunCallbacks( |
445 client_conn, client_session.GetCryptoStream(), server_conn, server, | 445 client_conn, client_session.GetMutableCryptoStream(), server_conn, server, |
446 async_channel_id_source); | 446 async_channel_id_source); |
447 | 447 |
448 if (server->handshake_confirmed() && server->encryption_established()) { | 448 if (server->handshake_confirmed() && server->encryption_established()) { |
449 CompareClientAndServerKeys(client_session.GetCryptoStream(), server); | 449 CompareClientAndServerKeys(client_session.GetMutableCryptoStream(), server); |
450 | 450 |
451 if (options.channel_id_enabled) { | 451 if (options.channel_id_enabled) { |
452 std::unique_ptr<ChannelIDKey> channel_id_key; | 452 std::unique_ptr<ChannelIDKey> channel_id_key; |
453 QuicAsyncStatus status = | 453 QuicAsyncStatus status = |
454 crypto_config.channel_id_source()->GetChannelIDKey( | 454 crypto_config.channel_id_source()->GetChannelIDKey( |
455 server_id.host(), &channel_id_key, nullptr); | 455 server_id.host(), &channel_id_key, nullptr); |
456 EXPECT_EQ(QUIC_SUCCESS, status); | 456 EXPECT_EQ(QUIC_SUCCESS, status); |
457 EXPECT_EQ(channel_id_key->SerializeKey(), | 457 EXPECT_EQ(channel_id_key->SerializeKey(), |
458 server->crypto_negotiated_params().channel_id); | 458 server->crypto_negotiated_params().channel_id); |
459 EXPECT_EQ( | 459 EXPECT_EQ( |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 FullChloGenerator generator(crypto_config, server_addr, client_addr, clock, | 980 FullChloGenerator generator(crypto_config, server_addr, client_addr, clock, |
981 proof, compressed_certs_cache, out); | 981 proof, compressed_certs_cache, out); |
982 crypto_config->ValidateClientHello( | 982 crypto_config->ValidateClientHello( |
983 inchoate_chlo, client_addr.host(), server_addr, version, clock, proof, | 983 inchoate_chlo, client_addr.host(), server_addr, version, clock, proof, |
984 generator.GetValidateClientHelloCallback()); | 984 generator.GetValidateClientHelloCallback()); |
985 } | 985 } |
986 | 986 |
987 } // namespace crypto_test_utils | 987 } // namespace crypto_test_utils |
988 } // namespace test | 988 } // namespace test |
989 } // namespace net | 989 } // namespace net |
OLD | NEW |