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

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

Issue 449273002: Along with sending the SCUP message, this CL includes small fixes which (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Trigger_QUIC_tracegraf_72571464
Patch Set: Created 6 years, 4 months 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/quic_config.h" 12 #include "net/quic/quic_config.h"
13 #include "net/quic/quic_protocol.h" 13 #include "net/quic/quic_protocol.h"
14 #include "net/quic/quic_session.h" 14 #include "net/quic/quic_session.h"
15 15
16 namespace net { 16 namespace net {
17 17
18 void ServerHelloNotifier::OnAckNotification(
19 int num_original_packets,
20 int num_original_bytes,
21 int num_retransmitted_packets,
22 int num_retransmitted_bytes,
23 QuicTime::Delta delta_largest_observed) {
24 server_stream_->OnServerHelloAcked();
25 }
26
18 QuicCryptoServerStream::QuicCryptoServerStream( 27 QuicCryptoServerStream::QuicCryptoServerStream(
19 const QuicCryptoServerConfig& crypto_config, 28 const QuicCryptoServerConfig& crypto_config,
20 QuicSession* session) 29 QuicSession* session)
21 : QuicCryptoStream(session), 30 : QuicCryptoStream(session),
22 crypto_config_(crypto_config), 31 crypto_config_(crypto_config),
23 validate_client_hello_cb_(NULL), 32 validate_client_hello_cb_(NULL),
24 num_handshake_messages_(0) { 33 num_handshake_messages_(0),
34 num_server_config_update_messages_sent_(0) {
25 } 35 }
26 36
27 QuicCryptoServerStream::~QuicCryptoServerStream() { 37 QuicCryptoServerStream::~QuicCryptoServerStream() {
28 CancelOutstandingCallbacks(); 38 CancelOutstandingCallbacks();
29 } 39 }
30 40
31 void QuicCryptoServerStream::CancelOutstandingCallbacks() { 41 void QuicCryptoServerStream::CancelOutstandingCallbacks() {
32 // Detach from the validation callback. Calling this multiple times is safe. 42 // Detach from the validation callback. Calling this multiple times is safe.
33 if (validate_client_hello_cb_ != NULL) { 43 if (validate_client_hello_cb_ != NULL) {
34 validate_client_hello_cb_->Cancel(); 44 validate_client_hello_cb_->Cancel();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 session()->connection()->SetEncrypter( 119 session()->connection()->SetEncrypter(
110 ENCRYPTION_INITIAL, 120 ENCRYPTION_INITIAL,
111 crypto_negotiated_params_.initial_crypters.encrypter.release()); 121 crypto_negotiated_params_.initial_crypters.encrypter.release());
112 session()->connection()->SetDefaultEncryptionLevel( 122 session()->connection()->SetDefaultEncryptionLevel(
113 ENCRYPTION_INITIAL); 123 ENCRYPTION_INITIAL);
114 // Set the decrypter immediately so that we no longer accept unencrypted 124 // Set the decrypter immediately so that we no longer accept unencrypted
115 // packets. 125 // packets.
116 session()->connection()->SetDecrypter( 126 session()->connection()->SetDecrypter(
117 crypto_negotiated_params_.initial_crypters.decrypter.release(), 127 crypto_negotiated_params_.initial_crypters.decrypter.release(),
118 ENCRYPTION_INITIAL); 128 ENCRYPTION_INITIAL);
119 SendHandshakeMessage(reply); 129
130 // We want to be notified when the SHLO is ACKed so that we can disable
131 // HANDSHAKE_MODE in the sent packet manager.
132 if (session()->connection()->version() <= QUIC_VERSION_21) {
133 SendHandshakeMessage(reply);
134 } else {
135 scoped_refptr<ServerHelloNotifier> server_hello_notifier(
136 new ServerHelloNotifier(this));
137 SendHandshakeMessage(reply, server_hello_notifier.get());
138 }
120 139
121 session()->connection()->SetEncrypter( 140 session()->connection()->SetEncrypter(
122 ENCRYPTION_FORWARD_SECURE, 141 ENCRYPTION_FORWARD_SECURE,
123 crypto_negotiated_params_.forward_secure_crypters.encrypter.release()); 142 crypto_negotiated_params_.forward_secure_crypters.encrypter.release());
124 session()->connection()->SetDefaultEncryptionLevel( 143 session()->connection()->SetDefaultEncryptionLevel(
125 ENCRYPTION_FORWARD_SECURE); 144 ENCRYPTION_FORWARD_SECURE);
126 session()->connection()->SetAlternativeDecrypter( 145 session()->connection()->SetAlternativeDecrypter(
127 crypto_negotiated_params_.forward_secure_crypters.decrypter.release(), 146 crypto_negotiated_params_.forward_secure_crypters.decrypter.release(),
128 ENCRYPTION_FORWARD_SECURE, false /* don't latch */); 147 ENCRYPTION_FORWARD_SECURE, false /* don't latch */);
129 148
130 encryption_established_ = true; 149 encryption_established_ = true;
131 handshake_confirmed_ = true; 150 handshake_confirmed_ = true;
132 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); 151 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED);
152
153 // Now that the handshake is complete, send an updated server config and
154 // source-address token to the client.
155 SendServerConfigUpdate();
156 }
157
158 void QuicCryptoServerStream::SendServerConfigUpdate() {
159 if (session()->connection()->version() <= QUIC_VERSION_21) {
160 return;
161 }
162
163 CryptoHandshakeMessage server_config_update_message;
164 if (!crypto_config_.BuildServerConfigUpdateMessage(
165 session()->connection()->peer_address(),
166 session()->connection()->clock(),
167 session()->connection()->random_generator(),
168 crypto_negotiated_params_, &server_config_update_message)) {
169 DVLOG(1) << "Server: Failed to build server config update (SCUP)!";
170 return;
171 }
172
173 DVLOG(1) << "Server: Sending server config update (SCUP): "
174 << server_config_update_message.DebugString();
175 const QuicData& data = server_config_update_message.GetSerialized();
176 WriteOrBufferData(string(data.data(), data.length()), false, NULL);
177
178 ++num_server_config_update_messages_sent_;
179 }
180
181 void QuicCryptoServerStream::OnServerHelloAcked() {
182 session()->connection()->OnHandshakeComplete();
133 } 183 }
134 184
135 bool QuicCryptoServerStream::GetBase64SHA256ClientChannelID( 185 bool QuicCryptoServerStream::GetBase64SHA256ClientChannelID(
136 string* output) const { 186 string* output) const {
137 if (!encryption_established_ || 187 if (!encryption_established_ ||
138 crypto_negotiated_params_.channel_id.empty()) { 188 crypto_negotiated_params_.channel_id.empty()) {
139 return false; 189 return false;
140 } 190 }
141 191
142 const string& channel_id(crypto_negotiated_params_.channel_id); 192 const string& channel_id(crypto_negotiated_params_.channel_id);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 241
192 void QuicCryptoServerStream::ValidateCallback::RunImpl( 242 void QuicCryptoServerStream::ValidateCallback::RunImpl(
193 const CryptoHandshakeMessage& client_hello, 243 const CryptoHandshakeMessage& client_hello,
194 const Result& result) { 244 const Result& result) {
195 if (parent_ != NULL) { 245 if (parent_ != NULL) {
196 parent_->FinishProcessingHandshakeMessage(client_hello, result); 246 parent_->FinishProcessingHandshakeMessage(client_hello, result);
197 } 247 }
198 } 248 }
199 249
200 } // namespace net 250 } // 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