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_server_stream.h" | 5 #include "net/quic/quic_crypto_server_stream.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "crypto/secure_hash.h" | 8 #include "crypto/secure_hash.h" |
9 #include "net/quic/crypto/cached_network_parameters.h" | 9 #include "net/quic/crypto/cached_network_parameters.h" |
10 #include "net/quic/crypto/crypto_protocol.h" | 10 #include "net/quic/crypto/crypto_protocol.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 crypto_negotiated_params_.initial_crypters.encrypter.release()); | 123 crypto_negotiated_params_.initial_crypters.encrypter.release()); |
124 session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); | 124 session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); |
125 // Set the decrypter immediately so that we no longer accept unencrypted | 125 // Set the decrypter immediately so that we no longer accept unencrypted |
126 // packets. | 126 // packets. |
127 session()->connection()->SetDecrypter( | 127 session()->connection()->SetDecrypter( |
128 crypto_negotiated_params_.initial_crypters.decrypter.release(), | 128 crypto_negotiated_params_.initial_crypters.decrypter.release(), |
129 ENCRYPTION_INITIAL); | 129 ENCRYPTION_INITIAL); |
130 | 130 |
131 // We want to be notified when the SHLO is ACKed so that we can disable | 131 // We want to be notified when the SHLO is ACKed so that we can disable |
132 // HANDSHAKE_MODE in the sent packet manager. | 132 // HANDSHAKE_MODE in the sent packet manager. |
133 if (session()->connection()->version() <= QUIC_VERSION_21) { | 133 scoped_refptr<ServerHelloNotifier> server_hello_notifier( |
134 SendHandshakeMessage(reply); | 134 new ServerHelloNotifier(this)); |
135 } else { | 135 SendHandshakeMessage(reply, server_hello_notifier.get()); |
136 scoped_refptr<ServerHelloNotifier> server_hello_notifier( | |
137 new ServerHelloNotifier(this)); | |
138 SendHandshakeMessage(reply, server_hello_notifier.get()); | |
139 } | |
140 | 136 |
141 session()->connection()->SetEncrypter( | 137 session()->connection()->SetEncrypter( |
142 ENCRYPTION_FORWARD_SECURE, | 138 ENCRYPTION_FORWARD_SECURE, |
143 crypto_negotiated_params_.forward_secure_crypters.encrypter.release()); | 139 crypto_negotiated_params_.forward_secure_crypters.encrypter.release()); |
144 session()->connection()->SetAlternativeDecrypter( | 140 session()->connection()->SetAlternativeDecrypter( |
145 crypto_negotiated_params_.forward_secure_crypters.decrypter.release(), | 141 crypto_negotiated_params_.forward_secure_crypters.decrypter.release(), |
146 ENCRYPTION_FORWARD_SECURE, false /* don't latch */); | 142 ENCRYPTION_FORWARD_SECURE, false /* don't latch */); |
147 | 143 |
148 encryption_established_ = true; | 144 encryption_established_ = true; |
149 handshake_confirmed_ = true; | 145 handshake_confirmed_ = true; |
150 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); | 146 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); |
151 } | 147 } |
152 | 148 |
153 void QuicCryptoServerStream::SendServerConfigUpdate( | 149 void QuicCryptoServerStream::SendServerConfigUpdate( |
154 const CachedNetworkParameters* cached_network_params) { | 150 const CachedNetworkParameters* cached_network_params) { |
155 if (session()->connection()->version() <= QUIC_VERSION_21 || | 151 if (!handshake_confirmed_) { |
156 !handshake_confirmed_) { | |
157 return; | 152 return; |
158 } | 153 } |
159 | 154 |
160 CryptoHandshakeMessage server_config_update_message; | 155 CryptoHandshakeMessage server_config_update_message; |
161 if (!crypto_config_.BuildServerConfigUpdateMessage( | 156 if (!crypto_config_.BuildServerConfigUpdateMessage( |
162 previous_source_address_tokens_, | 157 previous_source_address_tokens_, |
163 session()->connection()->self_address(), | 158 session()->connection()->self_address(), |
164 session()->connection()->peer_address(), | 159 session()->connection()->peer_address(), |
165 session()->connection()->clock(), | 160 session()->connection()->clock(), |
166 session()->connection()->random_generator(), | 161 session()->connection()->random_generator(), |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 252 |
258 void QuicCryptoServerStream::ValidateCallback::RunImpl( | 253 void QuicCryptoServerStream::ValidateCallback::RunImpl( |
259 const CryptoHandshakeMessage& client_hello, | 254 const CryptoHandshakeMessage& client_hello, |
260 const Result& result) { | 255 const Result& result) { |
261 if (parent_ != nullptr) { | 256 if (parent_ != nullptr) { |
262 parent_->FinishProcessingHandshakeMessage(client_hello, result); | 257 parent_->FinishProcessingHandshakeMessage(client_hello, result); |
263 } | 258 } |
264 } | 259 } |
265 | 260 |
266 } // namespace net | 261 } // namespace net |
OLD | NEW |