| 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 "net/quic/crypto/crypto_protocol.h" | 8 #include "net/quic/crypto/crypto_protocol.h" |
| 9 #include "net/quic/crypto/crypto_utils.h" | 9 #include "net/quic/crypto/crypto_utils.h" |
| 10 #include "net/quic/crypto/null_encrypter.h" | 10 #include "net/quic/crypto/null_encrypter.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 QuicCryptoClientStream::ProofVerifierCallbackImpl::ProofVerifierCallbackImpl( | 43 QuicCryptoClientStream::ProofVerifierCallbackImpl::ProofVerifierCallbackImpl( |
| 44 QuicCryptoClientStream* stream) | 44 QuicCryptoClientStream* stream) |
| 45 : stream_(stream) {} | 45 : stream_(stream) {} |
| 46 | 46 |
| 47 QuicCryptoClientStream::ProofVerifierCallbackImpl:: | 47 QuicCryptoClientStream::ProofVerifierCallbackImpl:: |
| 48 ~ProofVerifierCallbackImpl() {} | 48 ~ProofVerifierCallbackImpl() {} |
| 49 | 49 |
| 50 void QuicCryptoClientStream::ProofVerifierCallbackImpl::Run( | 50 void QuicCryptoClientStream::ProofVerifierCallbackImpl::Run( |
| 51 bool ok, | 51 bool ok, |
| 52 const string& error_details, | 52 const std::string& error_details, |
| 53 scoped_ptr<ProofVerifyDetails>* details) { | 53 scoped_ptr<ProofVerifyDetails>* details) { |
| 54 if (stream_ == nullptr) { | 54 if (stream_ == nullptr) { |
| 55 return; | 55 return; |
| 56 } | 56 } |
| 57 | 57 |
| 58 stream_->verify_ok_ = ok; | 58 stream_->verify_ok_ = ok; |
| 59 stream_->verify_error_details_ = error_details; | 59 stream_->verify_error_details_ = error_details; |
| 60 stream_->verify_details_.reset(details->release()); | 60 stream_->verify_details_.reset(details->release()); |
| 61 stream_->proof_verify_callback_ = nullptr; | 61 stream_->proof_verify_callback_ = nullptr; |
| 62 stream_->DoHandshakeLoop(nullptr); | 62 stream_->DoHandshakeLoop(nullptr); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 return channel_id_sent_; | 134 return channel_id_sent_; |
| 135 } | 135 } |
| 136 | 136 |
| 137 bool QuicCryptoClientStream::WasChannelIDSourceCallbackRun() const { | 137 bool QuicCryptoClientStream::WasChannelIDSourceCallbackRun() const { |
| 138 return channel_id_source_callback_run_; | 138 return channel_id_source_callback_run_; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void QuicCryptoClientStream::HandleServerConfigUpdateMessage( | 141 void QuicCryptoClientStream::HandleServerConfigUpdateMessage( |
| 142 const CryptoHandshakeMessage& server_config_update) { | 142 const CryptoHandshakeMessage& server_config_update) { |
| 143 DCHECK(server_config_update.tag() == kSCUP); | 143 DCHECK(server_config_update.tag() == kSCUP); |
| 144 string error_details; | 144 std::string error_details; |
| 145 QuicCryptoClientConfig::CachedState* cached = | 145 QuicCryptoClientConfig::CachedState* cached = |
| 146 crypto_config_->LookupOrCreate(server_id_); | 146 crypto_config_->LookupOrCreate(server_id_); |
| 147 QuicErrorCode error = crypto_config_->ProcessServerConfigUpdate( | 147 QuicErrorCode error = crypto_config_->ProcessServerConfigUpdate( |
| 148 server_config_update, | 148 server_config_update, |
| 149 session()->connection()->clock()->WallNow(), | 149 session()->connection()->clock()->WallNow(), |
| 150 cached, | 150 cached, |
| 151 &crypto_negotiated_params_, | 151 &crypto_negotiated_params_, |
| 152 &error_details); | 152 &error_details); |
| 153 | 153 |
| 154 if (error != QUIC_NO_ERROR) { | 154 if (error != QUIC_NO_ERROR) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 CloseConnection(QUIC_INTERNAL_ERROR); | 270 CloseConnection(QUIC_INTERNAL_ERROR); |
| 271 return; | 271 return; |
| 272 } | 272 } |
| 273 out.set_minimum_size(max_packet_size - kFramingOverhead); | 273 out.set_minimum_size(max_packet_size - kFramingOverhead); |
| 274 next_state_ = STATE_RECV_REJ; | 274 next_state_ = STATE_RECV_REJ; |
| 275 SendHandshakeMessage(out); | 275 SendHandshakeMessage(out); |
| 276 return; | 276 return; |
| 277 } | 277 } |
| 278 | 278 |
| 279 session()->config()->ToHandshakeMessage(&out); | 279 session()->config()->ToHandshakeMessage(&out); |
| 280 string error_details; | 280 std::string error_details; |
| 281 QuicErrorCode error = crypto_config_->FillClientHello( | 281 QuicErrorCode error = crypto_config_->FillClientHello( |
| 282 server_id_, | 282 server_id_, |
| 283 session()->connection()->connection_id(), | 283 session()->connection()->connection_id(), |
| 284 session()->connection()->supported_versions().front(), | 284 session()->connection()->supported_versions().front(), |
| 285 cached, | 285 cached, |
| 286 session()->connection()->clock()->WallNow(), | 286 session()->connection()->clock()->WallNow(), |
| 287 session()->connection()->random_generator(), | 287 session()->connection()->random_generator(), |
| 288 channel_id_key_.get(), | 288 channel_id_key_.get(), |
| 289 &crypto_negotiated_params_, | 289 &crypto_negotiated_params_, |
| 290 &out, | 290 &out, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // We sent a dummy CHLO because we didn't have enough information to | 331 // We sent a dummy CHLO because we didn't have enough information to |
| 332 // perform a handshake, or we sent a full hello that the server | 332 // perform a handshake, or we sent a full hello that the server |
| 333 // rejected. Here we hope to have a REJ that contains the information | 333 // rejected. Here we hope to have a REJ that contains the information |
| 334 // that we need. | 334 // that we need. |
| 335 if (in->tag() != kREJ) { | 335 if (in->tag() != kREJ) { |
| 336 next_state_ = STATE_NONE; | 336 next_state_ = STATE_NONE; |
| 337 CloseConnectionWithDetails(QUIC_INVALID_CRYPTO_MESSAGE_TYPE, | 337 CloseConnectionWithDetails(QUIC_INVALID_CRYPTO_MESSAGE_TYPE, |
| 338 "Expected REJ"); | 338 "Expected REJ"); |
| 339 return; | 339 return; |
| 340 } | 340 } |
| 341 string error_details; | 341 std::string error_details; |
| 342 QuicErrorCode error = crypto_config_->ProcessRejection( | 342 QuicErrorCode error = crypto_config_->ProcessRejection( |
| 343 *in, session()->connection()->clock()->WallNow(), cached, | 343 *in, session()->connection()->clock()->WallNow(), cached, |
| 344 server_id_.is_https(), &crypto_negotiated_params_, &error_details); | 344 server_id_.is_https(), &crypto_negotiated_params_, &error_details); |
| 345 if (error != QUIC_NO_ERROR) { | 345 if (error != QUIC_NO_ERROR) { |
| 346 next_state_ = STATE_NONE; | 346 next_state_ = STATE_NONE; |
| 347 CloseConnectionWithDetails(error, error_details); | 347 CloseConnectionWithDetails(error, error_details); |
| 348 return; | 348 return; |
| 349 } | 349 } |
| 350 if (!cached->proof_valid()) { | 350 if (!cached->proof_valid()) { |
| 351 if (!server_id_.is_https()) { | 351 if (!server_id_.is_https()) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 // alternative_decrypter will be nullptr if the original alternative | 502 // alternative_decrypter will be nullptr if the original alternative |
| 503 // decrypter latched and became the primary decrypter. That happens | 503 // decrypter latched and became the primary decrypter. That happens |
| 504 // if we received a message encrypted with the INITIAL key. | 504 // if we received a message encrypted with the INITIAL key. |
| 505 if (session()->connection()->alternative_decrypter() != nullptr) { | 505 if (session()->connection()->alternative_decrypter() != nullptr) { |
| 506 // The server hello was sent without encryption. | 506 // The server hello was sent without encryption. |
| 507 CloseConnectionWithDetails(QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT, | 507 CloseConnectionWithDetails(QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT, |
| 508 "unencrypted SHLO message"); | 508 "unencrypted SHLO message"); |
| 509 return; | 509 return; |
| 510 } | 510 } |
| 511 | 511 |
| 512 string error_details; | 512 std::string error_details; |
| 513 QuicErrorCode error = crypto_config_->ProcessServerHello( | 513 QuicErrorCode error = crypto_config_->ProcessServerHello( |
| 514 *in, session()->connection()->connection_id(), | 514 *in, session()->connection()->connection_id(), |
| 515 session()->connection()->server_supported_versions(), | 515 session()->connection()->server_supported_versions(), |
| 516 cached, &crypto_negotiated_params_, &error_details); | 516 cached, &crypto_negotiated_params_, &error_details); |
| 517 | 517 |
| 518 if (error != QUIC_NO_ERROR) { | 518 if (error != QUIC_NO_ERROR) { |
| 519 CloseConnectionWithDetails(error, "Server hello invalid: " + error_details); | 519 CloseConnectionWithDetails(error, "Server hello invalid: " + error_details); |
| 520 return; | 520 return; |
| 521 } | 521 } |
| 522 error = session()->config()->ProcessPeerHello(*in, SERVER, &error_details); | 522 error = session()->config()->ProcessPeerHello(*in, SERVER, &error_details); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 } | 592 } |
| 593 } | 593 } |
| 594 return false; | 594 return false; |
| 595 } | 595 } |
| 596 | 596 |
| 597 QuicClientSessionBase* QuicCryptoClientStream::client_session() { | 597 QuicClientSessionBase* QuicCryptoClientStream::client_session() { |
| 598 return reinterpret_cast<QuicClientSessionBase*>(session()); | 598 return reinterpret_cast<QuicClientSessionBase*>(session()); |
| 599 } | 599 } |
| 600 | 600 |
| 601 } // namespace net | 601 } // namespace net |
| OLD | NEW |