| 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_client_stream.h" | 5 #include "net/quic/core/quic_crypto_client_stream.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
| 11 #include "base/trace_event/trace_event.h" |
| 11 #include "net/quic/core/crypto/crypto_protocol.h" | 12 #include "net/quic/core/crypto/crypto_protocol.h" |
| 12 #include "net/quic/core/crypto/crypto_utils.h" | 13 #include "net/quic/core/crypto/crypto_utils.h" |
| 13 #include "net/quic/core/crypto/null_encrypter.h" | 14 #include "net/quic/core/crypto/null_encrypter.h" |
| 14 #include "net/quic/core/quic_packets.h" | 15 #include "net/quic/core/quic_packets.h" |
| 15 #include "net/quic/core/quic_session.h" | 16 #include "net/quic/core/quic_session.h" |
| 16 #include "net/quic/core/quic_utils.h" | 17 #include "net/quic/core/quic_utils.h" |
| 17 #include "net/quic/platform/api/quic_flags.h" | 18 #include "net/quic/platform/api/quic_flags.h" |
| 18 #include "net/quic/platform/api/quic_logging.h" | 19 #include "net/quic/platform/api/quic_logging.h" |
| 19 #include "net/quic/platform/api/quic_str_cat.h" | 20 #include "net/quic/platform/api/quic_str_cat.h" |
| 20 | 21 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 if (channel_id_source_callback_) { | 111 if (channel_id_source_callback_) { |
| 111 channel_id_source_callback_->Cancel(); | 112 channel_id_source_callback_->Cancel(); |
| 112 } | 113 } |
| 113 if (proof_verify_callback_) { | 114 if (proof_verify_callback_) { |
| 114 proof_verify_callback_->Cancel(); | 115 proof_verify_callback_->Cancel(); |
| 115 } | 116 } |
| 116 } | 117 } |
| 117 | 118 |
| 118 void QuicCryptoClientStream::OnHandshakeMessage( | 119 void QuicCryptoClientStream::OnHandshakeMessage( |
| 119 const CryptoHandshakeMessage& message) { | 120 const CryptoHandshakeMessage& message) { |
| 121 TRACE_EVENT1("net", "QuicCryptoClientStream::OnHandshakeMessage", "host", |
| 122 server_id_.host()); |
| 120 QuicCryptoClientStreamBase::OnHandshakeMessage(message); | 123 QuicCryptoClientStreamBase::OnHandshakeMessage(message); |
| 121 | 124 |
| 122 if (message.tag() == kSCUP) { | 125 if (message.tag() == kSCUP) { |
| 123 if (!handshake_confirmed()) { | 126 if (!handshake_confirmed()) { |
| 124 CloseConnectionWithDetails(QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE, | 127 CloseConnectionWithDetails(QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE, |
| 125 "Early SCUP disallowed"); | 128 "Early SCUP disallowed"); |
| 126 return; | 129 return; |
| 127 } | 130 } |
| 128 | 131 |
| 129 // |message| is an update from the server, so we treat it differently from a | 132 // |message| is an update from the server, so we treat it differently from a |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 188 |
| 186 DCHECK(handshake_confirmed()); | 189 DCHECK(handshake_confirmed()); |
| 187 if (proof_verify_callback_) { | 190 if (proof_verify_callback_) { |
| 188 proof_verify_callback_->Cancel(); | 191 proof_verify_callback_->Cancel(); |
| 189 } | 192 } |
| 190 next_state_ = STATE_INITIALIZE_SCUP; | 193 next_state_ = STATE_INITIALIZE_SCUP; |
| 191 DoHandshakeLoop(nullptr); | 194 DoHandshakeLoop(nullptr); |
| 192 } | 195 } |
| 193 | 196 |
| 194 void QuicCryptoClientStream::DoHandshakeLoop(const CryptoHandshakeMessage* in) { | 197 void QuicCryptoClientStream::DoHandshakeLoop(const CryptoHandshakeMessage* in) { |
| 198 TRACE_EVENT1("net", "QuicCryptoClientStream::DoHandshakeLoop", "host", |
| 199 server_id_.host()); |
| 195 QuicCryptoClientConfig::CachedState* cached = | 200 QuicCryptoClientConfig::CachedState* cached = |
| 196 crypto_config_->LookupOrCreate(server_id_); | 201 crypto_config_->LookupOrCreate(server_id_); |
| 197 | 202 |
| 198 QuicAsyncStatus rv = QUIC_SUCCESS; | 203 QuicAsyncStatus rv = QUIC_SUCCESS; |
| 199 do { | 204 do { |
| 200 CHECK_NE(STATE_NONE, next_state_); | 205 CHECK_NE(STATE_NONE, next_state_); |
| 201 const State state = next_state_; | 206 const State state = next_state_; |
| 202 next_state_ = STATE_IDLE; | 207 next_state_ = STATE_IDLE; |
| 203 rv = QUIC_SUCCESS; | 208 rv = QUIC_SUCCESS; |
| 204 switch (state) { | 209 switch (state) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 chlo_hash_ = cached->chlo_hash(); | 259 chlo_hash_ = cached->chlo_hash(); |
| 255 // If the cached state needs to be verified, do it now. | 260 // If the cached state needs to be verified, do it now. |
| 256 next_state_ = STATE_VERIFY_PROOF; | 261 next_state_ = STATE_VERIFY_PROOF; |
| 257 } else { | 262 } else { |
| 258 next_state_ = STATE_GET_CHANNEL_ID; | 263 next_state_ = STATE_GET_CHANNEL_ID; |
| 259 } | 264 } |
| 260 } | 265 } |
| 261 | 266 |
| 262 void QuicCryptoClientStream::DoSendCHLO( | 267 void QuicCryptoClientStream::DoSendCHLO( |
| 263 QuicCryptoClientConfig::CachedState* cached) { | 268 QuicCryptoClientConfig::CachedState* cached) { |
| 269 TRACE_EVENT1("net", "QuicCryptoClientStream::DoSendCHLO", "host", |
| 270 server_id_.host()); |
| 264 if (stateless_reject_received_) { | 271 if (stateless_reject_received_) { |
| 265 // If we've gotten to this point, we've sent at least one hello | 272 // If we've gotten to this point, we've sent at least one hello |
| 266 // and received a stateless reject in response. We cannot | 273 // and received a stateless reject in response. We cannot |
| 267 // continue to send hellos because the server has abandoned state | 274 // continue to send hellos because the server has abandoned state |
| 268 // for this connection. Abandon further handshakes. | 275 // for this connection. Abandon further handshakes. |
| 269 next_state_ = STATE_NONE; | 276 next_state_ = STATE_NONE; |
| 270 if (session()->connection()->connected()) { | 277 if (session()->connection()->connected()) { |
| 271 session()->connection()->CloseConnection( | 278 session()->connection()->CloseConnection( |
| 272 QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, "stateless reject received", | 279 QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, "stateless reject received", |
| 273 ConnectionCloseBehavior::SILENT_CLOSE); | 280 ConnectionCloseBehavior::SILENT_CLOSE); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 // has happened since then. | 447 // has happened since then. |
| 441 next_state_ = STATE_VERIFY_PROOF; | 448 next_state_ = STATE_VERIFY_PROOF; |
| 442 return; | 449 return; |
| 443 } | 450 } |
| 444 } | 451 } |
| 445 next_state_ = STATE_GET_CHANNEL_ID; | 452 next_state_ = STATE_GET_CHANNEL_ID; |
| 446 } | 453 } |
| 447 | 454 |
| 448 QuicAsyncStatus QuicCryptoClientStream::DoVerifyProof( | 455 QuicAsyncStatus QuicCryptoClientStream::DoVerifyProof( |
| 449 QuicCryptoClientConfig::CachedState* cached) { | 456 QuicCryptoClientConfig::CachedState* cached) { |
| 457 TRACE_EVENT1("net", "QuicCryptoClientStream::DoVerifyProof", "host", |
| 458 server_id_.host()); |
| 450 ProofVerifier* verifier = crypto_config_->proof_verifier(); | 459 ProofVerifier* verifier = crypto_config_->proof_verifier(); |
| 451 DCHECK(verifier); | 460 DCHECK(verifier); |
| 452 next_state_ = STATE_VERIFY_PROOF_COMPLETE; | 461 next_state_ = STATE_VERIFY_PROOF_COMPLETE; |
| 453 generation_counter_ = cached->generation_counter(); | 462 generation_counter_ = cached->generation_counter(); |
| 454 | 463 |
| 455 ProofVerifierCallbackImpl* proof_verify_callback = | 464 ProofVerifierCallbackImpl* proof_verify_callback = |
| 456 new ProofVerifierCallbackImpl(this); | 465 new ProofVerifierCallbackImpl(this); |
| 457 | 466 |
| 458 verify_ok_ = false; | 467 verify_ok_ = false; |
| 459 | 468 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 } | 680 } |
| 672 for (size_t i = 0; i < num_their_proof_demands; i++) { | 681 for (size_t i = 0; i < num_their_proof_demands; i++) { |
| 673 if (their_proof_demands[i] == kCHID) { | 682 if (their_proof_demands[i] == kCHID) { |
| 674 return true; | 683 return true; |
| 675 } | 684 } |
| 676 } | 685 } |
| 677 return false; | 686 return false; |
| 678 } | 687 } |
| 679 | 688 |
| 680 } // namespace net | 689 } // namespace net |
| OLD | NEW |