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

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

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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"
(...skipping 12 matching lines...) Expand all
23 int num_retransmitted_bytes, 23 int num_retransmitted_bytes,
24 QuicTime::Delta delta_largest_observed) { 24 QuicTime::Delta delta_largest_observed) {
25 server_stream_->OnServerHelloAcked(); 25 server_stream_->OnServerHelloAcked();
26 } 26 }
27 27
28 QuicCryptoServerStream::QuicCryptoServerStream( 28 QuicCryptoServerStream::QuicCryptoServerStream(
29 const QuicCryptoServerConfig& crypto_config, 29 const QuicCryptoServerConfig& crypto_config,
30 QuicSession* session) 30 QuicSession* session)
31 : QuicCryptoStream(session), 31 : QuicCryptoStream(session),
32 crypto_config_(crypto_config), 32 crypto_config_(crypto_config),
33 validate_client_hello_cb_(NULL), 33 validate_client_hello_cb_(nullptr),
34 num_handshake_messages_(0), 34 num_handshake_messages_(0),
35 num_server_config_update_messages_sent_(0) { 35 num_server_config_update_messages_sent_(0) {}
36 }
37 36
38 QuicCryptoServerStream::~QuicCryptoServerStream() { 37 QuicCryptoServerStream::~QuicCryptoServerStream() {
39 CancelOutstandingCallbacks(); 38 CancelOutstandingCallbacks();
40 } 39 }
41 40
42 void QuicCryptoServerStream::CancelOutstandingCallbacks() { 41 void QuicCryptoServerStream::CancelOutstandingCallbacks() {
43 // Detach from the validation callback. Calling this multiple times is safe. 42 // Detach from the validation callback. Calling this multiple times is safe.
44 if (validate_client_hello_cb_ != NULL) { 43 if (validate_client_hello_cb_ != nullptr) {
45 validate_client_hello_cb_->Cancel(); 44 validate_client_hello_cb_->Cancel();
46 } 45 }
47 } 46 }
48 47
49 void QuicCryptoServerStream::OnHandshakeMessage( 48 void QuicCryptoServerStream::OnHandshakeMessage(
50 const CryptoHandshakeMessage& message) { 49 const CryptoHandshakeMessage& message) {
51 QuicCryptoStream::OnHandshakeMessage(message); 50 QuicCryptoStream::OnHandshakeMessage(message);
52 ++num_handshake_messages_; 51 ++num_handshake_messages_;
53 52
54 // Do not process handshake messages after the handshake is confirmed. 53 // Do not process handshake messages after the handshake is confirmed.
55 if (handshake_confirmed_) { 54 if (handshake_confirmed_) {
56 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); 55 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE);
57 return; 56 return;
58 } 57 }
59 58
60 if (message.tag() != kCHLO) { 59 if (message.tag() != kCHLO) {
61 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE); 60 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE);
62 return; 61 return;
63 } 62 }
64 63
65 if (validate_client_hello_cb_ != NULL) { 64 if (validate_client_hello_cb_ != nullptr) {
66 // Already processing some other handshake message. The protocol 65 // Already processing some other handshake message. The protocol
67 // does not allow for clients to send multiple handshake messages 66 // does not allow for clients to send multiple handshake messages
68 // before the server has a chance to respond. 67 // before the server has a chance to respond.
69 CloseConnection(QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO); 68 CloseConnection(QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO);
70 return; 69 return;
71 } 70 }
72 71
73 validate_client_hello_cb_ = new ValidateCallback(this); 72 validate_client_hello_cb_ = new ValidateCallback(this);
74 return crypto_config_.ValidateClientHello( 73 return crypto_config_.ValidateClientHello(
75 message, 74 message,
76 session()->connection()->peer_address(), 75 session()->connection()->peer_address(),
77 session()->connection()->clock(), 76 session()->connection()->clock(),
78 validate_client_hello_cb_); 77 validate_client_hello_cb_);
79 } 78 }
80 79
81 void QuicCryptoServerStream::FinishProcessingHandshakeMessage( 80 void QuicCryptoServerStream::FinishProcessingHandshakeMessage(
82 const CryptoHandshakeMessage& message, 81 const CryptoHandshakeMessage& message,
83 const ValidateClientHelloResultCallback::Result& result) { 82 const ValidateClientHelloResultCallback::Result& result) {
84 // Clear the callback that got us here. 83 // Clear the callback that got us here.
85 DCHECK(validate_client_hello_cb_ != NULL); 84 DCHECK(validate_client_hello_cb_ != nullptr);
86 validate_client_hello_cb_ = NULL; 85 validate_client_hello_cb_ = nullptr;
87 86
88 string error_details; 87 string error_details;
89 CryptoHandshakeMessage reply; 88 CryptoHandshakeMessage reply;
90 QuicErrorCode error = ProcessClientHello( 89 QuicErrorCode error = ProcessClientHello(
91 message, result, &reply, &error_details); 90 message, result, &reply, &error_details);
92 91
93 if (error != QUIC_NO_ERROR) { 92 if (error != QUIC_NO_ERROR) {
94 CloseConnectionWithDetails(error, error_details); 93 CloseConnectionWithDetails(error, error_details);
95 return; 94 return;
96 } 95 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 152
154 // Now that the handshake is complete, send an updated server config and 153 // Now that the handshake is complete, send an updated server config and
155 // source-address token to the client. 154 // source-address token to the client.
156 SendServerConfigUpdate(NULL); 155 SendServerConfigUpdate(nullptr);
157 } 156 }
158 157
159 void QuicCryptoServerStream::SendServerConfigUpdate( 158 void QuicCryptoServerStream::SendServerConfigUpdate(
160 const CachedNetworkParameters* cached_network_params) { 159 const CachedNetworkParameters* cached_network_params) {
161 if (session()->connection()->version() <= QUIC_VERSION_21 || 160 if (session()->connection()->version() <= QUIC_VERSION_21 ||
162 !handshake_confirmed_) { 161 !handshake_confirmed_) {
163 return; 162 return;
164 } 163 }
165 164
166 CryptoHandshakeMessage server_config_update_message; 165 CryptoHandshakeMessage server_config_update_message;
167 if (!crypto_config_.BuildServerConfigUpdateMessage( 166 if (!crypto_config_.BuildServerConfigUpdateMessage(
168 session()->connection()->peer_address(), 167 session()->connection()->peer_address(),
169 session()->connection()->clock(), 168 session()->connection()->clock(),
170 session()->connection()->random_generator(), 169 session()->connection()->random_generator(),
171 crypto_negotiated_params_, 170 crypto_negotiated_params_,
172 cached_network_params, 171 cached_network_params,
173 &server_config_update_message)) { 172 &server_config_update_message)) {
174 DVLOG(1) << "Server: Failed to build server config update (SCUP)!"; 173 DVLOG(1) << "Server: Failed to build server config update (SCUP)!";
175 return; 174 return;
176 } 175 }
177 176
178 DVLOG(1) << "Server: Sending server config update: " 177 DVLOG(1) << "Server: Sending server config update: "
179 << server_config_update_message.DebugString(); 178 << server_config_update_message.DebugString();
180 const QuicData& data = server_config_update_message.GetSerialized(); 179 const QuicData& data = server_config_update_message.GetSerialized();
181 WriteOrBufferData(string(data.data(), data.length()), false, NULL); 180 WriteOrBufferData(string(data.data(), data.length()), false, nullptr);
182 181
183 ++num_server_config_update_messages_sent_; 182 ++num_server_config_update_messages_sent_;
184 } 183 }
185 184
186 void QuicCryptoServerStream::OnServerHelloAcked() { 185 void QuicCryptoServerStream::OnServerHelloAcked() {
187 session()->connection()->OnHandshakeComplete(); 186 session()->connection()->OnHandshakeComplete();
188 } 187 }
189 188
190 bool QuicCryptoServerStream::GetBase64SHA256ClientChannelID( 189 bool QuicCryptoServerStream::GetBase64SHA256ClientChannelID(
191 string* output) const { 190 string* output) const {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 &crypto_negotiated_params_, reply, error_details); 232 &crypto_negotiated_params_, reply, error_details);
234 } 233 }
235 234
236 void QuicCryptoServerStream::OverrideQuicConfigDefaults(QuicConfig* config) { 235 void QuicCryptoServerStream::OverrideQuicConfigDefaults(QuicConfig* config) {
237 } 236 }
238 237
239 QuicCryptoServerStream::ValidateCallback::ValidateCallback( 238 QuicCryptoServerStream::ValidateCallback::ValidateCallback(
240 QuicCryptoServerStream* parent) : parent_(parent) { 239 QuicCryptoServerStream* parent) : parent_(parent) {
241 } 240 }
242 241
243 void QuicCryptoServerStream::ValidateCallback::Cancel() { 242 void QuicCryptoServerStream::ValidateCallback::Cancel() { parent_ = nullptr; }
244 parent_ = NULL;
245 }
246 243
247 void QuicCryptoServerStream::ValidateCallback::RunImpl( 244 void QuicCryptoServerStream::ValidateCallback::RunImpl(
248 const CryptoHandshakeMessage& client_hello, 245 const CryptoHandshakeMessage& client_hello,
249 const Result& result) { 246 const Result& result) {
250 if (parent_ != NULL) { 247 if (parent_ != nullptr) {
251 parent_->FinishProcessingHandshakeMessage(client_hello, result); 248 parent_->FinishProcessingHandshakeMessage(client_hello, result);
252 } 249 }
253 } 250 }
254 251
255 } // namespace net 252 } // 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