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/core/quic_crypto_server_stream.h" | 5 #include "net/quic/core/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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 250 |
251 ASSERT_TRUE(client_state->has_server_nonce()); | 251 ASSERT_TRUE(client_state->has_server_nonce()); |
252 ASSERT_FALSE(client_state->GetNextServerNonce().empty()); | 252 ASSERT_FALSE(client_state->GetNextServerNonce().empty()); |
253 ASSERT_FALSE(client_state->has_server_nonce()); | 253 ASSERT_FALSE(client_state->has_server_nonce()); |
254 | 254 |
255 ASSERT_TRUE(client_state->has_server_designated_connection_id()); | 255 ASSERT_TRUE(client_state->has_server_designated_connection_id()); |
256 const QuicConnectionId server_designated_connection_id = | 256 const QuicConnectionId server_designated_connection_id = |
257 client_state->GetNextServerDesignatedConnectionId(); | 257 client_state->GetNextServerDesignatedConnectionId(); |
258 const QuicConnectionId expected_id = | 258 const QuicConnectionId expected_id = |
259 server_connection_->random_generator()->RandUint64(); | 259 server_connection_->random_generator()->RandUint64(); |
260 EXPECT_EQ(expected_id, server_designated_connection_id); | 260 EXPECT_EQ(GetPeerInMemoryConnectionId(expected_id), |
| 261 server_designated_connection_id); |
261 EXPECT_FALSE(client_state->has_server_designated_connection_id()); | 262 EXPECT_FALSE(client_state->has_server_designated_connection_id()); |
262 ASSERT_TRUE(client_state->IsComplete(QuicWallTime::FromUNIXSeconds(0))); | 263 ASSERT_TRUE(client_state->IsComplete(QuicWallTime::FromUNIXSeconds(0))); |
263 } | 264 } |
264 | 265 |
265 TEST_P(QuicCryptoServerStreamTest, ConnectedAfterStatelessHandshake) { | 266 TEST_P(QuicCryptoServerStreamTest, ConnectedAfterStatelessHandshake) { |
266 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support = true; | 267 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support = true; |
267 Initialize(); | 268 Initialize(); |
268 | 269 |
269 InitializeFakeClient(/* supports_stateless_rejects= */ true); | 270 InitializeFakeClient(/* supports_stateless_rejects= */ true); |
270 AdvanceHandshakeWithFakeClient(); | 271 AdvanceHandshakeWithFakeClient(); |
271 | 272 |
272 // On the first round, encryption will not be established. | 273 // On the first round, encryption will not be established. |
273 EXPECT_FALSE(server_stream()->encryption_established()); | 274 EXPECT_FALSE(server_stream()->encryption_established()); |
274 EXPECT_FALSE(server_stream()->handshake_confirmed()); | 275 EXPECT_FALSE(server_stream()->handshake_confirmed()); |
275 EXPECT_EQ(1, server_stream()->NumHandshakeMessages()); | 276 EXPECT_EQ(1, server_stream()->NumHandshakeMessages()); |
276 EXPECT_EQ(0, server_stream()->NumHandshakeMessagesWithServerNonces()); | 277 EXPECT_EQ(0, server_stream()->NumHandshakeMessagesWithServerNonces()); |
277 | 278 |
278 // Now check the client state. | 279 // Now check the client state. |
279 QuicCryptoClientConfig::CachedState* client_state = | 280 QuicCryptoClientConfig::CachedState* client_state = |
280 client_crypto_config_.LookupOrCreate(server_id_); | 281 client_crypto_config_.LookupOrCreate(server_id_); |
281 | 282 |
282 ASSERT_TRUE(client_state->has_server_designated_connection_id()); | 283 ASSERT_TRUE(client_state->has_server_designated_connection_id()); |
283 const QuicConnectionId server_designated_connection_id = | 284 const QuicConnectionId server_designated_connection_id = |
284 client_state->GetNextServerDesignatedConnectionId(); | 285 client_state->GetNextServerDesignatedConnectionId(); |
285 const QuicConnectionId expected_id = | 286 const QuicConnectionId expected_id = |
286 server_connection_->random_generator()->RandUint64(); | 287 server_connection_->random_generator()->RandUint64(); |
287 EXPECT_EQ(expected_id, server_designated_connection_id); | 288 EXPECT_EQ(GetPeerInMemoryConnectionId(expected_id), |
| 289 server_designated_connection_id); |
288 EXPECT_FALSE(client_state->has_server_designated_connection_id()); | 290 EXPECT_FALSE(client_state->has_server_designated_connection_id()); |
289 ASSERT_TRUE(client_state->IsComplete(QuicWallTime::FromUNIXSeconds(0))); | 291 ASSERT_TRUE(client_state->IsComplete(QuicWallTime::FromUNIXSeconds(0))); |
290 | 292 |
291 // Now create new client and server streams with the existing config | 293 // Now create new client and server streams with the existing config |
292 // and try the handshake again (0-RTT handshake). | 294 // and try the handshake again (0-RTT handshake). |
293 InitializeServer(); | 295 InitializeServer(); |
294 | 296 |
295 InitializeFakeClient(/* supports_stateless_rejects= */ true); | 297 InitializeFakeClient(/* supports_stateless_rejects= */ true); |
296 // In the stateless case, the second handshake contains a server-nonce, so the | 298 // In the stateless case, the second handshake contains a server-nonce, so the |
297 // AsyncStrikeRegisterVerification() case will still succeed (unlike a 0-RTT | 299 // AsyncStrikeRegisterVerification() case will still succeed (unlike a 0-RTT |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 EXPECT_CALL( | 557 EXPECT_CALL( |
556 *server_connection_, | 558 *server_connection_, |
557 CloseConnection(QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO, | 559 CloseConnection(QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO, |
558 "Unexpected handshake message while processing CHLO", _)); | 560 "Unexpected handshake message while processing CHLO", _)); |
559 server_stream()->OnHandshakeMessage(chlo); | 561 server_stream()->OnHandshakeMessage(chlo); |
560 } | 562 } |
561 | 563 |
562 } // namespace | 564 } // namespace |
563 } // namespace test | 565 } // namespace test |
564 } // namespace net | 566 } // namespace net |
OLD | NEW |