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" |
11 #include "net/quic/crypto/crypto_utils.h" | 11 #include "net/quic/crypto/crypto_utils.h" |
12 #include "net/quic/crypto/quic_crypto_server_config.h" | 12 #include "net/quic/crypto/quic_crypto_server_config.h" |
13 #include "net/quic/quic_config.h" | 13 #include "net/quic/quic_config.h" |
14 #include "net/quic/quic_flags.h" | |
15 #include "net/quic/quic_protocol.h" | 14 #include "net/quic/quic_protocol.h" |
16 #include "net/quic/quic_session.h" | 15 #include "net/quic/quic_session.h" |
17 | 16 |
18 using std::string; | 17 using std::string; |
19 | 18 |
20 namespace net { | 19 namespace net { |
21 | 20 |
22 void ServerHelloNotifier::OnAckNotification( | 21 void ServerHelloNotifier::OnAckNotification( |
23 int num_original_packets, | 22 int num_original_packets, |
24 int num_original_bytes, | 23 int num_original_bytes, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 SendHandshakeMessage(reply); | 134 SendHandshakeMessage(reply); |
136 } else { | 135 } else { |
137 scoped_refptr<ServerHelloNotifier> server_hello_notifier( | 136 scoped_refptr<ServerHelloNotifier> server_hello_notifier( |
138 new ServerHelloNotifier(this)); | 137 new ServerHelloNotifier(this)); |
139 SendHandshakeMessage(reply, server_hello_notifier.get()); | 138 SendHandshakeMessage(reply, server_hello_notifier.get()); |
140 } | 139 } |
141 | 140 |
142 session()->connection()->SetEncrypter( | 141 session()->connection()->SetEncrypter( |
143 ENCRYPTION_FORWARD_SECURE, | 142 ENCRYPTION_FORWARD_SECURE, |
144 crypto_negotiated_params_.forward_secure_crypters.encrypter.release()); | 143 crypto_negotiated_params_.forward_secure_crypters.encrypter.release()); |
145 if (!FLAGS_enable_quic_delay_forward_security) { | |
146 session()->connection()->SetDefaultEncryptionLevel( | |
147 ENCRYPTION_FORWARD_SECURE); | |
148 } | |
149 session()->connection()->SetAlternativeDecrypter( | 144 session()->connection()->SetAlternativeDecrypter( |
150 crypto_negotiated_params_.forward_secure_crypters.decrypter.release(), | 145 crypto_negotiated_params_.forward_secure_crypters.decrypter.release(), |
151 ENCRYPTION_FORWARD_SECURE, false /* don't latch */); | 146 ENCRYPTION_FORWARD_SECURE, false /* don't latch */); |
152 | 147 |
153 encryption_established_ = true; | 148 encryption_established_ = true; |
154 handshake_confirmed_ = true; | 149 handshake_confirmed_ = true; |
155 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); | 150 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); |
156 } | 151 } |
157 | 152 |
158 void QuicCryptoServerStream::SendServerConfigUpdate( | 153 void QuicCryptoServerStream::SendServerConfigUpdate( |
159 const CachedNetworkParameters* cached_network_params) { | 154 const CachedNetworkParameters* cached_network_params) { |
160 if (session()->connection()->version() <= QUIC_VERSION_21 || | 155 if (session()->connection()->version() <= QUIC_VERSION_21 || |
161 !handshake_confirmed_) { | 156 !handshake_confirmed_) { |
162 return; | 157 return; |
163 } | 158 } |
164 | 159 |
165 CryptoHandshakeMessage server_config_update_message; | 160 CryptoHandshakeMessage server_config_update_message; |
166 if (!crypto_config_.BuildServerConfigUpdateMessage( | 161 if (!crypto_config_.BuildServerConfigUpdateMessage( |
| 162 previous_source_address_tokens_, |
167 session()->connection()->self_address(), | 163 session()->connection()->self_address(), |
168 session()->connection()->peer_address(), | 164 session()->connection()->peer_address(), |
169 session()->connection()->clock(), | 165 session()->connection()->clock(), |
170 session()->connection()->random_generator(), | 166 session()->connection()->random_generator(), |
171 crypto_negotiated_params_, cached_network_params, | 167 crypto_negotiated_params_, cached_network_params, |
172 &server_config_update_message)) { | 168 &server_config_update_message)) { |
173 DVLOG(1) << "Server: Failed to build server config update (SCUP)!"; | 169 DVLOG(1) << "Server: Failed to build server config update (SCUP)!"; |
174 return; | 170 return; |
175 } | 171 } |
176 | 172 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 QuicErrorCode QuicCryptoServerStream::ProcessClientHello( | 221 QuicErrorCode QuicCryptoServerStream::ProcessClientHello( |
226 const CryptoHandshakeMessage& message, | 222 const CryptoHandshakeMessage& message, |
227 const ValidateClientHelloResultCallback::Result& result, | 223 const ValidateClientHelloResultCallback::Result& result, |
228 CryptoHandshakeMessage* reply, | 224 CryptoHandshakeMessage* reply, |
229 string* error_details) { | 225 string* error_details) { |
230 // Store the bandwidth estimate from the client. | 226 // Store the bandwidth estimate from the client. |
231 if (result.cached_network_params.bandwidth_estimate_bytes_per_second() > 0) { | 227 if (result.cached_network_params.bandwidth_estimate_bytes_per_second() > 0) { |
232 previous_cached_network_params_.reset( | 228 previous_cached_network_params_.reset( |
233 new CachedNetworkParameters(result.cached_network_params)); | 229 new CachedNetworkParameters(result.cached_network_params)); |
234 } | 230 } |
| 231 previous_source_address_tokens_ = result.info.source_address_tokens; |
235 | 232 |
236 return crypto_config_.ProcessClientHello( | 233 return crypto_config_.ProcessClientHello( |
237 result, session()->connection()->connection_id(), | 234 result, session()->connection()->connection_id(), |
238 session()->connection()->self_address(), | 235 session()->connection()->self_address(), |
239 session()->connection()->peer_address(), | 236 session()->connection()->peer_address(), |
240 session()->connection()->version(), | 237 session()->connection()->version(), |
241 session()->connection()->supported_versions(), | 238 session()->connection()->supported_versions(), |
242 session()->connection()->clock(), | 239 session()->connection()->clock(), |
243 session()->connection()->random_generator(), &crypto_negotiated_params_, | 240 session()->connection()->random_generator(), &crypto_negotiated_params_, |
244 reply, error_details); | 241 reply, error_details); |
(...skipping 15 matching lines...) Expand all Loading... |
260 | 257 |
261 void QuicCryptoServerStream::ValidateCallback::RunImpl( | 258 void QuicCryptoServerStream::ValidateCallback::RunImpl( |
262 const CryptoHandshakeMessage& client_hello, | 259 const CryptoHandshakeMessage& client_hello, |
263 const Result& result) { | 260 const Result& result) { |
264 if (parent_ != nullptr) { | 261 if (parent_ != nullptr) { |
265 parent_->FinishProcessingHandshakeMessage(client_hello, result); | 262 parent_->FinishProcessingHandshakeMessage(client_hello, result); |
266 } | 263 } |
267 } | 264 } |
268 | 265 |
269 } // namespace net | 266 } // namespace net |
OLD | NEW |