OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/crypto_handshake.h" | 5 #include "net/quic/crypto/crypto_handshake.h" |
6 | 6 |
7 #include "net/quic/crypto/aes_128_gcm_encrypter.h" | 7 #include "net/quic/crypto/aes_128_gcm_encrypter.h" |
8 #include "net/quic/crypto/crypto_server_config.h" | 8 #include "net/quic/crypto/crypto_server_config.h" |
9 #include "net/quic/crypto/quic_random.h" | 9 #include "net/quic/crypto/quic_random.h" |
10 #include "net/quic/quic_time.h" | 10 #include "net/quic/quic_time.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 return server_config_->ValidateSourceAddressToken(srct, ip, now); | 35 return server_config_->ValidateSourceAddressToken(srct, ip, now); |
36 } | 36 } |
37 | 37 |
38 private: | 38 private: |
39 QuicCryptoServerConfig* const server_config_; | 39 QuicCryptoServerConfig* const server_config_; |
40 }; | 40 }; |
41 | 41 |
42 TEST(QuicCryptoServerConfigTest, ServerConfig) { | 42 TEST(QuicCryptoServerConfigTest, ServerConfig) { |
43 QuicCryptoServerConfig server("source address token secret"); | 43 QuicCryptoServerConfig server("source address token secret"); |
44 MockClock clock; | 44 MockClock clock; |
45 CryptoHandshakeMessage extra_tags; | |
46 | 45 |
47 scoped_ptr<CryptoHandshakeMessage>( | 46 scoped_ptr<CryptoHandshakeMessage>( |
48 server.AddDefaultConfig(QuicRandom::GetInstance(), &clock, extra_tags, | 47 server.AddDefaultConfig(QuicRandom::GetInstance(), &clock, |
49 QuicCryptoServerConfig::kDefaultExpiry)); | 48 QuicCryptoServerConfig::kDefaultExpiry)); |
50 } | 49 } |
51 | 50 |
52 TEST(QuicCryptoServerConfigTest, SourceAddressTokens) { | 51 TEST(QuicCryptoServerConfigTest, SourceAddressTokens) { |
53 if (!Aes128GcmEncrypter::IsSupported()) { | 52 if (!Aes128GcmEncrypter::IsSupported()) { |
54 LOG(INFO) << "AES GCM not supported. Test skipped."; | 53 LOG(INFO) << "AES GCM not supported. Test skipped."; |
55 return; | 54 return; |
56 } | 55 } |
57 | 56 |
58 QuicCryptoServerConfig server("source address token secret"); | 57 QuicCryptoServerConfig server("source address token secret"); |
(...skipping 18 matching lines...) Expand all Loading... |
77 | 76 |
78 now = original_time.Add(QuicTime::Delta::FromSeconds(86400 * 7)); | 77 now = original_time.Add(QuicTime::Delta::FromSeconds(86400 * 7)); |
79 EXPECT_FALSE(peer.ValidateSourceAddressToken(token4, ip4, now)); | 78 EXPECT_FALSE(peer.ValidateSourceAddressToken(token4, ip4, now)); |
80 | 79 |
81 now = original_time.Subtract(QuicTime::Delta::FromSeconds(3600 * 2)); | 80 now = original_time.Subtract(QuicTime::Delta::FromSeconds(3600 * 2)); |
82 EXPECT_FALSE(peer.ValidateSourceAddressToken(token4, ip4, now)); | 81 EXPECT_FALSE(peer.ValidateSourceAddressToken(token4, ip4, now)); |
83 } | 82 } |
84 | 83 |
85 } // namespace test | 84 } // namespace test |
86 } // namespace net | 85 } // namespace net |
OLD | NEW |