| 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" |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 } | 423 } |
| 424 | 424 |
| 425 TEST(QuicCryptoServerConfigTest, ValidateServerNonce) { | 425 TEST(QuicCryptoServerConfigTest, ValidateServerNonce) { |
| 426 QuicRandom* rand = QuicRandom::GetInstance(); | 426 QuicRandom* rand = QuicRandom::GetInstance(); |
| 427 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand, | 427 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand, |
| 428 CryptoTestUtils::ProofSourceForTesting()); | 428 CryptoTestUtils::ProofSourceForTesting()); |
| 429 QuicCryptoServerConfigPeer peer(&server); | 429 QuicCryptoServerConfigPeer peer(&server); |
| 430 | 430 |
| 431 StringPiece message("hello world"); | 431 StringPiece message("hello world"); |
| 432 const size_t key_size = CryptoSecretBoxer::GetKeySize(); | 432 const size_t key_size = CryptoSecretBoxer::GetKeySize(); |
| 433 scoped_ptr<uint8[]> key(new uint8[key_size]); | 433 scoped_ptr<uint8_t[]> key(new uint8_t[key_size]); |
| 434 memset(key.get(), 0x11, key_size); | 434 memset(key.get(), 0x11, key_size); |
| 435 | 435 |
| 436 CryptoSecretBoxer boxer; | 436 CryptoSecretBoxer boxer; |
| 437 boxer.SetKey(StringPiece(reinterpret_cast<char*>(key.get()), key_size)); | 437 boxer.SetKey(StringPiece(reinterpret_cast<char*>(key.get()), key_size)); |
| 438 const string box = boxer.Box(rand, message); | 438 const string box = boxer.Box(rand, message); |
| 439 MockClock clock; | 439 MockClock clock; |
| 440 QuicWallTime now = clock.WallNow(); | 440 QuicWallTime now = clock.WallNow(); |
| 441 const QuicWallTime original_time = now; | 441 const QuicWallTime original_time = now; |
| 442 EXPECT_EQ(SERVER_NONCE_DECRYPTION_FAILURE, | 442 EXPECT_EQ(SERVER_NONCE_DECRYPTION_FAILURE, |
| 443 peer.ValidateServerNonce(box, now)); | 443 peer.ValidateServerNonce(box, now)); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 TEST_F(CryptoServerConfigsTest, InvalidConfigs) { | 632 TEST_F(CryptoServerConfigsTest, InvalidConfigs) { |
| 633 // Ensure that invalid configs don't change anything. | 633 // Ensure that invalid configs don't change anything. |
| 634 SetConfigs("a", 800, 1, "b", 900, 1, "c", 1100, 1, nullptr); | 634 SetConfigs("a", 800, 1, "b", 900, 1, "c", 1100, 1, nullptr); |
| 635 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); | 635 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); |
| 636 SetConfigs("a", 800, 1, "c", 1100, 1, "INVALID1", 1000, 1, nullptr); | 636 SetConfigs("a", 800, 1, "c", 1100, 1, "INVALID1", 1000, 1, nullptr); |
| 637 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); | 637 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); |
| 638 } | 638 } |
| 639 | 639 |
| 640 } // namespace test | 640 } // namespace test |
| 641 } // namespace net | 641 } // namespace net |
| OLD | NEW |