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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand, | 455 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand, |
456 CryptoTestUtils::ProofSourceForTesting()); | 456 CryptoTestUtils::ProofSourceForTesting()); |
457 QuicCryptoServerConfigPeer peer(&server); | 457 QuicCryptoServerConfigPeer peer(&server); |
458 | 458 |
459 StringPiece message("hello world"); | 459 StringPiece message("hello world"); |
460 const size_t key_size = CryptoSecretBoxer::GetKeySize(); | 460 const size_t key_size = CryptoSecretBoxer::GetKeySize(); |
461 scoped_ptr<uint8_t[]> key(new uint8_t[key_size]); | 461 scoped_ptr<uint8_t[]> key(new uint8_t[key_size]); |
462 memset(key.get(), 0x11, key_size); | 462 memset(key.get(), 0x11, key_size); |
463 | 463 |
464 CryptoSecretBoxer boxer; | 464 CryptoSecretBoxer boxer; |
465 boxer.SetKey(StringPiece(reinterpret_cast<char*>(key.get()), key_size)); | 465 boxer.SetKeys({string(reinterpret_cast<char*>(key.get()), key_size)}); |
466 const string box = boxer.Box(rand, message); | 466 const string box = boxer.Box(rand, message); |
467 MockClock clock; | 467 MockClock clock; |
468 QuicWallTime now = clock.WallNow(); | 468 QuicWallTime now = clock.WallNow(); |
469 const QuicWallTime original_time = now; | 469 const QuicWallTime original_time = now; |
470 EXPECT_EQ(SERVER_NONCE_DECRYPTION_FAILURE, | 470 EXPECT_EQ(SERVER_NONCE_DECRYPTION_FAILURE, |
471 peer.ValidateServerNonce(box, now)); | 471 peer.ValidateServerNonce(box, now)); |
472 | 472 |
473 string server_nonce = peer.NewServerNonce(rand, now); | 473 string server_nonce = peer.NewServerNonce(rand, now); |
474 EXPECT_EQ(HANDSHAKE_OK, peer.ValidateServerNonce(server_nonce, now)); | 474 EXPECT_EQ(HANDSHAKE_OK, peer.ValidateServerNonce(server_nonce, now)); |
475 EXPECT_EQ(SERVER_NONCE_NOT_UNIQUE_FAILURE, | 475 EXPECT_EQ(SERVER_NONCE_NOT_UNIQUE_FAILURE, |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 TEST_F(CryptoServerConfigsTest, InvalidConfigs) { | 660 TEST_F(CryptoServerConfigsTest, InvalidConfigs) { |
661 // Ensure that invalid configs don't change anything. | 661 // Ensure that invalid configs don't change anything. |
662 SetConfigs("a", 800, 1, "b", 900, 1, "c", 1100, 1, nullptr); | 662 SetConfigs("a", 800, 1, "b", 900, 1, "c", 1100, 1, nullptr); |
663 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); | 663 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); |
664 SetConfigs("a", 800, 1, "c", 1100, 1, "INVALID1", 1000, 1, nullptr); | 664 SetConfigs("a", 800, 1, "c", 1100, 1, "INVALID1", 1000, 1, nullptr); |
665 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); | 665 test_peer_.CheckConfigs("a", false, "b", true, "c", false, nullptr); |
666 } | 666 } |
667 | 667 |
668 } // namespace test | 668 } // namespace test |
669 } // namespace net | 669 } // namespace net |
OLD | NEW |