| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/quic_crypto_server_stream.h" | 5 #include "net/quic/quic_crypto_server_stream.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" | 11 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
| 12 #include "net/quic/crypto/crypto_framer.h" | 12 #include "net/quic/crypto/crypto_framer.h" |
| 13 #include "net/quic/crypto/crypto_handshake.h" | 13 #include "net/quic/crypto/crypto_handshake.h" |
| 14 #include "net/quic/crypto/crypto_protocol.h" | 14 #include "net/quic/crypto/crypto_protocol.h" |
| 15 #include "net/quic/crypto/crypto_server_config.h" | 15 #include "net/quic/crypto/crypto_server_config.h" |
| 16 #include "net/quic/crypto/crypto_utils.h" | 16 #include "net/quic/crypto/crypto_utils.h" |
| 17 #include "net/quic/crypto/quic_decrypter.h" | 17 #include "net/quic/crypto/quic_decrypter.h" |
| 18 #include "net/quic/crypto/quic_encrypter.h" | 18 #include "net/quic/crypto/quic_encrypter.h" |
| 19 #include "net/quic/crypto/quic_random.h" |
| 19 #include "net/quic/quic_crypto_client_stream.h" | 20 #include "net/quic/quic_crypto_client_stream.h" |
| 20 #include "net/quic/quic_protocol.h" | 21 #include "net/quic/quic_protocol.h" |
| 21 #include "net/quic/quic_session.h" | 22 #include "net/quic/quic_session.h" |
| 22 #include "net/quic/test_tools/crypto_test_utils.h" | 23 #include "net/quic/test_tools/crypto_test_utils.h" |
| 23 #include "net/quic/test_tools/quic_test_utils.h" | 24 #include "net/quic/test_tools/quic_test_utils.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 27 |
| 27 namespace net { | 28 namespace net { |
| 28 class QuicConnection; | 29 class QuicConnection; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 class QuicCryptoServerStreamTest : public ::testing::Test { | 58 class QuicCryptoServerStreamTest : public ::testing::Test { |
| 58 public: | 59 public: |
| 59 QuicCryptoServerStreamTest() | 60 QuicCryptoServerStreamTest() |
| 60 : guid_(1), | 61 : guid_(1), |
| 61 addr_(ParseIPLiteralToNumber("192.0.2.33", &ip_) ? | 62 addr_(ParseIPLiteralToNumber("192.0.2.33", &ip_) ? |
| 62 ip_ : IPAddressNumber(), 1), | 63 ip_ : IPAddressNumber(), 1), |
| 63 connection_(new PacketSavingConnection(guid_, addr_, true)), | 64 connection_(new PacketSavingConnection(guid_, addr_, true)), |
| 64 session_(connection_, QuicConfig(), true), | 65 session_(connection_, QuicConfig(), true), |
| 65 crypto_config_(QuicCryptoServerConfig::TESTING), | 66 crypto_config_(QuicCryptoServerConfig::TESTING, |
| 67 QuicRandom::GetInstance()), |
| 66 stream_(crypto_config_, &session_) { | 68 stream_(crypto_config_, &session_) { |
| 67 config_.SetDefaults(); | 69 config_.SetDefaults(); |
| 68 session_.config()->SetDefaults(); | 70 session_.config()->SetDefaults(); |
| 69 session_.SetCryptoStream(&stream_); | 71 session_.SetCryptoStream(&stream_); |
| 70 // We advance the clock initially because the default time is zero and the | 72 // We advance the clock initially because the default time is zero and the |
| 71 // strike register worries that we've just overflowed a uint32 time. | 73 // strike register worries that we've just overflowed a uint32 time. |
| 72 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(100000)); | 74 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(100000)); |
| 73 // TODO(rtenneti): Enable testing of ProofSource. | 75 // TODO(rtenneti): Enable testing of ProofSource. |
| 74 // crypto_config_.SetProofSource(CryptoTestUtils::ProofSourceForTesting()); | 76 // crypto_config_.SetProofSource(CryptoTestUtils::ProofSourceForTesting()); |
| 75 | 77 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 if (!Aes128Gcm12Encrypter::IsSupported()) { | 237 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 236 LOG(INFO) << "AES GCM not supported. Test skipped."; | 238 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 237 return; | 239 return; |
| 238 } | 240 } |
| 239 | 241 |
| 240 crypto_config_.SetProofSource(NULL); | 242 crypto_config_.SetProofSource(NULL); |
| 241 client_options_.dont_verify_certs = true; | 243 client_options_.dont_verify_certs = true; |
| 242 | 244 |
| 243 // Only 2 client hellos need to be sent in the no-certs case: one to get the | 245 // Only 2 client hellos need to be sent in the no-certs case: one to get the |
| 244 // source-address token and the second to finish. | 246 // source-address token and the second to finish. |
| 247 // TODO(rtenneti): Enable testing of ProofVerifier. |
| 245 EXPECT_EQ(2, CompleteCryptoHandshake()); | 248 EXPECT_EQ(2, CompleteCryptoHandshake()); |
| 246 EXPECT_TRUE(stream_.encryption_established()); | 249 EXPECT_TRUE(stream_.encryption_established()); |
| 247 EXPECT_TRUE(stream_.handshake_confirmed()); | 250 EXPECT_TRUE(stream_.handshake_confirmed()); |
| 248 } | 251 } |
| 249 | 252 |
| 253 TEST_F(QuicCryptoServerStreamTest, ChannelID) { |
| 254 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 255 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 256 return; |
| 257 } |
| 258 |
| 259 client_options_.channel_id_enabled = true; |
| 260 // TODO(rtenneti): Enable testing of ProofVerifier. |
| 261 EXPECT_EQ(2, CompleteCryptoHandshake()); |
| 262 EXPECT_TRUE(stream_.encryption_established()); |
| 263 EXPECT_TRUE(stream_.handshake_confirmed()); |
| 264 // TODO(rtenneti): Enable testing of ChannelID. |
| 265 // EXPECT_EQ(CryptoTestUtils::ChannelIDKeyForHostname("test.example.com"), |
| 266 // stream_.crypto_negotiated_params().channel_id); |
| 267 } |
| 268 |
| 250 } // namespace | 269 } // namespace |
| 251 } // namespace test | 270 } // namespace test |
| 252 } // namespace net | 271 } // namespace net |
| OLD | NEW |