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_server_stream.h" | 5 #include "net/quic/core/quic_crypto_server_stream.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" | 12 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" |
13 #include "net/quic/core/crypto/crypto_framer.h" | 13 #include "net/quic/core/crypto/crypto_framer.h" |
14 #include "net/quic/core/crypto/crypto_handshake.h" | 14 #include "net/quic/core/crypto/crypto_handshake.h" |
15 #include "net/quic/core/crypto/crypto_protocol.h" | 15 #include "net/quic/core/crypto/crypto_protocol.h" |
16 #include "net/quic/core/crypto/crypto_utils.h" | 16 #include "net/quic/core/crypto/crypto_utils.h" |
17 #include "net/quic/core/crypto/quic_crypto_server_config.h" | 17 #include "net/quic/core/crypto/quic_crypto_server_config.h" |
18 #include "net/quic/core/crypto/quic_decrypter.h" | 18 #include "net/quic/core/crypto/quic_decrypter.h" |
19 #include "net/quic/core/crypto/quic_encrypter.h" | 19 #include "net/quic/core/crypto/quic_encrypter.h" |
20 #include "net/quic/core/crypto/quic_random.h" | 20 #include "net/quic/core/crypto/quic_random.h" |
21 #include "net/quic/core/quic_crypto_client_stream.h" | 21 #include "net/quic/core/quic_crypto_client_stream.h" |
22 #include "net/quic/core/quic_flags.h" | 22 #include "net/quic/core/quic_flags.h" |
23 #include "net/quic/core/quic_packets.h" | 23 #include "net/quic/core/quic_packets.h" |
24 #include "net/quic/core/quic_session.h" | 24 #include "net/quic/core/quic_session.h" |
25 #include "net/quic/platform/api/quic_socket_address.h" | 25 #include "net/quic/platform/api/quic_socket_address.h" |
26 #include "net/quic/test_tools/crypto_test_utils.h" | 26 #include "net/quic/test_tools/crypto_test_utils.h" |
| 27 #include "net/quic/test_tools/failing_proof_source.h" |
27 #include "net/quic/test_tools/quic_crypto_server_config_peer.h" | 28 #include "net/quic/test_tools/quic_crypto_server_config_peer.h" |
28 #include "net/quic/test_tools/quic_test_utils.h" | 29 #include "net/quic/test_tools/quic_test_utils.h" |
29 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
31 | 32 |
32 namespace net { | 33 namespace net { |
33 class QuicConnection; | 34 class QuicConnection; |
34 class QuicStream; | 35 class QuicStream; |
35 } // namespace net | 36 } // namespace net |
36 | 37 |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 TEST_P(QuicCryptoServerStreamTest, NoTokenBindingWithoutClientSupport) { | 477 TEST_P(QuicCryptoServerStreamTest, NoTokenBindingWithoutClientSupport) { |
477 Initialize(); | 478 Initialize(); |
478 | 479 |
479 CompleteCryptoHandshake(); | 480 CompleteCryptoHandshake(); |
480 EXPECT_EQ( | 481 EXPECT_EQ( |
481 0u, server_stream()->crypto_negotiated_params().token_binding_key_param); | 482 0u, server_stream()->crypto_negotiated_params().token_binding_key_param); |
482 EXPECT_TRUE(server_stream()->encryption_established()); | 483 EXPECT_TRUE(server_stream()->encryption_established()); |
483 EXPECT_TRUE(server_stream()->handshake_confirmed()); | 484 EXPECT_TRUE(server_stream()->handshake_confirmed()); |
484 } | 485 } |
485 | 486 |
486 class FailingProofSource : public ProofSource { | |
487 public: | |
488 bool GetProof(const QuicSocketAddress& server_address, | |
489 const string& hostname, | |
490 const string& server_config, | |
491 QuicVersion quic_version, | |
492 StringPiece chlo_hash, | |
493 const QuicTagVector& connection_options, | |
494 QuicReferenceCountedPointer<ProofSource::Chain>* out_chain, | |
495 QuicCryptoProof* out_proof) override { | |
496 return false; | |
497 } | |
498 | |
499 void GetProof(const QuicSocketAddress& server_address, | |
500 const string& hostname, | |
501 const string& server_config, | |
502 QuicVersion quic_version, | |
503 StringPiece chlo_hash, | |
504 const QuicTagVector& connection_options, | |
505 std::unique_ptr<Callback> callback) override { | |
506 callback->Run(false, nullptr, QuicCryptoProof(), nullptr); | |
507 } | |
508 }; | |
509 | |
510 class QuicCryptoServerStreamTestWithFailingProofSource | 487 class QuicCryptoServerStreamTestWithFailingProofSource |
511 : public QuicCryptoServerStreamTest { | 488 : public QuicCryptoServerStreamTest { |
512 public: | 489 public: |
513 QuicCryptoServerStreamTestWithFailingProofSource() | 490 QuicCryptoServerStreamTestWithFailingProofSource() |
514 : QuicCryptoServerStreamTest( | 491 : QuicCryptoServerStreamTest( |
515 std::unique_ptr<FailingProofSource>(new FailingProofSource)) {} | 492 std::unique_ptr<FailingProofSource>(new FailingProofSource)) {} |
516 }; | 493 }; |
517 | 494 |
518 INSTANTIATE_TEST_CASE_P(MoreTests, | 495 INSTANTIATE_TEST_CASE_P(MoreTests, |
519 QuicCryptoServerStreamTestWithFailingProofSource, | 496 QuicCryptoServerStreamTestWithFailingProofSource, |
520 testing::Bool()); | 497 testing::Bool()); |
521 | 498 |
522 TEST_P(QuicCryptoServerStreamTestWithFailingProofSource, Test) { | 499 TEST_P(QuicCryptoServerStreamTestWithFailingProofSource, Test) { |
523 Initialize(); | 500 Initialize(); |
524 InitializeFakeClient(/* supports_stateless_rejects= */ false); | 501 InitializeFakeClient(/* supports_stateless_rejects= */ false); |
525 | 502 |
526 // Regression test for b/31521252, in which a crash would happen here. | 503 // Regression test for b/31521252, in which a crash would happen here. |
527 AdvanceHandshakeWithFakeClient(); | 504 AdvanceHandshakeWithFakeClient(); |
528 EXPECT_FALSE(server_stream()->encryption_established()); | 505 EXPECT_FALSE(server_stream()->encryption_established()); |
529 EXPECT_FALSE(server_stream()->handshake_confirmed()); | 506 EXPECT_FALSE(server_stream()->handshake_confirmed()); |
530 } | 507 } |
531 | 508 |
532 } // namespace | 509 } // namespace |
533 | 510 |
534 } // namespace test | 511 } // namespace test |
535 } // namespace net | 512 } // namespace net |
OLD | NEW |