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_client_stream.h" | 5 #include "net/quic/quic_crypto_client_stream.h" |
6 | 6 |
7 #include "net/quic/crypto/crypto_protocol.h" | 7 #include "net/quic/crypto/crypto_protocol.h" |
8 #include "net/quic/crypto/crypto_utils.h" | 8 #include "net/quic/crypto/crypto_utils.h" |
9 #include "net/quic/crypto/null_encrypter.h" | 9 #include "net/quic/crypto/null_encrypter.h" |
10 #include "net/quic/quic_client_session_base.h" | 10 #include "net/quic/quic_client_session_base.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 if (channel_id_source_callback_) { | 90 if (channel_id_source_callback_) { |
91 channel_id_source_callback_->Cancel(); | 91 channel_id_source_callback_->Cancel(); |
92 } | 92 } |
93 if (proof_verify_callback_) { | 93 if (proof_verify_callback_) { |
94 proof_verify_callback_->Cancel(); | 94 proof_verify_callback_->Cancel(); |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 void QuicCryptoClientStream::OnHandshakeMessage( | 98 void QuicCryptoClientStream::OnHandshakeMessage( |
99 const CryptoHandshakeMessage& message) { | 99 const CryptoHandshakeMessage& message) { |
100 DVLOG(1) << "Client: Received " << message.DebugString(); | |
101 | |
102 QuicCryptoStream::OnHandshakeMessage(message); | 100 QuicCryptoStream::OnHandshakeMessage(message); |
103 | 101 |
104 if (message.tag() == kSCUP) { | 102 if (message.tag() == kSCUP) { |
105 if (!handshake_confirmed()) { | 103 if (!handshake_confirmed()) { |
106 CloseConnection(QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE); | 104 CloseConnection(QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE); |
107 return; | 105 return; |
108 } | 106 } |
109 | 107 |
110 // |message| is an update from the server, so we treat it differently from a | 108 // |message| is an update from the server, so we treat it differently from a |
111 // handshake message. | 109 // handshake message. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 CloseConnection(QUIC_INTERNAL_ERROR); | 216 CloseConnection(QUIC_INTERNAL_ERROR); |
219 return; | 217 return; |
220 } | 218 } |
221 if (kClientHelloMinimumSize > max_packet_size - kFramingOverhead) { | 219 if (kClientHelloMinimumSize > max_packet_size - kFramingOverhead) { |
222 DLOG(DFATAL) << "Client hello won't fit in a single packet."; | 220 DLOG(DFATAL) << "Client hello won't fit in a single packet."; |
223 CloseConnection(QUIC_INTERNAL_ERROR); | 221 CloseConnection(QUIC_INTERNAL_ERROR); |
224 return; | 222 return; |
225 } | 223 } |
226 out.set_minimum_size(max_packet_size - kFramingOverhead); | 224 out.set_minimum_size(max_packet_size - kFramingOverhead); |
227 next_state_ = STATE_RECV_REJ; | 225 next_state_ = STATE_RECV_REJ; |
228 DVLOG(1) << "Client: Sending " << out.DebugString(); | |
229 SendHandshakeMessage(out); | 226 SendHandshakeMessage(out); |
230 return; | 227 return; |
231 } | 228 } |
232 session()->config()->ToHandshakeMessage(&out); | 229 session()->config()->ToHandshakeMessage(&out); |
233 error = crypto_config_->FillClientHello( | 230 error = crypto_config_->FillClientHello( |
234 server_id_, | 231 server_id_, |
235 session()->connection()->connection_id(), | 232 session()->connection()->connection_id(), |
236 session()->connection()->supported_versions().front(), | 233 session()->connection()->supported_versions().front(), |
237 cached, | 234 cached, |
238 session()->connection()->clock()->WallNow(), | 235 session()->connection()->clock()->WallNow(), |
(...skipping 10 matching lines...) Expand all Loading... |
249 return; | 246 return; |
250 } | 247 } |
251 // TODO(wtc): a temporary change to measure the performance penalty of | 248 // TODO(wtc): a temporary change to measure the performance penalty of |
252 // pooling connections less often if channel ID is used. | 249 // pooling connections less often if channel ID is used. |
253 // channel_id_sent_ = (channel_id_key_.get() != NULL); | 250 // channel_id_sent_ = (channel_id_key_.get() != NULL); |
254 if (cached->proof_verify_details()) { | 251 if (cached->proof_verify_details()) { |
255 client_session()->OnProofVerifyDetailsAvailable( | 252 client_session()->OnProofVerifyDetailsAvailable( |
256 *cached->proof_verify_details()); | 253 *cached->proof_verify_details()); |
257 } | 254 } |
258 next_state_ = STATE_RECV_SHLO; | 255 next_state_ = STATE_RECV_SHLO; |
259 DVLOG(1) << "Client: Sending " << out.DebugString(); | |
260 SendHandshakeMessage(out); | 256 SendHandshakeMessage(out); |
261 // Be prepared to decrypt with the new server write key. | 257 // Be prepared to decrypt with the new server write key. |
262 session()->connection()->SetAlternativeDecrypter( | 258 session()->connection()->SetAlternativeDecrypter( |
263 crypto_negotiated_params_.initial_crypters.decrypter.release(), | 259 crypto_negotiated_params_.initial_crypters.decrypter.release(), |
264 ENCRYPTION_INITIAL, | 260 ENCRYPTION_INITIAL, |
265 true /* latch once used */); | 261 true /* latch once used */); |
266 // Send subsequent packets under encryption on the assumption that the | 262 // Send subsequent packets under encryption on the assumption that the |
267 // server will accept the handshake. | 263 // server will accept the handshake. |
268 session()->connection()->SetEncrypter( | 264 session()->connection()->SetEncrypter( |
269 ENCRYPTION_INITIAL, | 265 ENCRYPTION_INITIAL, |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 } | 505 } |
510 } | 506 } |
511 return false; | 507 return false; |
512 } | 508 } |
513 | 509 |
514 QuicClientSessionBase* QuicCryptoClientStream::client_session() { | 510 QuicClientSessionBase* QuicCryptoClientStream::client_session() { |
515 return reinterpret_cast<QuicClientSessionBase*>(session()); | 511 return reinterpret_cast<QuicClientSessionBase*>(session()); |
516 } | 512 } |
517 | 513 |
518 } // namespace net | 514 } // namespace net |
OLD | NEW |