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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // does not allow for clients to send multiple handshake messages | 108 // does not allow for clients to send multiple handshake messages |
109 // before the server has a chance to respond. | 109 // before the server has a chance to respond. |
110 CloseConnectionWithDetails( | 110 CloseConnectionWithDetails( |
111 QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO, | 111 QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO, |
112 "Unexpected handshake message while processing CHLO"); | 112 "Unexpected handshake message while processing CHLO"); |
113 return; | 113 return; |
114 } | 114 } |
115 | 115 |
116 CryptoUtils::HashHandshakeMessage(message, &chlo_hash_); | 116 CryptoUtils::HashHandshakeMessage(message, &chlo_hash_); |
117 | 117 |
118 validate_client_hello_cb_ = new ValidateCallback(this); | 118 std::unique_ptr<ValidateCallback> cb(new ValidateCallback(this)); |
| 119 validate_client_hello_cb_ = cb.get(); |
119 crypto_config_->ValidateClientHello( | 120 crypto_config_->ValidateClientHello( |
120 message, session()->connection()->peer_address().address(), | 121 message, session()->connection()->peer_address().address(), |
121 session()->connection()->self_address().address(), version(), | 122 session()->connection()->self_address().address(), version(), |
122 session()->connection()->clock(), &crypto_proof_, | 123 session()->connection()->clock(), &crypto_proof_, std::move(cb)); |
123 validate_client_hello_cb_); | |
124 } | 124 } |
125 | 125 |
126 void QuicCryptoServerStream::FinishProcessingHandshakeMessage( | 126 void QuicCryptoServerStream::FinishProcessingHandshakeMessage( |
127 const ValidateClientHelloResultCallback::Result& result, | 127 const 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; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::RunImpl( | 431 void QuicCryptoServerStream::ValidateCallback::Run( |
432 std::unique_ptr<Result> result, | 432 std::unique_ptr<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(*result, std::move(details)); |
436 } | 436 } |
437 } | 437 } |
438 | 438 |
439 QuicConnectionId QuicCryptoServerStream::GenerateConnectionIdForReject( | 439 QuicConnectionId QuicCryptoServerStream::GenerateConnectionIdForReject( |
440 bool use_stateless_rejects) { | 440 bool use_stateless_rejects) { |
441 if (!use_stateless_rejects) { | 441 if (!use_stateless_rejects) { |
442 return 0; | 442 return 0; |
443 } | 443 } |
444 return helper_->GenerateConnectionIdForReject( | 444 return helper_->GenerateConnectionIdForReject( |
445 session()->connection()->connection_id()); | 445 session()->connection()->connection_id()); |
446 } | 446 } |
447 | 447 |
448 } // namespace net | 448 } // namespace net |
OLD | NEW |