| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "crypto/secure_hash.h" | 10 #include "crypto/secure_hash.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 namespace net { | 24 namespace net { |
| 25 | 25 |
| 26 class QuicCryptoServerStream::ProcessClientHelloCallback | 26 class QuicCryptoServerStream::ProcessClientHelloCallback |
| 27 : public ProcessClientHelloResultCallback { | 27 : public ProcessClientHelloResultCallback { |
| 28 public: | 28 public: |
| 29 ProcessClientHelloCallback( | 29 ProcessClientHelloCallback( |
| 30 QuicCryptoServerStream* stream, | 30 QuicCryptoServerStream* stream, |
| 31 const scoped_refptr<ValidateClientHelloResultCallback::Result>& result) | 31 const scoped_refptr<ValidateClientHelloResultCallback::Result>& result) |
| 32 : stream_(stream), result_(result) {} | 32 : stream_(stream), result_(result) {} |
| 33 | 33 |
| 34 void Run( | 34 void Run(QuicErrorCode error, |
| 35 QuicErrorCode error, | 35 const string& error_details, |
| 36 const string& error_details, | 36 std::unique_ptr<CryptoHandshakeMessage> message, |
| 37 std::unique_ptr<CryptoHandshakeMessage> message, | 37 std::unique_ptr<DiversificationNonce> diversification_nonce, |
| 38 std::unique_ptr<DiversificationNonce> diversification_nonce) override { | 38 std::unique_ptr<net::ProofSource::Details> proof_source_details) |
| 39 override { |
| 39 if (stream_ == nullptr) { | 40 if (stream_ == nullptr) { |
| 40 return; | 41 return; |
| 41 } | 42 } |
| 42 | 43 |
| 43 // Note: set the parent's callback to nullptr here because | 44 // Note: set the parent's callback to nullptr here because |
| 44 // FinishProcessingHandshakeMessageAfterProcessClientHello can be invoked | 45 // FinishProcessingHandshakeMessageAfterProcessClientHello can be invoked |
| 45 // from either synchronous or asynchronous codepaths. When the synchronous | 46 // from either synchronous or asynchronous codepaths. When the synchronous |
| 46 // codepaths are removed, this assignment should move to | 47 // codepaths are removed, this assignment should move to |
| 47 // FinishProcessingHandshakeMessageAfterProcessClientHello. | 48 // FinishProcessingHandshakeMessageAfterProcessClientHello. |
| 48 stream_->process_client_hello_cb_ = nullptr; | 49 stream_->process_client_hello_cb_ = nullptr; |
| 49 | 50 |
| 50 stream_->FinishProcessingHandshakeMessageAfterProcessClientHello( | 51 stream_->FinishProcessingHandshakeMessageAfterProcessClientHello( |
| 51 *result_, error, error_details, std::move(message), | 52 *result_, error, error_details, std::move(message), |
| 52 std::move(diversification_nonce)); | 53 std::move(diversification_nonce), std::move(proof_source_details)); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void Cancel() { stream_ = nullptr; } | 56 void Cancel() { stream_ = nullptr; } |
| 56 | 57 |
| 57 private: | 58 private: |
| 58 QuicCryptoServerStream* stream_; | 59 QuicCryptoServerStream* stream_; |
| 59 scoped_refptr<ValidateClientHelloResultCallback::Result> result_; | 60 scoped_refptr<ValidateClientHelloResultCallback::Result> result_; |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 QuicCryptoServerStreamBase::QuicCryptoServerStreamBase(QuicSession* session) | 63 QuicCryptoServerStreamBase::QuicCryptoServerStreamBase(QuicSession* session) |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 process_client_hello_cb_ = cb.get(); | 184 process_client_hello_cb_ = cb.get(); |
| 184 ProcessClientHello(result, std::move(details), std::move(cb)); | 185 ProcessClientHello(result, std::move(details), std::move(cb)); |
| 185 } | 186 } |
| 186 | 187 |
| 187 void QuicCryptoServerStream:: | 188 void QuicCryptoServerStream:: |
| 188 FinishProcessingHandshakeMessageAfterProcessClientHello( | 189 FinishProcessingHandshakeMessageAfterProcessClientHello( |
| 189 const ValidateClientHelloResultCallback::Result& result, | 190 const ValidateClientHelloResultCallback::Result& result, |
| 190 QuicErrorCode error, | 191 QuicErrorCode error, |
| 191 const string& error_details, | 192 const string& error_details, |
| 192 std::unique_ptr<CryptoHandshakeMessage> reply, | 193 std::unique_ptr<CryptoHandshakeMessage> reply, |
| 193 std::unique_ptr<DiversificationNonce> diversification_nonce) { | 194 std::unique_ptr<DiversificationNonce> diversification_nonce, |
| 195 std::unique_ptr<ProofSource::Details> proof_source_details) { |
| 194 const CryptoHandshakeMessage& message = result.client_hello; | 196 const CryptoHandshakeMessage& message = result.client_hello; |
| 195 if (error != QUIC_NO_ERROR) { | 197 if (error != QUIC_NO_ERROR) { |
| 196 CloseConnectionWithDetails(error, error_details); | 198 CloseConnectionWithDetails(error, error_details); |
| 197 return; | 199 return; |
| 198 } | 200 } |
| 199 | 201 |
| 200 if (reply->tag() != kSHLO) { | 202 if (reply->tag() != kSHLO) { |
| 201 if (reply->tag() == kSREJ) { | 203 if (reply->tag() == kSREJ) { |
| 202 DCHECK(use_stateless_rejects_if_peer_supported_); | 204 DCHECK(use_stateless_rejects_if_peer_supported_); |
| 203 DCHECK(peer_supports_stateless_rejects_); | 205 DCHECK(peer_supports_stateless_rejects_); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 } | 441 } |
| 440 | 442 |
| 441 void QuicCryptoServerStream::ProcessClientHello( | 443 void QuicCryptoServerStream::ProcessClientHello( |
| 442 scoped_refptr<ValidateClientHelloResultCallback::Result> result, | 444 scoped_refptr<ValidateClientHelloResultCallback::Result> result, |
| 443 std::unique_ptr<ProofSource::Details> proof_source_details, | 445 std::unique_ptr<ProofSource::Details> proof_source_details, |
| 444 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) { | 446 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) { |
| 445 const CryptoHandshakeMessage& message = result->client_hello; | 447 const CryptoHandshakeMessage& message = result->client_hello; |
| 446 string error_details; | 448 string error_details; |
| 447 if (!helper_->CanAcceptClientHello( | 449 if (!helper_->CanAcceptClientHello( |
| 448 message, session()->connection()->self_address(), &error_details)) { | 450 message, session()->connection()->self_address(), &error_details)) { |
| 449 done_cb->Run(QUIC_HANDSHAKE_FAILED, error_details, nullptr, nullptr); | 451 done_cb->Run(QUIC_HANDSHAKE_FAILED, error_details, nullptr, nullptr, |
| 452 nullptr); |
| 450 return; | 453 return; |
| 451 } | 454 } |
| 452 | 455 |
| 453 if (!result->info.server_nonce.empty()) { | 456 if (!result->info.server_nonce.empty()) { |
| 454 ++num_handshake_messages_with_server_nonces_; | 457 ++num_handshake_messages_with_server_nonces_; |
| 455 } | 458 } |
| 456 // Store the bandwidth estimate from the client. | 459 // Store the bandwidth estimate from the client. |
| 457 if (result->cached_network_params.bandwidth_estimate_bytes_per_second() > 0) { | 460 if (result->cached_network_params.bandwidth_estimate_bytes_per_second() > 0) { |
| 458 previous_cached_network_params_.reset( | 461 previous_cached_network_params_.reset( |
| 459 new CachedNetworkParameters(result->cached_network_params)); | 462 new CachedNetworkParameters(result->cached_network_params)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 QuicConnectionId QuicCryptoServerStream::GenerateConnectionIdForReject( | 502 QuicConnectionId QuicCryptoServerStream::GenerateConnectionIdForReject( |
| 500 bool use_stateless_rejects) { | 503 bool use_stateless_rejects) { |
| 501 if (!use_stateless_rejects) { | 504 if (!use_stateless_rejects) { |
| 502 return 0; | 505 return 0; |
| 503 } | 506 } |
| 504 return helper_->GenerateConnectionIdForReject( | 507 return helper_->GenerateConnectionIdForReject( |
| 505 session()->connection()->connection_id()); | 508 session()->connection()->connection_id()); |
| 506 } | 509 } |
| 507 | 510 |
| 508 } // namespace net | 511 } // namespace net |
| OLD | NEW |