| 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 <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // CompleteCryptoHandshake returns the number of client hellos sent. This | 218 // CompleteCryptoHandshake returns the number of client hellos sent. This |
| 219 // test should send: | 219 // test should send: |
| 220 // * One to get a source-address token and certificates. | 220 // * One to get a source-address token and certificates. |
| 221 // * One to complete the handshake. | 221 // * One to complete the handshake. |
| 222 Initialize(); | 222 Initialize(); |
| 223 EXPECT_EQ(2, CompleteCryptoHandshake()); | 223 EXPECT_EQ(2, CompleteCryptoHandshake()); |
| 224 EXPECT_TRUE(server_stream()->encryption_established()); | 224 EXPECT_TRUE(server_stream()->encryption_established()); |
| 225 EXPECT_TRUE(server_stream()->handshake_confirmed()); | 225 EXPECT_TRUE(server_stream()->handshake_confirmed()); |
| 226 } | 226 } |
| 227 | 227 |
| 228 TEST_P(QuicCryptoServerStreamTest, InitialEncryptionAfterCHLO) { | |
| 229 Initialize(); | |
| 230 InitializeFakeClient(/* supports_stateless_rejects= */ false); | |
| 231 | |
| 232 // Do a first handshake in order to prime the client config with the server's | |
| 233 // information. | |
| 234 AdvanceHandshakeWithFakeClient(); | |
| 235 EXPECT_FALSE(server_stream()->encryption_established()); | |
| 236 EXPECT_FALSE(server_stream()->handshake_confirmed()); | |
| 237 | |
| 238 // Now do another handshake, with the blocking SHLO connection option. | |
| 239 InitializeServer(); | |
| 240 InitializeFakeClient(/* supports_stateless_rejects= */ false); | |
| 241 if (FLAGS_quic_default_immediate_forward_secure) { | |
| 242 client_session_->config()->SetConnectionOptionsToSend({kIPFS}); | |
| 243 } | |
| 244 | |
| 245 AdvanceHandshakeWithFakeClient(); | |
| 246 EXPECT_TRUE(server_stream()->encryption_established()); | |
| 247 EXPECT_TRUE(server_stream()->handshake_confirmed()); | |
| 248 EXPECT_EQ(ENCRYPTION_INITIAL, | |
| 249 server_session_->connection()->encryption_level()); | |
| 250 } | |
| 251 | |
| 252 TEST_P(QuicCryptoServerStreamTest, ForwardSecureAfterCHLO) { | 228 TEST_P(QuicCryptoServerStreamTest, ForwardSecureAfterCHLO) { |
| 253 Initialize(); | 229 Initialize(); |
| 254 InitializeFakeClient(/* supports_stateless_rejects= */ false); | 230 InitializeFakeClient(/* supports_stateless_rejects= */ false); |
| 255 | 231 |
| 256 // Do a first handshake in order to prime the client config with the server's | 232 // Do a first handshake in order to prime the client config with the server's |
| 257 // information. | 233 // information. |
| 258 AdvanceHandshakeWithFakeClient(); | 234 AdvanceHandshakeWithFakeClient(); |
| 259 EXPECT_FALSE(server_stream()->encryption_established()); | 235 EXPECT_FALSE(server_stream()->encryption_established()); |
| 260 EXPECT_FALSE(server_stream()->handshake_confirmed()); | 236 EXPECT_FALSE(server_stream()->handshake_confirmed()); |
| 261 | 237 |
| 262 // Now do another handshake, with the blocking SHLO connection option. | 238 // Now do another handshake, with the blocking SHLO connection option. |
| 263 InitializeServer(); | 239 InitializeServer(); |
| 264 InitializeFakeClient(/* supports_stateless_rejects= */ false); | 240 InitializeFakeClient(/* supports_stateless_rejects= */ false); |
| 265 if (!FLAGS_quic_default_immediate_forward_secure) { | |
| 266 client_session_->config()->SetConnectionOptionsToSend({kIPFS}); | |
| 267 } | |
| 268 | 241 |
| 269 AdvanceHandshakeWithFakeClient(); | 242 AdvanceHandshakeWithFakeClient(); |
| 270 EXPECT_TRUE(server_stream()->encryption_established()); | 243 EXPECT_TRUE(server_stream()->encryption_established()); |
| 271 EXPECT_TRUE(server_stream()->handshake_confirmed()); | 244 EXPECT_TRUE(server_stream()->handshake_confirmed()); |
| 272 EXPECT_EQ(ENCRYPTION_FORWARD_SECURE, | 245 EXPECT_EQ(ENCRYPTION_FORWARD_SECURE, |
| 273 server_session_->connection()->encryption_level()); | 246 server_session_->connection()->encryption_level()); |
| 274 } | 247 } |
| 275 | 248 |
| 276 TEST_P(QuicCryptoServerStreamTest, StatelessRejectAfterCHLO) { | 249 TEST_P(QuicCryptoServerStreamTest, StatelessRejectAfterCHLO) { |
| 277 ValueRestore<bool> old_flag(&FLAGS_enable_quic_stateless_reject_support, | 250 ValueRestore<bool> old_flag(&FLAGS_enable_quic_stateless_reject_support, |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 QUIC_NO_ERROR, "", ConnectionCloseBehavior::SILENT_CLOSE); | 572 QUIC_NO_ERROR, "", ConnectionCloseBehavior::SILENT_CLOSE); |
| 600 | 573 |
| 601 // The outstanding nonce verification RPC now completes. | 574 // The outstanding nonce verification RPC now completes. |
| 602 strike_register_client_->RunPendingVerifications(); | 575 strike_register_client_->RunPendingVerifications(); |
| 603 } | 576 } |
| 604 | 577 |
| 605 } // namespace | 578 } // namespace |
| 606 | 579 |
| 607 } // namespace test | 580 } // namespace test |
| 608 } // namespace net | 581 } // namespace net |
| OLD | NEW |