| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <cstdint> | 6 #include <cstdint> |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 compressed_certs_cache_( | 112 compressed_certs_cache_( |
| 113 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize), | 113 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize), |
| 114 params_(new QuicCryptoNegotiatedParameters), | 114 params_(new QuicCryptoNegotiatedParameters), |
| 115 signed_config_(new QuicSignedServerConfig), | 115 signed_config_(new QuicSignedServerConfig), |
| 116 chlo_packet_size_(kDefaultMaxPacketSize) { | 116 chlo_packet_size_(kDefaultMaxPacketSize) { |
| 117 supported_versions_ = GetParam().supported_versions; | 117 supported_versions_ = GetParam().supported_versions; |
| 118 config_.set_enable_serving_sct(true); | 118 config_.set_enable_serving_sct(true); |
| 119 | 119 |
| 120 client_version_ = supported_versions_.front(); | 120 client_version_ = supported_versions_.front(); |
| 121 client_version_string_ = | 121 client_version_string_ = |
| 122 QuicUtils::TagToString(QuicVersionToQuicTag(client_version_)); | 122 QuicTagToString(QuicVersionToQuicTag(client_version_)); |
| 123 | 123 |
| 124 FLAGS_quic_require_handshake_confirmation_pre33 = false; | 124 FLAGS_quic_require_handshake_confirmation_pre33 = false; |
| 125 FLAGS_enable_quic_stateless_reject_support = | 125 FLAGS_enable_quic_stateless_reject_support = |
| 126 GetParam().enable_stateless_rejects; | 126 GetParam().enable_stateless_rejects; |
| 127 use_stateless_rejects_ = GetParam().use_stateless_rejects; | 127 use_stateless_rejects_ = GetParam().use_stateless_rejects; |
| 128 } | 128 } |
| 129 | 129 |
| 130 void SetUp() override { | 130 void SetUp() override { |
| 131 QuicCryptoServerConfig::ConfigOptions old_config_options; | 131 QuicCryptoServerConfig::ConfigOptions old_config_options; |
| 132 old_config_options.id = kOldConfigId; | 132 old_config_options.id = kOldConfigId; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 ASSERT_EQ(QUIC_NO_ERROR, | 374 ASSERT_EQ(QUIC_NO_ERROR, |
| 375 out_.GetUint64(kRCID, &server_designated_connection_id)); | 375 out_.GetUint64(kRCID, &server_designated_connection_id)); |
| 376 EXPECT_EQ(rand_for_id_generation_.RandUint64(), | 376 EXPECT_EQ(rand_for_id_generation_.RandUint64(), |
| 377 server_designated_connection_id); | 377 server_designated_connection_id); |
| 378 } | 378 } |
| 379 rand_for_id_generation_.ChangeValue(); | 379 rand_for_id_generation_.ChangeValue(); |
| 380 } | 380 } |
| 381 | 381 |
| 382 void CheckRejectTag() { | 382 void CheckRejectTag() { |
| 383 if (RejectsAreStateless()) { | 383 if (RejectsAreStateless()) { |
| 384 ASSERT_EQ(kSREJ, out_.tag()) << QuicUtils::TagToString(out_.tag()); | 384 ASSERT_EQ(kSREJ, out_.tag()) << QuicTagToString(out_.tag()); |
| 385 } else { | 385 } else { |
| 386 ASSERT_EQ(kREJ, out_.tag()) << QuicUtils::TagToString(out_.tag()); | 386 ASSERT_EQ(kREJ, out_.tag()) << QuicTagToString(out_.tag()); |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 390 bool RejectsAreStateless() { | 390 bool RejectsAreStateless() { |
| 391 return GetParam().enable_stateless_rejects && | 391 return GetParam().enable_stateless_rejects && |
| 392 GetParam().use_stateless_rejects; | 392 GetParam().use_stateless_rejects; |
| 393 } | 393 } |
| 394 | 394 |
| 395 string XlctHexString() { | 395 string XlctHexString() { |
| 396 uint64_t xlct = CryptoTestUtils::LeafCertHashForTesting(); | 396 uint64_t xlct = CryptoTestUtils::LeafCertHashForTesting(); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 } | 711 } |
| 712 | 712 |
| 713 TEST_P(CryptoServerTest, DowngradeAttack) { | 713 TEST_P(CryptoServerTest, DowngradeAttack) { |
| 714 if (supported_versions_.size() == 1) { | 714 if (supported_versions_.size() == 1) { |
| 715 // No downgrade attack is possible if the server only supports one version. | 715 // No downgrade attack is possible if the server only supports one version. |
| 716 return; | 716 return; |
| 717 } | 717 } |
| 718 // Set the client's preferred version to a supported version that | 718 // Set the client's preferred version to a supported version that |
| 719 // is not the "current" version (supported_versions_.front()). | 719 // is not the "current" version (supported_versions_.front()). |
| 720 string bad_version = | 720 string bad_version = |
| 721 QuicUtils::TagToString(QuicVersionToQuicTag(supported_versions_.back())); | 721 QuicTagToString(QuicVersionToQuicTag(supported_versions_.back())); |
| 722 | 722 |
| 723 // clang-format off | 723 // clang-format off |
| 724 CryptoHandshakeMessage msg = CryptoTestUtils::Message( | 724 CryptoHandshakeMessage msg = CryptoTestUtils::Message( |
| 725 "CHLO", | 725 "CHLO", |
| 726 "PDMD", "X509", | 726 "PDMD", "X509", |
| 727 "VER\0", bad_version.c_str(), | 727 "VER\0", bad_version.c_str(), |
| 728 "$padding", static_cast<int>(kClientHelloMinimumSize), | 728 "$padding", static_cast<int>(kClientHelloMinimumSize), |
| 729 nullptr); | 729 nullptr); |
| 730 // clang-format on | 730 // clang-format on |
| 731 ShouldFailMentioning("Downgrade", msg); | 731 ShouldFailMentioning("Downgrade", msg); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 const HandshakeFailureReason kRejectReasons[] = { | 1100 const HandshakeFailureReason kRejectReasons[] = { |
| 1101 SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; | 1101 SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; |
| 1102 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); | 1102 CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); |
| 1103 } | 1103 } |
| 1104 | 1104 |
| 1105 class CryptoServerTestOldVersion : public CryptoServerTest { | 1105 class CryptoServerTestOldVersion : public CryptoServerTest { |
| 1106 public: | 1106 public: |
| 1107 void SetUp() override { | 1107 void SetUp() override { |
| 1108 client_version_ = supported_versions_.back(); | 1108 client_version_ = supported_versions_.back(); |
| 1109 client_version_string_ = | 1109 client_version_string_ = |
| 1110 QuicUtils::TagToString(QuicVersionToQuicTag(client_version_)); | 1110 QuicTagToString(QuicVersionToQuicTag(client_version_)); |
| 1111 CryptoServerTest::SetUp(); | 1111 CryptoServerTest::SetUp(); |
| 1112 } | 1112 } |
| 1113 }; | 1113 }; |
| 1114 | 1114 |
| 1115 TEST_P(CryptoServerTestOldVersion, ServerIgnoresXlct) { | 1115 TEST_P(CryptoServerTestOldVersion, ServerIgnoresXlct) { |
| 1116 // clang-format off | 1116 // clang-format off |
| 1117 CryptoHandshakeMessage msg = CryptoTestUtils::Message( | 1117 CryptoHandshakeMessage msg = CryptoTestUtils::Message( |
| 1118 "CHLO", | 1118 "CHLO", |
| 1119 "PDMD", "X509", | 1119 "PDMD", "X509", |
| 1120 "AEAD", "AESG", | 1120 "AEAD", "AESG", |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 // clang-format on | 1257 // clang-format on |
| 1258 | 1258 |
| 1259 ShouldSucceed(msg); | 1259 ShouldSucceed(msg); |
| 1260 | 1260 |
| 1261 ASSERT_EQ(kSHLO, out_.tag()); | 1261 ASSERT_EQ(kSHLO, out_.tag()); |
| 1262 CheckServerHello(out_); | 1262 CheckServerHello(out_); |
| 1263 } | 1263 } |
| 1264 | 1264 |
| 1265 } // namespace test | 1265 } // namespace test |
| 1266 } // namespace net | 1266 } // namespace net |
| OLD | NEW |