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

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

Issue 1660593004: Landing Recent QUIC changes until 01/28/2016 18:41 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0202
Patch Set: Created 4 years, 10 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/quic_chromium_client_session.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"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 QuicCryptoServerConfig* config_; 214 QuicCryptoServerConfig* config_;
215 mutable bool is_known_orbit_called_; 215 mutable bool is_known_orbit_called_;
216 }; 216 };
217 217
218 TEST(QuicCryptoServerConfigTest, ServerConfig) { 218 TEST(QuicCryptoServerConfigTest, ServerConfig) {
219 QuicRandom* rand = QuicRandom::GetInstance(); 219 QuicRandom* rand = QuicRandom::GetInstance();
220 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand, 220 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand,
221 CryptoTestUtils::ProofSourceForTesting()); 221 CryptoTestUtils::ProofSourceForTesting());
222 MockClock clock; 222 MockClock clock;
223 223
224 scoped_ptr<CryptoHandshakeMessage>(server.AddDefaultConfig( 224 scoped_ptr<CryptoHandshakeMessage> message(server.AddDefaultConfig(
225 rand, &clock, QuicCryptoServerConfig::ConfigOptions())); 225 rand, &clock, QuicCryptoServerConfig::ConfigOptions()));
226
227 // The default configuration should have AES-GCM and at least one ChaCha20
228 // cipher.
229 const QuicTag* aead_tags;
230 size_t aead_len;
231 ASSERT_EQ(QUIC_NO_ERROR, message->GetTaglist(kAEAD, &aead_tags, &aead_len));
232 vector<QuicTag> aead(aead_tags, aead_tags + aead_len);
233 EXPECT_THAT(aead, ::testing::Contains(kAESG));
234 EXPECT_LE(2u, aead.size());
235 }
236
237 TEST(QuicCryptoServerConfigTest, ServerConfigDisableChaCha) {
238 ValueRestore<bool> old_flag(
239 &FLAGS_quic_crypto_server_config_default_has_chacha20, false);
240 QuicRandom* rand = QuicRandom::GetInstance();
241 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand,
242 CryptoTestUtils::ProofSourceForTesting());
243 MockClock clock;
244
245 scoped_ptr<CryptoHandshakeMessage> message(server.AddDefaultConfig(
246 rand, &clock, QuicCryptoServerConfig::ConfigOptions()));
247
248 // The default configuration should only contain AES-GCM when ChaCha20 has
249 // been disabled.
250 const QuicTag* aead_tags;
251 size_t aead_len;
252 ASSERT_EQ(QUIC_NO_ERROR, message->GetTaglist(kAEAD, &aead_tags, &aead_len));
253 vector<QuicTag> aead(aead_tags, aead_tags + aead_len);
254 EXPECT_THAT(aead, ::testing::ElementsAre(kAESG));
226 } 255 }
227 256
228 TEST(QuicCryptoServerConfigTest, GetOrbitIsCalledWithoutTheStrikeRegisterLock) { 257 TEST(QuicCryptoServerConfigTest, GetOrbitIsCalledWithoutTheStrikeRegisterLock) {
229 QuicRandom* rand = QuicRandom::GetInstance(); 258 QuicRandom* rand = QuicRandom::GetInstance();
230 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand, 259 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand,
231 CryptoTestUtils::ProofSourceForTesting()); 260 CryptoTestUtils::ProofSourceForTesting());
232 MockClock clock; 261 MockClock clock;
233 262
234 TestStrikeRegisterClient* strike_register = 263 TestStrikeRegisterClient* strike_register =
235 new TestStrikeRegisterClient(&server); 264 new TestStrikeRegisterClient(&server);
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 TEST_F(CryptoServerConfigsTest, InvalidConfigs) { 661 TEST_F(CryptoServerConfigsTest, InvalidConfigs) {
633 // Ensure that invalid configs don't change anything. 662 // Ensure that invalid configs don't change anything.
634 SetConfigs("a", 800, 1, "b", 900, 1, "c", 1100, 1, nullptr); 663 SetConfigs("a", 800, 1, "b", 900, 1, "c", 1100, 1, nullptr);
635 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); 664 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr);
636 SetConfigs("a", 800, 1, "c", 1100, 1, "INVALID1", 1000, 1, nullptr); 665 SetConfigs("a", 800, 1, "c", 1100, 1, "INVALID1", 1000, 1, nullptr);
637 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); 666 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr);
638 } 667 }
639 668
640 } // namespace test 669 } // namespace test
641 } // namespace net 670 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_crypto_server_config.cc ('k') | net/quic/quic_chromium_client_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698