| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 std::unique_ptr<ValidateCallback> cb(new ValidateCallback(this)); | 118 std::unique_ptr<ValidateCallback> cb(new ValidateCallback(this)); |
| 119 validate_client_hello_cb_ = cb.get(); | 119 validate_client_hello_cb_ = cb.get(); |
| 120 crypto_config_->ValidateClientHello( | 120 crypto_config_->ValidateClientHello( |
| 121 message, session()->connection()->peer_address().address(), | 121 message, session()->connection()->peer_address().address(), |
| 122 session()->connection()->self_address().address(), version(), | 122 session()->connection()->self_address().address(), version(), |
| 123 session()->connection()->clock(), &crypto_proof_, std::move(cb)); | 123 session()->connection()->clock(), &crypto_proof_, std::move(cb)); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void QuicCryptoServerStream::FinishProcessingHandshakeMessage( | 126 void QuicCryptoServerStream::FinishProcessingHandshakeMessage( |
| 127 const ValidateClientHelloResultCallback::Result& result, | 127 scoped_refptr<ValidateClientHelloResultCallback::Result> result, |
| 128 std::unique_ptr<ProofSource::Details> details) { | 128 std::unique_ptr<ProofSource::Details> details) { |
| 129 const CryptoHandshakeMessage& message = result.client_hello; | 129 const CryptoHandshakeMessage& message = result->client_hello; |
| 130 | 130 |
| 131 // Clear the callback that got us here. | 131 // Clear the callback that got us here. |
| 132 DCHECK(validate_client_hello_cb_ != nullptr); | 132 DCHECK(validate_client_hello_cb_ != nullptr); |
| 133 validate_client_hello_cb_ = nullptr; | 133 validate_client_hello_cb_ = nullptr; |
| 134 | 134 |
| 135 if (use_stateless_rejects_if_peer_supported_) { | 135 if (use_stateless_rejects_if_peer_supported_) { |
| 136 peer_supports_stateless_rejects_ = DoesPeerSupportStatelessRejects(message); | 136 peer_supports_stateless_rejects_ = DoesPeerSupportStatelessRejects(message); |
| 137 } | 137 } |
| 138 | 138 |
| 139 CryptoHandshakeMessage reply; | 139 CryptoHandshakeMessage reply; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 if ((*output)[len - 1] == '=') { | 373 if ((*output)[len - 1] == '=') { |
| 374 len--; | 374 len--; |
| 375 } | 375 } |
| 376 output->resize(len); | 376 output->resize(len); |
| 377 } | 377 } |
| 378 } | 378 } |
| 379 return true; | 379 return true; |
| 380 } | 380 } |
| 381 | 381 |
| 382 QuicErrorCode QuicCryptoServerStream::ProcessClientHello( | 382 QuicErrorCode QuicCryptoServerStream::ProcessClientHello( |
| 383 const ValidateClientHelloResultCallback::Result& result, | 383 scoped_refptr<ValidateClientHelloResultCallback::Result> result, |
| 384 std::unique_ptr<ProofSource::Details> proof_source_details, | 384 std::unique_ptr<ProofSource::Details> proof_source_details, |
| 385 CryptoHandshakeMessage* reply, | 385 CryptoHandshakeMessage* reply, |
| 386 DiversificationNonce* out_diversification_nonce, | 386 DiversificationNonce* out_diversification_nonce, |
| 387 string* error_details) { | 387 string* error_details) { |
| 388 const CryptoHandshakeMessage& message = result.client_hello; | 388 const CryptoHandshakeMessage& message = result->client_hello; |
| 389 if (!helper_->CanAcceptClientHello( | 389 if (!helper_->CanAcceptClientHello( |
| 390 message, session()->connection()->self_address(), error_details)) { | 390 message, session()->connection()->self_address(), error_details)) { |
| 391 return QUIC_HANDSHAKE_FAILED; | 391 return QUIC_HANDSHAKE_FAILED; |
| 392 } | 392 } |
| 393 | 393 |
| 394 if (!result.info.server_nonce.empty()) { | 394 if (!result->info.server_nonce.empty()) { |
| 395 ++num_handshake_messages_with_server_nonces_; | 395 ++num_handshake_messages_with_server_nonces_; |
| 396 } | 396 } |
| 397 // Store the bandwidth estimate from the client. | 397 // Store the bandwidth estimate from the client. |
| 398 if (result.cached_network_params.bandwidth_estimate_bytes_per_second() > 0) { | 398 if (result->cached_network_params.bandwidth_estimate_bytes_per_second() > 0) { |
| 399 previous_cached_network_params_.reset( | 399 previous_cached_network_params_.reset( |
| 400 new CachedNetworkParameters(result.cached_network_params)); | 400 new CachedNetworkParameters(result->cached_network_params)); |
| 401 } | 401 } |
| 402 previous_source_address_tokens_ = result.info.source_address_tokens; | 402 previous_source_address_tokens_ = result->info.source_address_tokens; |
| 403 | 403 |
| 404 const bool use_stateless_rejects_in_crypto_config = | 404 const bool use_stateless_rejects_in_crypto_config = |
| 405 use_stateless_rejects_if_peer_supported_ && | 405 use_stateless_rejects_if_peer_supported_ && |
| 406 peer_supports_stateless_rejects_; | 406 peer_supports_stateless_rejects_; |
| 407 QuicConnection* connection = session()->connection(); | 407 QuicConnection* connection = session()->connection(); |
| 408 const QuicConnectionId server_designated_connection_id = | 408 const QuicConnectionId server_designated_connection_id = |
| 409 GenerateConnectionIdForReject(use_stateless_rejects_in_crypto_config); | 409 GenerateConnectionIdForReject(use_stateless_rejects_in_crypto_config); |
| 410 return crypto_config_->ProcessClientHello( | 410 return crypto_config_->ProcessClientHello( |
| 411 result, /*reject_only=*/false, connection->connection_id(), | 411 result, /*reject_only=*/false, connection->connection_id(), |
| 412 connection->self_address().address(), connection->peer_address(), | 412 connection->self_address().address(), connection->peer_address(), |
| 413 version(), connection->supported_versions(), | 413 version(), connection->supported_versions(), |
| 414 use_stateless_rejects_in_crypto_config, server_designated_connection_id, | 414 use_stateless_rejects_in_crypto_config, server_designated_connection_id, |
| 415 connection->clock(), connection->random_generator(), | 415 connection->clock(), connection->random_generator(), |
| 416 compressed_certs_cache_, &crypto_negotiated_params_, &crypto_proof_, | 416 compressed_certs_cache_, &crypto_negotiated_params_, &crypto_proof_, |
| 417 QuicCryptoStream::CryptoMessageFramingOverhead(version()), | 417 QuicCryptoStream::CryptoMessageFramingOverhead(version()), |
| 418 chlo_packet_size_, reply, out_diversification_nonce, error_details); | 418 chlo_packet_size_, reply, out_diversification_nonce, error_details); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void QuicCryptoServerStream::OverrideQuicConfigDefaults(QuicConfig* config) {} | 421 void QuicCryptoServerStream::OverrideQuicConfigDefaults(QuicConfig* config) {} |
| 422 | 422 |
| 423 QuicCryptoServerStream::ValidateCallback::ValidateCallback( | 423 QuicCryptoServerStream::ValidateCallback::ValidateCallback( |
| 424 QuicCryptoServerStream* parent) | 424 QuicCryptoServerStream* parent) |
| 425 : parent_(parent) {} | 425 : parent_(parent) {} |
| 426 | 426 |
| 427 void QuicCryptoServerStream::ValidateCallback::Cancel() { | 427 void QuicCryptoServerStream::ValidateCallback::Cancel() { |
| 428 parent_ = nullptr; | 428 parent_ = nullptr; |
| 429 } | 429 } |
| 430 | 430 |
| 431 void QuicCryptoServerStream::ValidateCallback::Run( | 431 void QuicCryptoServerStream::ValidateCallback::Run( |
| 432 std::unique_ptr<Result> result, | 432 scoped_refptr<Result> result, |
| 433 std::unique_ptr<ProofSource::Details> details) { | 433 std::unique_ptr<ProofSource::Details> details) { |
| 434 if (parent_ != nullptr) { | 434 if (parent_ != nullptr) { |
| 435 parent_->FinishProcessingHandshakeMessage(*result, std::move(details)); | 435 parent_->FinishProcessingHandshakeMessage(std::move(result), |
| 436 std::move(details)); |
| 436 } | 437 } |
| 437 } | 438 } |
| 438 | 439 |
| 439 QuicConnectionId QuicCryptoServerStream::GenerateConnectionIdForReject( | 440 QuicConnectionId QuicCryptoServerStream::GenerateConnectionIdForReject( |
| 440 bool use_stateless_rejects) { | 441 bool use_stateless_rejects) { |
| 441 if (!use_stateless_rejects) { | 442 if (!use_stateless_rejects) { |
| 442 return 0; | 443 return 0; |
| 443 } | 444 } |
| 444 return helper_->GenerateConnectionIdForReject( | 445 return helper_->GenerateConnectionIdForReject( |
| 445 session()->connection()->connection_id()); | 446 session()->connection()->connection_id()); |
| 446 } | 447 } |
| 447 | 448 |
| 448 } // namespace net | 449 } // namespace net |
| OLD | NEW |