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

Side by Side Diff: net/quic/crypto/quic_crypto_server_config_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
« no previous file with comments | « net/quic/crypto/quic_crypto_server_config.cc ('k') | net/quic/p2p/quic_p2p_session_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "net/quic/crypto/quic_crypto_server_config.h" 5 #include "net/quic/crypto/quic_crypto_server_config.h"
6 6
7 #include <stdarg.h> 7 #include <stdarg.h>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" 10 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h"
11 #include "net/quic/crypto/crypto_handshake_message.h" 11 #include "net/quic/crypto/crypto_handshake_message.h"
12 #include "net/quic/crypto/crypto_secret_boxer.h" 12 #include "net/quic/crypto/crypto_secret_boxer.h"
13 #include "net/quic/crypto/crypto_server_config_protobuf.h" 13 #include "net/quic/crypto/crypto_server_config_protobuf.h"
14 #include "net/quic/crypto/quic_random.h" 14 #include "net/quic/crypto/quic_random.h"
15 #include "net/quic/crypto/strike_register_client.h" 15 #include "net/quic/crypto/strike_register_client.h"
16 #include "net/quic/quic_flags.h" 16 #include "net/quic/quic_flags.h"
17 #include "net/quic/quic_time.h" 17 #include "net/quic/quic_time.h"
18 #include "net/quic/test_tools/crypto_test_utils.h"
18 #include "net/quic/test_tools/mock_clock.h" 19 #include "net/quic/test_tools/mock_clock.h"
19 #include "net/quic/test_tools/quic_test_utils.h" 20 #include "net/quic/test_tools/quic_test_utils.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
23 using base::StringPiece; 24 using base::StringPiece;
24 using std::map; 25 using std::map;
25 using std::pair; 26 using std::pair;
26 using std::string; 27 using std::string;
27 using std::vector; 28 using std::vector;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 212
212 bool is_known_orbit_called() { return is_known_orbit_called_; } 213 bool is_known_orbit_called() { return is_known_orbit_called_; }
213 214
214 private: 215 private:
215 QuicCryptoServerConfig* config_; 216 QuicCryptoServerConfig* config_;
216 mutable bool is_known_orbit_called_; 217 mutable bool is_known_orbit_called_;
217 }; 218 };
218 219
219 TEST(QuicCryptoServerConfigTest, ServerConfig) { 220 TEST(QuicCryptoServerConfigTest, ServerConfig) {
220 QuicRandom* rand = QuicRandom::GetInstance(); 221 QuicRandom* rand = QuicRandom::GetInstance();
221 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand); 222 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand,
223 CryptoTestUtils::ProofSourceForTesting());
222 MockClock clock; 224 MockClock clock;
223 225
224 scoped_ptr<CryptoHandshakeMessage>( 226 scoped_ptr<CryptoHandshakeMessage>(
225 server.AddDefaultConfig(rand, &clock, 227 server.AddDefaultConfig(rand, &clock,
226 QuicCryptoServerConfig::ConfigOptions())); 228 QuicCryptoServerConfig::ConfigOptions()));
227 } 229 }
228 230
229 TEST(QuicCryptoServerConfigTest, GetOrbitIsCalledWithoutTheStrikeRegisterLock) { 231 TEST(QuicCryptoServerConfigTest, GetOrbitIsCalledWithoutTheStrikeRegisterLock) {
230 QuicRandom* rand = QuicRandom::GetInstance(); 232 QuicRandom* rand = QuicRandom::GetInstance();
231 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand); 233 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand,
234 CryptoTestUtils::ProofSourceForTesting());
232 MockClock clock; 235 MockClock clock;
233 236
234 TestStrikeRegisterClient* strike_register = 237 TestStrikeRegisterClient* strike_register =
235 new TestStrikeRegisterClient(&server); 238 new TestStrikeRegisterClient(&server);
236 server.SetStrikeRegisterClient(strike_register); 239 server.SetStrikeRegisterClient(strike_register);
237 240
238 QuicCryptoServerConfig::ConfigOptions options; 241 QuicCryptoServerConfig::ConfigOptions options;
239 scoped_ptr<CryptoHandshakeMessage> message( 242 scoped_ptr<CryptoHandshakeMessage> message(
240 server.AddDefaultConfig(rand, &clock, options)); 243 server.AddDefaultConfig(rand, &clock, options));
241 EXPECT_TRUE(strike_register->is_known_orbit_called()); 244 EXPECT_TRUE(strike_register->is_known_orbit_called());
242 } 245 }
243 246
244 class SourceAddressTokenTest : public ::testing::Test { 247 class SourceAddressTokenTest : public ::testing::Test {
245 public: 248 public:
246 SourceAddressTokenTest() 249 SourceAddressTokenTest()
247 : ip4_(Loopback4()), 250 : ip4_(Loopback4()),
248 ip4_dual_(ConvertIPv4NumberToIPv6Number(ip4_)), 251 ip4_dual_(ConvertIPv4NumberToIPv6Number(ip4_)),
249 ip6_(Loopback6()), 252 ip6_(Loopback6()),
250 original_time_(QuicWallTime::Zero()), 253 original_time_(QuicWallTime::Zero()),
251 rand_(QuicRandom::GetInstance()), 254 rand_(QuicRandom::GetInstance()),
252 server_(QuicCryptoServerConfig::TESTING, rand_), 255 server_(QuicCryptoServerConfig::TESTING,
256 rand_,
257 CryptoTestUtils::ProofSourceForTesting()),
253 peer_(&server_) { 258 peer_(&server_) {
254 // Advance the clock to some non-zero time. 259 // Advance the clock to some non-zero time.
255 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1000000)); 260 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1000000));
256 original_time_ = clock_.WallNow(); 261 original_time_ = clock_.WallNow();
257 262
258 primary_config_.reset(server_.AddDefaultConfig( 263 primary_config_.reset(server_.AddDefaultConfig(
259 rand_, &clock_, QuicCryptoServerConfig::ConfigOptions())); 264 rand_, &clock_, QuicCryptoServerConfig::ConfigOptions()));
260 265
261 // Add a config that overrides the default boxer. 266 // Add a config that overrides the default boxer.
262 QuicCryptoServerConfig::ConfigOptions options; 267 QuicCryptoServerConfig::ConfigOptions options;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 NewSourceAddressToken(kPrimary, ip4_, previous_tokens); 420 NewSourceAddressToken(kPrimary, ip4_, previous_tokens);
416 421
417 EXPECT_EQ(HANDSHAKE_OK, 422 EXPECT_EQ(HANDSHAKE_OK,
418 ValidateSourceAddressTokens(kPrimary, token4or6, ip4_)); 423 ValidateSourceAddressTokens(kPrimary, token4or6, ip4_));
419 ASSERT_EQ(HANDSHAKE_OK, 424 ASSERT_EQ(HANDSHAKE_OK,
420 ValidateSourceAddressTokens(kPrimary, token4or6, ip6_)); 425 ValidateSourceAddressTokens(kPrimary, token4or6, ip6_));
421 } 426 }
422 427
423 TEST(QuicCryptoServerConfigTest, ValidateServerNonce) { 428 TEST(QuicCryptoServerConfigTest, ValidateServerNonce) {
424 QuicRandom* rand = QuicRandom::GetInstance(); 429 QuicRandom* rand = QuicRandom::GetInstance();
425 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand); 430 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand,
431 CryptoTestUtils::ProofSourceForTesting());
426 QuicCryptoServerConfigPeer peer(&server); 432 QuicCryptoServerConfigPeer peer(&server);
427 433
428 StringPiece message("hello world"); 434 StringPiece message("hello world");
429 const size_t key_size = CryptoSecretBoxer::GetKeySize(); 435 const size_t key_size = CryptoSecretBoxer::GetKeySize();
430 scoped_ptr<uint8[]> key(new uint8[key_size]); 436 scoped_ptr<uint8[]> key(new uint8[key_size]);
431 memset(key.get(), 0x11, key_size); 437 memset(key.get(), 0x11, key_size);
432 438
433 CryptoSecretBoxer boxer; 439 CryptoSecretBoxer boxer;
434 boxer.SetKey(StringPiece(reinterpret_cast<char*>(key.get()), key_size)); 440 boxer.SetKey(StringPiece(reinterpret_cast<char*>(key.get()), key_size));
435 const string box = boxer.Box(rand, message); 441 const string box = boxer.Box(rand, message);
(...skipping 10 matching lines...) Expand all
446 452
447 now = original_time.Add(QuicTime::Delta::FromSeconds(1000 * 7)); 453 now = original_time.Add(QuicTime::Delta::FromSeconds(1000 * 7));
448 server_nonce = peer.NewServerNonce(rand, now); 454 server_nonce = peer.NewServerNonce(rand, now);
449 EXPECT_EQ(HANDSHAKE_OK, peer.ValidateServerNonce(server_nonce, now)); 455 EXPECT_EQ(HANDSHAKE_OK, peer.ValidateServerNonce(server_nonce, now));
450 } 456 }
451 457
452 class CryptoServerConfigsTest : public ::testing::Test { 458 class CryptoServerConfigsTest : public ::testing::Test {
453 public: 459 public:
454 CryptoServerConfigsTest() 460 CryptoServerConfigsTest()
455 : rand_(QuicRandom::GetInstance()), 461 : rand_(QuicRandom::GetInstance()),
456 config_(QuicCryptoServerConfig::TESTING, rand_), 462 config_(QuicCryptoServerConfig::TESTING,
463 rand_,
464 CryptoTestUtils::ProofSourceForTesting()),
457 test_peer_(&config_) {} 465 test_peer_(&config_) {}
458 466
459 void SetUp() override { 467 void SetUp() override {
460 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1000)); 468 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1000));
461 } 469 }
462 470
463 // SetConfigs constructs suitable config protobufs and calls SetConfigs on 471 // SetConfigs constructs suitable config protobufs and calls SetConfigs on
464 // |config_|. The arguments are given as nullptr-terminated pairs. The first 472 // |config_|. The arguments are given as nullptr-terminated pairs. The first
465 // of each pair is the server config ID of a Config. The second is the 473 // of each pair is the server config ID of a Config. The second is the
466 // |primary_time| of that Config, given in epoch seconds. (Although note that, 474 // |primary_time| of that Config, given in epoch seconds. (Although note that,
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 nullptr); 757 nullptr);
750 test_peer_.CheckConfigs( 758 test_peer_.CheckConfigs(
751 "a", false, 759 "a", false,
752 "b", true, 760 "b", true,
753 "c", false, 761 "c", false,
754 nullptr); 762 nullptr);
755 } 763 }
756 764
757 } // namespace test 765 } // namespace test
758 } // namespace net 766 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_crypto_server_config.cc ('k') | net/quic/p2p/quic_p2p_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698