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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 CloseConnection(QUIC_INTERNAL_ERROR); | 212 CloseConnection(QUIC_INTERNAL_ERROR); |
215 return; | 213 return; |
216 } | 214 } |
217 if (kClientHelloMinimumSize > max_packet_size - kFramingOverhead) { | 215 if (kClientHelloMinimumSize > max_packet_size - kFramingOverhead) { |
218 DLOG(DFATAL) << "Client hello won't fit in a single packet."; | 216 DLOG(DFATAL) << "Client hello won't fit in a single packet."; |
219 CloseConnection(QUIC_INTERNAL_ERROR); | 217 CloseConnection(QUIC_INTERNAL_ERROR); |
220 return; | 218 return; |
221 } | 219 } |
222 out.set_minimum_size(max_packet_size - kFramingOverhead); | 220 out.set_minimum_size(max_packet_size - kFramingOverhead); |
223 next_state_ = STATE_RECV_REJ; | 221 next_state_ = STATE_RECV_REJ; |
224 DVLOG(1) << "Client: Sending " << out.DebugString(); | |
225 SendHandshakeMessage(out); | 222 SendHandshakeMessage(out); |
226 return; | 223 return; |
227 } | 224 } |
228 session()->config()->ToHandshakeMessage(&out); | 225 session()->config()->ToHandshakeMessage(&out); |
229 error = crypto_config_->FillClientHello( | 226 error = crypto_config_->FillClientHello( |
230 server_id_, | 227 server_id_, |
231 session()->connection()->connection_id(), | 228 session()->connection()->connection_id(), |
232 session()->connection()->supported_versions().front(), | 229 session()->connection()->supported_versions().front(), |
233 cached, | 230 cached, |
234 session()->connection()->clock()->WallNow(), | 231 session()->connection()->clock()->WallNow(), |
(...skipping 10 matching lines...) Expand all Loading... |
245 return; | 242 return; |
246 } | 243 } |
247 // TODO(wtc): a temporary change to measure the performance penalty of | 244 // TODO(wtc): a temporary change to measure the performance penalty of |
248 // pooling connections less often if channel ID is used. | 245 // pooling connections less often if channel ID is used. |
249 // channel_id_sent_ = (channel_id_key_.get() != NULL); | 246 // channel_id_sent_ = (channel_id_key_.get() != NULL); |
250 if (cached->proof_verify_details()) { | 247 if (cached->proof_verify_details()) { |
251 client_session()->OnProofVerifyDetailsAvailable( | 248 client_session()->OnProofVerifyDetailsAvailable( |
252 *cached->proof_verify_details()); | 249 *cached->proof_verify_details()); |
253 } | 250 } |
254 next_state_ = STATE_RECV_SHLO; | 251 next_state_ = STATE_RECV_SHLO; |
255 DVLOG(1) << "Client: Sending " << out.DebugString(); | |
256 SendHandshakeMessage(out); | 252 SendHandshakeMessage(out); |
257 // Be prepared to decrypt with the new server write key. | 253 // Be prepared to decrypt with the new server write key. |
258 session()->connection()->SetAlternativeDecrypter( | 254 session()->connection()->SetAlternativeDecrypter( |
259 crypto_negotiated_params_.initial_crypters.decrypter.release(), | 255 crypto_negotiated_params_.initial_crypters.decrypter.release(), |
260 ENCRYPTION_INITIAL, | 256 ENCRYPTION_INITIAL, |
261 true /* latch once used */); | 257 true /* latch once used */); |
262 // Send subsequent packets under encryption on the assumption that the | 258 // Send subsequent packets under encryption on the assumption that the |
263 // server will accept the handshake. | 259 // server will accept the handshake. |
264 session()->connection()->SetEncrypter( | 260 session()->connection()->SetEncrypter( |
265 ENCRYPTION_INITIAL, | 261 ENCRYPTION_INITIAL, |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 } | 496 } |
501 } | 497 } |
502 return false; | 498 return false; |
503 } | 499 } |
504 | 500 |
505 QuicClientSessionBase* QuicCryptoClientStream::client_session() { | 501 QuicClientSessionBase* QuicCryptoClientStream::client_session() { |
506 return reinterpret_cast<QuicClientSessionBase*>(session()); | 502 return reinterpret_cast<QuicClientSessionBase*>(session()); |
507 } | 503 } |
508 | 504 |
509 } // namespace net | 505 } // namespace net |
OLD | NEW |