| 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_client_stream.h" | 5 #include "net/quic/quic_crypto_client_stream.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/profiler/scoped_tracker.h" | 8 #include "base/profiler/scoped_tracker.h" |
| 9 #include "net/quic/crypto/crypto_protocol.h" | 9 #include "net/quic/crypto/crypto_protocol.h" |
| 10 #include "net/quic/crypto/crypto_utils.h" | 10 #include "net/quic/crypto/crypto_utils.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 // If the cached state needs to be verified, do it now. | 239 // If the cached state needs to be verified, do it now. |
| 240 next_state_ = STATE_VERIFY_PROOF; | 240 next_state_ = STATE_VERIFY_PROOF; |
| 241 } else { | 241 } else { |
| 242 next_state_ = STATE_GET_CHANNEL_ID; | 242 next_state_ = STATE_GET_CHANNEL_ID; |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 void QuicCryptoClientStream::DoSendCHLO( | 246 void QuicCryptoClientStream::DoSendCHLO( |
| 247 const CryptoHandshakeMessage* in, | 247 const CryptoHandshakeMessage* in, |
| 248 QuicCryptoClientConfig::CachedState* cached) { | 248 QuicCryptoClientConfig::CachedState* cached) { |
| 249 // TODO(rtenneti): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
| 250 tracked_objects::ScopedTracker tracking_profile1( | |
| 251 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 252 "422516 QuicCryptoClientStream::DoSendCHLO1")); | |
| 253 | |
| 254 // Send the client hello in plaintext. | 249 // Send the client hello in plaintext. |
| 255 session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_NONE); | 250 session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_NONE); |
| 256 if (num_client_hellos_ > kMaxClientHellos) { | 251 if (num_client_hellos_ > kMaxClientHellos) { |
| 257 CloseConnection(QUIC_CRYPTO_TOO_MANY_REJECTS); | 252 CloseConnection(QUIC_CRYPTO_TOO_MANY_REJECTS); |
| 258 return; | 253 return; |
| 259 } | 254 } |
| 260 num_client_hellos_++; | 255 num_client_hellos_++; |
| 261 | 256 |
| 262 CryptoHandshakeMessage out; | 257 CryptoHandshakeMessage out; |
| 263 if (!cached->IsComplete(session()->connection()->clock()->WallNow())) { | 258 if (!cached->IsComplete(session()->connection()->clock()->WallNow())) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 294 session()->connection()->connection_id(), | 289 session()->connection()->connection_id(), |
| 295 session()->connection()->supported_versions().front(), | 290 session()->connection()->supported_versions().front(), |
| 296 cached, | 291 cached, |
| 297 session()->connection()->clock()->WallNow(), | 292 session()->connection()->clock()->WallNow(), |
| 298 session()->connection()->random_generator(), | 293 session()->connection()->random_generator(), |
| 299 channel_id_key_.get(), | 294 channel_id_key_.get(), |
| 300 &crypto_negotiated_params_, | 295 &crypto_negotiated_params_, |
| 301 &out, | 296 &out, |
| 302 &error_details); | 297 &error_details); |
| 303 | 298 |
| 304 // TODO(rtenneti): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
| 305 tracked_objects::ScopedTracker tracking_profile2( | |
| 306 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 307 "422516 QuicCryptoClientStream::DoSendCHLO2")); | |
| 308 | |
| 309 if (error != QUIC_NO_ERROR) { | 299 if (error != QUIC_NO_ERROR) { |
| 310 // Flush the cached config so that, if it's bad, the server has a | 300 // Flush the cached config so that, if it's bad, the server has a |
| 311 // chance to send us another in the future. | 301 // chance to send us another in the future. |
| 312 cached->InvalidateServerConfig(); | 302 cached->InvalidateServerConfig(); |
| 313 CloseConnectionWithDetails(error, error_details); | 303 CloseConnectionWithDetails(error, error_details); |
| 314 return; | 304 return; |
| 315 } | 305 } |
| 316 channel_id_sent_ = (channel_id_key_.get() != nullptr); | 306 channel_id_sent_ = (channel_id_key_.get() != nullptr); |
| 317 if (cached->proof_verify_details()) { | 307 if (cached->proof_verify_details()) { |
| 318 client_session()->OnProofVerifyDetailsAvailable( | 308 client_session()->OnProofVerifyDetailsAvailable( |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 CloseConnectionWithDetails(QUIC_INVALID_CHANNEL_ID_SIGNATURE, | 483 CloseConnectionWithDetails(QUIC_INVALID_CHANNEL_ID_SIGNATURE, |
| 494 "Channel ID lookup failed"); | 484 "Channel ID lookup failed"); |
| 495 return; | 485 return; |
| 496 } | 486 } |
| 497 next_state_ = STATE_SEND_CHLO; | 487 next_state_ = STATE_SEND_CHLO; |
| 498 } | 488 } |
| 499 | 489 |
| 500 void QuicCryptoClientStream::DoReceiveSHLO( | 490 void QuicCryptoClientStream::DoReceiveSHLO( |
| 501 const CryptoHandshakeMessage* in, | 491 const CryptoHandshakeMessage* in, |
| 502 QuicCryptoClientConfig::CachedState* cached) { | 492 QuicCryptoClientConfig::CachedState* cached) { |
| 503 // TODO(rtenneti): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
| 504 tracked_objects::ScopedTracker tracking_profile( | |
| 505 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 506 "422516 QuicCryptoClientStream::DoReceiveSHLO")); | |
| 507 | |
| 508 next_state_ = STATE_NONE; | 493 next_state_ = STATE_NONE; |
| 509 // We sent a CHLO that we expected to be accepted and now we're hoping | 494 // We sent a CHLO that we expected to be accepted and now we're hoping |
| 510 // for a SHLO from the server to confirm that. | 495 // for a SHLO from the server to confirm that. |
| 511 if (in->tag() == kREJ) { | 496 if (in->tag() == kREJ) { |
| 512 // alternative_decrypter will be nullptr if the original alternative | 497 // alternative_decrypter will be nullptr if the original alternative |
| 513 // decrypter latched and became the primary decrypter. That happens | 498 // decrypter latched and became the primary decrypter. That happens |
| 514 // if we received a message encrypted with the INITIAL key. | 499 // if we received a message encrypted with the INITIAL key. |
| 515 if (session()->connection()->alternative_decrypter() == nullptr) { | 500 if (session()->connection()->alternative_decrypter() == nullptr) { |
| 516 // The rejection was sent encrypted! | 501 // The rejection was sent encrypted! |
| 517 CloseConnectionWithDetails(QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT, | 502 CloseConnectionWithDetails(QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 } | 606 } |
| 622 } | 607 } |
| 623 return false; | 608 return false; |
| 624 } | 609 } |
| 625 | 610 |
| 626 QuicClientSessionBase* QuicCryptoClientStream::client_session() { | 611 QuicClientSessionBase* QuicCryptoClientStream::client_session() { |
| 627 return reinterpret_cast<QuicClientSessionBase*>(session()); | 612 return reinterpret_cast<QuicClientSessionBase*>(session()); |
| 628 } | 613 } |
| 629 | 614 |
| 630 } // namespace net | 615 } // namespace net |
| OLD | NEW |