| 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_client_config.h" | 5 #include "net/quic/crypto/quic_crypto_client_config.h" |
| 6 | 6 |
| 7 #include "net/quic/crypto/proof_verifier.h" | 7 #include "net/quic/crypto/proof_verifier.h" |
| 8 #include "net/quic/quic_session_key.h" | 8 #include "net/quic/quic_session_key.h" |
| 9 #include "net/quic/test_tools/quic_test_utils.h" | 9 #include "net/quic/test_tools/quic_test_utils.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 EXPECT_EQ(state.source_address_token(), other.source_address_token()); | 49 EXPECT_EQ(state.source_address_token(), other.source_address_token()); |
| 50 EXPECT_EQ(state.certs(), other.certs()); | 50 EXPECT_EQ(state.certs(), other.certs()); |
| 51 EXPECT_EQ(1u, other.generation_counter()); | 51 EXPECT_EQ(1u, other.generation_counter()); |
| 52 } | 52 } |
| 53 | 53 |
| 54 TEST(QuicCryptoClientConfigTest, InchoateChlo) { | 54 TEST(QuicCryptoClientConfigTest, InchoateChlo) { |
| 55 QuicCryptoClientConfig::CachedState state; | 55 QuicCryptoClientConfig::CachedState state; |
| 56 QuicCryptoClientConfig config; | 56 QuicCryptoClientConfig config; |
| 57 QuicCryptoNegotiatedParameters params; | 57 QuicCryptoNegotiatedParameters params; |
| 58 CryptoHandshakeMessage msg; | 58 CryptoHandshakeMessage msg; |
| 59 QuicSessionKey server_key("www.google.com", 80, false, PRIVACY_MODE_DISABLED); | 59 QuicSessionKey server_key("www.google.com", 80, false, kPrivacyModeDisabled); |
| 60 config.FillInchoateClientHello(server_key, QuicVersionMax(), &state, | 60 config.FillInchoateClientHello(server_key, QuicVersionMax(), &state, |
| 61 ¶ms, &msg); | 61 ¶ms, &msg); |
| 62 | 62 |
| 63 QuicTag cver; | 63 QuicTag cver; |
| 64 EXPECT_EQ(QUIC_NO_ERROR, msg.GetUint32(kVER, &cver)); | 64 EXPECT_EQ(QUIC_NO_ERROR, msg.GetUint32(kVER, &cver)); |
| 65 EXPECT_EQ(QuicVersionToQuicTag(QuicVersionMax()), cver); | 65 EXPECT_EQ(QuicVersionToQuicTag(QuicVersionMax()), cver); |
| 66 } | 66 } |
| 67 | 67 |
| 68 TEST(QuicCryptoClientConfigTest, PreferAesGcm) { | 68 TEST(QuicCryptoClientConfigTest, PreferAesGcm) { |
| 69 QuicCryptoClientConfig config; | 69 QuicCryptoClientConfig config; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 95 QuicCryptoClientConfig config; | 95 QuicCryptoClientConfig config; |
| 96 EXPECT_EQ(QUIC_VERSION_NEGOTIATION_MISMATCH, | 96 EXPECT_EQ(QUIC_VERSION_NEGOTIATION_MISMATCH, |
| 97 config.ProcessServerHello(msg, 0, supported_versions, | 97 config.ProcessServerHello(msg, 0, supported_versions, |
| 98 &cached, &out_params, &error)); | 98 &cached, &out_params, &error)); |
| 99 EXPECT_EQ("Downgrade attack detected", error); | 99 EXPECT_EQ("Downgrade attack detected", error); |
| 100 } | 100 } |
| 101 | 101 |
| 102 TEST(QuicCryptoClientConfigTest, InitializeFrom) { | 102 TEST(QuicCryptoClientConfigTest, InitializeFrom) { |
| 103 QuicCryptoClientConfig config; | 103 QuicCryptoClientConfig config; |
| 104 QuicSessionKey canonical_key1("www.google.com", 80, false, | 104 QuicSessionKey canonical_key1("www.google.com", 80, false, |
| 105 PRIVACY_MODE_DISABLED); | 105 kPrivacyModeDisabled); |
| 106 QuicCryptoClientConfig::CachedState* state = | 106 QuicCryptoClientConfig::CachedState* state = |
| 107 config.LookupOrCreate(canonical_key1); | 107 config.LookupOrCreate(canonical_key1); |
| 108 // TODO(rch): Populate other fields of |state|. | 108 // TODO(rch): Populate other fields of |state|. |
| 109 state->set_source_address_token("TOKEN"); | 109 state->set_source_address_token("TOKEN"); |
| 110 state->SetProofValid(); | 110 state->SetProofValid(); |
| 111 | 111 |
| 112 QuicSessionKey other_key("mail.google.com", 80, false, PRIVACY_MODE_DISABLED); | 112 QuicSessionKey other_key("mail.google.com", 80, false, kPrivacyModeDisabled); |
| 113 config.InitializeFrom(other_key, canonical_key1, &config); | 113 config.InitializeFrom(other_key, canonical_key1, &config); |
| 114 QuicCryptoClientConfig::CachedState* other = config.LookupOrCreate(other_key); | 114 QuicCryptoClientConfig::CachedState* other = config.LookupOrCreate(other_key); |
| 115 | 115 |
| 116 EXPECT_EQ(state->server_config(), other->server_config()); | 116 EXPECT_EQ(state->server_config(), other->server_config()); |
| 117 EXPECT_EQ(state->source_address_token(), other->source_address_token()); | 117 EXPECT_EQ(state->source_address_token(), other->source_address_token()); |
| 118 EXPECT_EQ(state->certs(), other->certs()); | 118 EXPECT_EQ(state->certs(), other->certs()); |
| 119 EXPECT_EQ(1u, other->generation_counter()); | 119 EXPECT_EQ(1u, other->generation_counter()); |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace test | 122 } // namespace test |
| 123 } // namespace net | 123 } // namespace net |
| OLD | NEW |