| OLD | NEW |
| 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/cert_compressor.h" | 11 #include "net/quic/crypto/cert_compressor.h" |
| 12 #include "net/quic/crypto/chacha20_poly1305_rfc7539_encrypter.h" |
| 12 #include "net/quic/crypto/crypto_handshake_message.h" | 13 #include "net/quic/crypto/crypto_handshake_message.h" |
| 13 #include "net/quic/crypto/crypto_secret_boxer.h" | 14 #include "net/quic/crypto/crypto_secret_boxer.h" |
| 14 #include "net/quic/crypto/crypto_server_config_protobuf.h" | 15 #include "net/quic/crypto/crypto_server_config_protobuf.h" |
| 15 #include "net/quic/crypto/quic_random.h" | 16 #include "net/quic/crypto/quic_random.h" |
| 16 #include "net/quic/crypto/strike_register_client.h" | 17 #include "net/quic/crypto/strike_register_client.h" |
| 17 #include "net/quic/quic_flags.h" | 18 #include "net/quic/quic_flags.h" |
| 18 #include "net/quic/quic_time.h" | 19 #include "net/quic/quic_time.h" |
| 19 #include "net/quic/test_tools/crypto_test_utils.h" | 20 #include "net/quic/test_tools/crypto_test_utils.h" |
| 20 #include "net/quic/test_tools/mock_clock.h" | 21 #include "net/quic/test_tools/mock_clock.h" |
| 21 #include "net/quic/test_tools/quic_test_utils.h" | 22 #include "net/quic/test_tools/quic_test_utils.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 scoped_ptr<CryptoHandshakeMessage> message(server.AddDefaultConfig( | 237 scoped_ptr<CryptoHandshakeMessage> message(server.AddDefaultConfig( |
| 237 rand, &clock, QuicCryptoServerConfig::ConfigOptions())); | 238 rand, &clock, QuicCryptoServerConfig::ConfigOptions())); |
| 238 | 239 |
| 239 // The default configuration should have AES-GCM and at least one ChaCha20 | 240 // The default configuration should have AES-GCM and at least one ChaCha20 |
| 240 // cipher. | 241 // cipher. |
| 241 const QuicTag* aead_tags; | 242 const QuicTag* aead_tags; |
| 242 size_t aead_len; | 243 size_t aead_len; |
| 243 ASSERT_EQ(QUIC_NO_ERROR, message->GetTaglist(kAEAD, &aead_tags, &aead_len)); | 244 ASSERT_EQ(QUIC_NO_ERROR, message->GetTaglist(kAEAD, &aead_tags, &aead_len)); |
| 244 vector<QuicTag> aead(aead_tags, aead_tags + aead_len); | 245 vector<QuicTag> aead(aead_tags, aead_tags + aead_len); |
| 245 EXPECT_THAT(aead, ::testing::Contains(kAESG)); | 246 EXPECT_THAT(aead, ::testing::Contains(kAESG)); |
| 246 EXPECT_LE(2u, aead.size()); | 247 if (ChaCha20Poly1305Rfc7539Encrypter::IsSupported()) { |
| 248 EXPECT_LE(2u, aead.size()); |
| 249 } else { |
| 250 EXPECT_LE(1u, aead.size()); |
| 251 } |
| 247 } | 252 } |
| 248 | 253 |
| 249 TEST(QuicCryptoServerConfigTest, ServerConfigDisableChaCha) { | 254 TEST(QuicCryptoServerConfigTest, ServerConfigDisableChaCha) { |
| 250 ValueRestore<bool> old_flag( | 255 ValueRestore<bool> old_flag( |
| 251 &FLAGS_quic_crypto_server_config_default_has_chacha20, false); | 256 &FLAGS_quic_crypto_server_config_default_has_chacha20, false); |
| 252 QuicRandom* rand = QuicRandom::GetInstance(); | 257 QuicRandom* rand = QuicRandom::GetInstance(); |
| 253 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand, | 258 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand, |
| 254 CryptoTestUtils::ProofSourceForTesting()); | 259 CryptoTestUtils::ProofSourceForTesting()); |
| 255 MockClock clock; | 260 MockClock clock; |
| 256 | 261 |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 TEST_F(CryptoServerConfigsTest, InvalidConfigs) { | 774 TEST_F(CryptoServerConfigsTest, InvalidConfigs) { |
| 770 // Ensure that invalid configs don't change anything. | 775 // Ensure that invalid configs don't change anything. |
| 771 SetConfigs("a", 800, 1, "b", 900, 1, "c", 1100, 1, nullptr); | 776 SetConfigs("a", 800, 1, "b", 900, 1, "c", 1100, 1, nullptr); |
| 772 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); | 777 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); |
| 773 SetConfigs("a", 800, 1, "c", 1100, 1, "INVALID1", 1000, 1, nullptr); | 778 SetConfigs("a", 800, 1, "c", 1100, 1, "INVALID1", 1000, 1, nullptr); |
| 774 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); | 779 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); |
| 775 } | 780 } |
| 776 | 781 |
| 777 } // namespace test | 782 } // namespace test |
| 778 } // namespace net | 783 } // namespace net |
| OLD | NEW |