Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: net/quic/quic_crypto_server_stream.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_crypto_server_stream.h ('k') | net/quic/quic_crypto_server_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/crypto_protocol.h" 9 #include "net/quic/crypto/crypto_protocol.h"
10 #include "net/quic/crypto/crypto_utils.h" 10 #include "net/quic/crypto/crypto_utils.h"
11 #include "net/quic/crypto/quic_crypto_server_config.h" 11 #include "net/quic/crypto/quic_crypto_server_config.h"
12 #include "net/quic/crypto/source_address_token.h" 12 #include "net/quic/crypto/source_address_token.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 namespace net { 17 namespace net {
19 18
20 void ServerHelloNotifier::OnAckNotification( 19 void ServerHelloNotifier::OnAckNotification(
21 int num_original_packets, 20 int num_original_packets,
22 int num_original_bytes, 21 int num_original_bytes,
23 int num_retransmitted_packets, 22 int num_retransmitted_packets,
24 int num_retransmitted_bytes, 23 int num_retransmitted_bytes,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 crypto_negotiated_params_.forward_secure_crypters.encrypter.release()); 142 crypto_negotiated_params_.forward_secure_crypters.encrypter.release());
144 session()->connection()->SetDefaultEncryptionLevel( 143 session()->connection()->SetDefaultEncryptionLevel(
145 ENCRYPTION_FORWARD_SECURE); 144 ENCRYPTION_FORWARD_SECURE);
146 session()->connection()->SetAlternativeDecrypter( 145 session()->connection()->SetAlternativeDecrypter(
147 crypto_negotiated_params_.forward_secure_crypters.decrypter.release(), 146 crypto_negotiated_params_.forward_secure_crypters.decrypter.release(),
148 ENCRYPTION_FORWARD_SECURE, false /* don't latch */); 147 ENCRYPTION_FORWARD_SECURE, false /* don't latch */);
149 148
150 encryption_established_ = true; 149 encryption_established_ = true;
151 handshake_confirmed_ = true; 150 handshake_confirmed_ = true;
152 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); 151 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED);
153
154 // Now that the handshake is complete, send an updated server config and
155 // source-address token to the client.
156 SendServerConfigUpdate(previous_cached_network_params_.get(), true);
157 } 152 }
158 153
159 void QuicCryptoServerStream::SendServerConfigUpdate( 154 void QuicCryptoServerStream::SendServerConfigUpdate(
160 const CachedNetworkParameters* cached_network_params, 155 const CachedNetworkParameters* cached_network_params) {
161 bool on_handshake_complete) {
162 if (session()->connection()->version() <= QUIC_VERSION_21 || 156 if (session()->connection()->version() <= QUIC_VERSION_21 ||
163 !handshake_confirmed_) { 157 !handshake_confirmed_) {
164 return; 158 return;
165 } 159 }
166 160
167 CryptoHandshakeMessage server_config_update_message; 161 CryptoHandshakeMessage server_config_update_message;
168 if (!crypto_config_.BuildServerConfigUpdateMessage( 162 if (!crypto_config_.BuildServerConfigUpdateMessage(
169 session()->connection()->peer_address(), 163 session()->connection()->peer_address(),
170 session()->connection()->clock(), 164 session()->connection()->clock(),
171 session()->connection()->random_generator(), 165 session()->connection()->random_generator(),
172 crypto_negotiated_params_, 166 crypto_negotiated_params_,
173 cached_network_params, 167 cached_network_params,
174 &server_config_update_message)) { 168 &server_config_update_message)) {
175 DVLOG(1) << "Server: Failed to build server config update (SCUP)!"; 169 DVLOG(1) << "Server: Failed to build server config update (SCUP)!";
176 return; 170 return;
177 } 171 }
178 172
179 DVLOG(1) << "Server: Sending server config update" 173 DVLOG(1) << "Server: Sending server config update: "
180 << (on_handshake_complete ? " immediately after handshake: " : ": ")
181 << server_config_update_message.DebugString(); 174 << server_config_update_message.DebugString();
182 const QuicData& data = server_config_update_message.GetSerialized(); 175 const QuicData& data = server_config_update_message.GetSerialized();
183 WriteOrBufferData(string(data.data(), data.length()), false, nullptr); 176 WriteOrBufferData(string(data.data(), data.length()), false, nullptr);
184 177
185 ++num_server_config_update_messages_sent_; 178 ++num_server_config_update_messages_sent_;
186 } 179 }
187 180
188 void QuicCryptoServerStream::OnServerHelloAcked() { 181 void QuicCryptoServerStream::OnServerHelloAcked() {
189 session()->connection()->OnHandshakeComplete(); 182 session()->connection()->OnHandshakeComplete();
190 } 183 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 217 }
225 return true; 218 return true;
226 } 219 }
227 220
228 QuicErrorCode QuicCryptoServerStream::ProcessClientHello( 221 QuicErrorCode QuicCryptoServerStream::ProcessClientHello(
229 const CryptoHandshakeMessage& message, 222 const CryptoHandshakeMessage& message,
230 const ValidateClientHelloResultCallback::Result& result, 223 const ValidateClientHelloResultCallback::Result& result,
231 CryptoHandshakeMessage* reply, 224 CryptoHandshakeMessage* reply,
232 string* error_details) { 225 string* error_details) {
233 // Store the bandwidth estimate from the client. 226 // Store the bandwidth estimate from the client.
234 if (FLAGS_quic_store_cached_network_params_from_chlo && 227 if (result.cached_network_params.bandwidth_estimate_bytes_per_second() > 0) {
235 result.cached_network_params.bandwidth_estimate_bytes_per_second() > 0) {
236 previous_cached_network_params_.reset( 228 previous_cached_network_params_.reset(
237 new CachedNetworkParameters(result.cached_network_params)); 229 new CachedNetworkParameters(result.cached_network_params));
238 } 230 }
239 231
240 return crypto_config_.ProcessClientHello( 232 return crypto_config_.ProcessClientHello(
241 result, 233 result,
242 session()->connection()->connection_id(), 234 session()->connection()->connection_id(),
243 session()->connection()->peer_address(), 235 session()->connection()->peer_address(),
244 session()->connection()->version(), 236 session()->connection()->version(),
245 session()->connection()->supported_versions(), 237 session()->connection()->supported_versions(),
(...skipping 18 matching lines...) Expand all
264 256
265 void QuicCryptoServerStream::ValidateCallback::RunImpl( 257 void QuicCryptoServerStream::ValidateCallback::RunImpl(
266 const CryptoHandshakeMessage& client_hello, 258 const CryptoHandshakeMessage& client_hello,
267 const Result& result) { 259 const Result& result) {
268 if (parent_ != nullptr) { 260 if (parent_ != nullptr) {
269 parent_->FinishProcessingHandshakeMessage(client_hello, result); 261 parent_->FinishProcessingHandshakeMessage(client_hello, result);
270 } 262 }
271 } 263 }
272 264
273 } // namespace net 265 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_server_stream.h ('k') | net/quic/quic_crypto_server_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698