OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <ostream> | 5 #include <ostream> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "crypto/secure_hash.h" | 10 #include "crypto/secure_hash.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 supported_versions_ = QuicSupportedVersions(); | 85 supported_versions_ = QuicSupportedVersions(); |
86 client_version_ = QuicUtils::TagToString( | 86 client_version_ = QuicUtils::TagToString( |
87 QuicVersionToQuicTag(supported_versions_.front())); | 87 QuicVersionToQuicTag(supported_versions_.front())); |
88 | 88 |
89 FLAGS_use_early_return_when_verifying_chlo = | 89 FLAGS_use_early_return_when_verifying_chlo = |
90 GetParam().use_early_return_when_verifying_chlo; | 90 GetParam().use_early_return_when_verifying_chlo; |
91 FLAGS_send_quic_crypto_reject_reason = | 91 FLAGS_send_quic_crypto_reject_reason = |
92 GetParam().send_quic_crypto_reject_reason; | 92 GetParam().send_quic_crypto_reject_reason; |
93 } | 93 } |
94 | 94 |
95 virtual void SetUp() { | 95 void SetUp() override { |
96 scoped_ptr<CryptoHandshakeMessage> msg( | 96 scoped_ptr<CryptoHandshakeMessage> msg( |
97 config_.AddDefaultConfig(rand_, &clock_, | 97 config_.AddDefaultConfig(rand_, &clock_, |
98 config_options_)); | 98 config_options_)); |
99 | 99 |
100 StringPiece orbit; | 100 StringPiece orbit; |
101 CHECK(msg->GetStringPiece(kORBT, &orbit)); | 101 CHECK(msg->GetStringPiece(kORBT, &orbit)); |
102 CHECK_EQ(sizeof(orbit_), orbit.size()); | 102 CHECK_EQ(sizeof(orbit_), orbit.size()); |
103 memcpy(orbit_, orbit.data(), orbit.size()); | 103 memcpy(orbit_, orbit.data(), orbit.size()); |
104 | 104 |
105 char public_value[32]; | 105 char public_value[32]; |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 hash->Update(serialized.data(), serialized.length()); | 633 hash->Update(serialized.data(), serialized.length()); |
634 uint8 digest[16]; | 634 uint8 digest[16]; |
635 hash->Finish(digest, sizeof(digest)); | 635 hash->Finish(digest, sizeof(digest)); |
636 | 636 |
637 ASSERT_EQ(scid.size(), sizeof(digest)); | 637 ASSERT_EQ(scid.size(), sizeof(digest)); |
638 EXPECT_EQ(0, memcmp(digest, scid_str.data(), sizeof(digest))); | 638 EXPECT_EQ(0, memcmp(digest, scid_str.data(), sizeof(digest))); |
639 } | 639 } |
640 | 640 |
641 class CryptoServerTestNoConfig : public CryptoServerTest { | 641 class CryptoServerTestNoConfig : public CryptoServerTest { |
642 public: | 642 public: |
643 virtual void SetUp() { | 643 void SetUp() override { |
644 // Deliberately don't add a config so that we can test this situation. | 644 // Deliberately don't add a config so that we can test this situation. |
645 } | 645 } |
646 }; | 646 }; |
647 | 647 |
648 TEST_P(CryptoServerTestNoConfig, DontCrash) { | 648 TEST_P(CryptoServerTestNoConfig, DontCrash) { |
649 ShouldFailMentioning("No config", InchoateClientHello( | 649 ShouldFailMentioning("No config", InchoateClientHello( |
650 "CHLO", | 650 "CHLO", |
651 "VER\0", client_version_.data(), | 651 "VER\0", client_version_.data(), |
652 nullptr)); | 652 nullptr)); |
653 | 653 |
654 const HandshakeFailureReason kRejectReasons[] = { | 654 const HandshakeFailureReason kRejectReasons[] = { |
655 SERVER_CONFIG_INCHOATE_HELLO_FAILURE | 655 SERVER_CONFIG_INCHOATE_HELLO_FAILURE |
656 }; | 656 }; |
657 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 657 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
658 } | 658 } |
659 | 659 |
660 class AsyncStrikeServerVerificationTest : public CryptoServerTest { | 660 class AsyncStrikeServerVerificationTest : public CryptoServerTest { |
661 protected: | 661 protected: |
662 AsyncStrikeServerVerificationTest() { | 662 AsyncStrikeServerVerificationTest() { |
663 } | 663 } |
664 | 664 |
665 virtual void SetUp() { | 665 void SetUp() override { |
666 const string kOrbit = "12345678"; | 666 const string kOrbit = "12345678"; |
667 config_options_.orbit = kOrbit; | 667 config_options_.orbit = kOrbit; |
668 strike_register_client_ = new DelayedVerifyStrikeRegisterClient( | 668 strike_register_client_ = new DelayedVerifyStrikeRegisterClient( |
669 10000, // strike_register_max_entries | 669 10000, // strike_register_max_entries |
670 static_cast<uint32>(clock_.WallNow().ToUNIXSeconds()), | 670 static_cast<uint32>(clock_.WallNow().ToUNIXSeconds()), |
671 60, // strike_register_window_secs | 671 60, // strike_register_window_secs |
672 reinterpret_cast<const uint8 *>(kOrbit.data()), | 672 reinterpret_cast<const uint8 *>(kOrbit.data()), |
673 StrikeRegister::NO_STARTUP_PERIOD_NEEDED); | 673 StrikeRegister::NO_STARTUP_PERIOD_NEEDED); |
674 config_.SetStrikeRegisterClient(strike_register_client_); | 674 config_.SetStrikeRegisterClient(strike_register_client_); |
675 CryptoServerTest::SetUp(); | 675 CryptoServerTest::SetUp(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 | 718 |
719 strike_register_client_->RunPendingVerifications(); | 719 strike_register_client_->RunPendingVerifications(); |
720 ASSERT_TRUE(called); | 720 ASSERT_TRUE(called); |
721 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); | 721 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); |
722 // The message should be rejected now. | 722 // The message should be rejected now. |
723 EXPECT_EQ(kREJ, out_.tag()); | 723 EXPECT_EQ(kREJ, out_.tag()); |
724 } | 724 } |
725 | 725 |
726 } // namespace test | 726 } // namespace test |
727 } // namespace net | 727 } // namespace net |
OLD | NEW |