Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1022)

Side by Side Diff: net/quic/crypto/crypto_server_test.cc

Issue 1397983007: relnote: remove insecure QUIC support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rch_insecure_quic
Patch Set: Compile fix Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 } 88 }
89 return params; 89 return params;
90 } 90 }
91 91
92 class CryptoServerTest : public ::testing::TestWithParam<TestParams> { 92 class CryptoServerTest : public ::testing::TestWithParam<TestParams> {
93 public: 93 public:
94 CryptoServerTest() 94 CryptoServerTest()
95 : rand_(QuicRandom::GetInstance()), 95 : rand_(QuicRandom::GetInstance()),
96 client_address_(Loopback4(), 1234), 96 client_address_(Loopback4(), 1234),
97 config_(QuicCryptoServerConfig::TESTING, rand_) { 97 config_(QuicCryptoServerConfig::TESTING,
98 #if defined(USE_OPENSSL) 98 rand_,
99 config_.SetProofSource(CryptoTestUtils::ProofSourceForTesting()); 99 CryptoTestUtils::ProofSourceForTesting()) {
100 #else
101 config_.SetProofSource(CryptoTestUtils::FakeProofSourceForTesting());
102 #endif
103 supported_versions_ = QuicSupportedVersions(); 100 supported_versions_ = QuicSupportedVersions();
104 client_version_ = supported_versions_.front(); 101 client_version_ = supported_versions_.front();
105 client_version_string_ = 102 client_version_string_ =
106 QuicUtils::TagToString(QuicVersionToQuicTag(client_version_)); 103 QuicUtils::TagToString(QuicVersionToQuicTag(client_version_));
107 104
108 FLAGS_use_early_return_when_verifying_chlo = 105 FLAGS_use_early_return_when_verifying_chlo =
109 GetParam().use_early_return_when_verifying_chlo; 106 GetParam().use_early_return_when_verifying_chlo;
110 FLAGS_enable_quic_stateless_reject_support = 107 FLAGS_enable_quic_stateless_reject_support =
111 GetParam().enable_stateless_rejects; 108 GetParam().enable_stateless_rejects;
112 use_stateless_rejects_ = GetParam().use_stateless_rejects; 109 use_stateless_rejects_ = GetParam().use_stateless_rejects;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 324
328 bool RejectsAreStateless() { 325 bool RejectsAreStateless() {
329 return GetParam().enable_stateless_rejects && 326 return GetParam().enable_stateless_rejects &&
330 GetParam().use_stateless_rejects; 327 GetParam().use_stateless_rejects;
331 } 328 }
332 329
333 string XlctHexString() { 330 string XlctHexString() {
334 const vector<string>* certs; 331 const vector<string>* certs;
335 IPAddressNumber server_ip; 332 IPAddressNumber server_ip;
336 string sig; 333 string sig;
337 #if defined(USE_OPENSSL)
338 scoped_ptr<ProofSource> proof_source( 334 scoped_ptr<ProofSource> proof_source(
339 CryptoTestUtils::ProofSourceForTesting()); 335 CryptoTestUtils::ProofSourceForTesting());
340 #else
341 scoped_ptr<ProofSource> proof_source(
342 CryptoTestUtils::FakeProofSourceForTesting());
343 #endif
344 if (!proof_source->GetProof(server_ip, "", "", false, &certs, &sig) || 336 if (!proof_source->GetProof(server_ip, "", "", false, &certs, &sig) ||
345 certs->empty()) { 337 certs->empty()) {
346 return "#0100000000000000"; 338 return "#0100000000000000";
347 } 339 }
348 340
349 std::ostringstream xlct_stream; 341 std::ostringstream xlct_stream;
350 uint64 xlct = 342 uint64 xlct =
351 QuicUtils::FNV1a_64_Hash(certs->at(0).c_str(), certs->at(0).length()); 343 QuicUtils::FNV1a_64_Hash(certs->at(0).c_str(), certs->at(0).length());
352 return "#" + base::HexEncode(reinterpret_cast<char*>(&xlct), sizeof(xlct)); 344 return "#" + base::HexEncode(reinterpret_cast<char*>(&xlct), sizeof(xlct));
353 } 345 }
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 } 737 }
746 738
747 TEST(CryptoServerConfigGenerationTest, Determinism) { 739 TEST(CryptoServerConfigGenerationTest, Determinism) {
748 // Test that using a deterministic PRNG causes the server-config to be 740 // Test that using a deterministic PRNG causes the server-config to be
749 // deterministic. 741 // deterministic.
750 742
751 MockRandom rand_a, rand_b; 743 MockRandom rand_a, rand_b;
752 const QuicCryptoServerConfig::ConfigOptions options; 744 const QuicCryptoServerConfig::ConfigOptions options;
753 MockClock clock; 745 MockClock clock;
754 746
755 QuicCryptoServerConfig a(QuicCryptoServerConfig::TESTING, &rand_a); 747 QuicCryptoServerConfig a(QuicCryptoServerConfig::TESTING, &rand_a,
756 QuicCryptoServerConfig b(QuicCryptoServerConfig::TESTING, &rand_b); 748 CryptoTestUtils::ProofSourceForTesting());
749 QuicCryptoServerConfig b(QuicCryptoServerConfig::TESTING, &rand_b,
750 CryptoTestUtils::ProofSourceForTesting());
757 scoped_ptr<CryptoHandshakeMessage> scfg_a( 751 scoped_ptr<CryptoHandshakeMessage> scfg_a(
758 a.AddDefaultConfig(&rand_a, &clock, options)); 752 a.AddDefaultConfig(&rand_a, &clock, options));
759 scoped_ptr<CryptoHandshakeMessage> scfg_b( 753 scoped_ptr<CryptoHandshakeMessage> scfg_b(
760 b.AddDefaultConfig(&rand_b, &clock, options)); 754 b.AddDefaultConfig(&rand_b, &clock, options));
761 755
762 ASSERT_EQ(scfg_a->DebugString(), scfg_b->DebugString()); 756 ASSERT_EQ(scfg_a->DebugString(), scfg_b->DebugString());
763 } 757 }
764 758
765 TEST(CryptoServerConfigGenerationTest, SCIDVaries) { 759 TEST(CryptoServerConfigGenerationTest, SCIDVaries) {
766 // This test ensures that the server config ID varies for different server 760 // This test ensures that the server config ID varies for different server
767 // configs. 761 // configs.
768 762
769 MockRandom rand_a, rand_b; 763 MockRandom rand_a, rand_b;
770 const QuicCryptoServerConfig::ConfigOptions options; 764 const QuicCryptoServerConfig::ConfigOptions options;
771 MockClock clock; 765 MockClock clock;
772 766
773 QuicCryptoServerConfig a(QuicCryptoServerConfig::TESTING, &rand_a); 767 QuicCryptoServerConfig a(QuicCryptoServerConfig::TESTING, &rand_a,
768 CryptoTestUtils::ProofSourceForTesting());
774 rand_b.ChangeValue(); 769 rand_b.ChangeValue();
775 QuicCryptoServerConfig b(QuicCryptoServerConfig::TESTING, &rand_b); 770 QuicCryptoServerConfig b(QuicCryptoServerConfig::TESTING, &rand_b,
771 CryptoTestUtils::ProofSourceForTesting());
776 scoped_ptr<CryptoHandshakeMessage> scfg_a( 772 scoped_ptr<CryptoHandshakeMessage> scfg_a(
777 a.AddDefaultConfig(&rand_a, &clock, options)); 773 a.AddDefaultConfig(&rand_a, &clock, options));
778 scoped_ptr<CryptoHandshakeMessage> scfg_b( 774 scoped_ptr<CryptoHandshakeMessage> scfg_b(
779 b.AddDefaultConfig(&rand_b, &clock, options)); 775 b.AddDefaultConfig(&rand_b, &clock, options));
780 776
781 StringPiece scid_a, scid_b; 777 StringPiece scid_a, scid_b;
782 EXPECT_TRUE(scfg_a->GetStringPiece(kSCID, &scid_a)); 778 EXPECT_TRUE(scfg_a->GetStringPiece(kSCID, &scid_a));
783 EXPECT_TRUE(scfg_b->GetStringPiece(kSCID, &scid_b)); 779 EXPECT_TRUE(scfg_b->GetStringPiece(kSCID, &scid_b));
784 780
785 EXPECT_NE(scid_a, scid_b); 781 EXPECT_NE(scid_a, scid_b);
786 } 782 }
787 783
788 TEST(CryptoServerConfigGenerationTest, SCIDIsHashOfServerConfig) { 784 TEST(CryptoServerConfigGenerationTest, SCIDIsHashOfServerConfig) {
789 MockRandom rand_a; 785 MockRandom rand_a;
790 const QuicCryptoServerConfig::ConfigOptions options; 786 const QuicCryptoServerConfig::ConfigOptions options;
791 MockClock clock; 787 MockClock clock;
792 788
793 QuicCryptoServerConfig a(QuicCryptoServerConfig::TESTING, &rand_a); 789 QuicCryptoServerConfig a(QuicCryptoServerConfig::TESTING, &rand_a,
790 CryptoTestUtils::ProofSourceForTesting());
794 scoped_ptr<CryptoHandshakeMessage> scfg( 791 scoped_ptr<CryptoHandshakeMessage> scfg(
795 a.AddDefaultConfig(&rand_a, &clock, options)); 792 a.AddDefaultConfig(&rand_a, &clock, options));
796 793
797 StringPiece scid; 794 StringPiece scid;
798 EXPECT_TRUE(scfg->GetStringPiece(kSCID, &scid)); 795 EXPECT_TRUE(scfg->GetStringPiece(kSCID, &scid));
799 // Need to take a copy of |scid| has we're about to call |Erase|. 796 // Need to take a copy of |scid| has we're about to call |Erase|.
800 const string scid_str(scid.as_string()); 797 const string scid_str(scid.as_string());
801 798
802 scfg->Erase(kSCID); 799 scfg->Erase(kSCID);
803 scfg->MarkDirty(); 800 scfg->MarkDirty();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 956
960 strike_register_client_->RunPendingVerifications(); 957 strike_register_client_->RunPendingVerifications();
961 ASSERT_TRUE(called); 958 ASSERT_TRUE(called);
962 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); 959 EXPECT_EQ(0, strike_register_client_->PendingVerifications());
963 // The message should be rejected now. 960 // The message should be rejected now.
964 CheckRejectTag(); 961 CheckRejectTag();
965 } 962 }
966 963
967 } // namespace test 964 } // namespace test
968 } // namespace net 965 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_manager_unittest.cc ('k') | net/quic/crypto/properties_based_quic_server_info_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698