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/crypto/proof_verifier.h" | 10 #include "net/quic/crypto/proof_verifier.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 crypto_negotiated_params_.initial_crypters.decrypter.release(), | 105 crypto_negotiated_params_.initial_crypters.decrypter.release(), |
106 true /* latch once used */); | 106 true /* latch once used */); |
107 // Send subsequent packets under encryption on the assumption that the | 107 // Send subsequent packets under encryption on the assumption that the |
108 // server will accept the handshake. | 108 // server will accept the handshake. |
109 session()->connection()->SetEncrypter( | 109 session()->connection()->SetEncrypter( |
110 ENCRYPTION_INITIAL, | 110 ENCRYPTION_INITIAL, |
111 crypto_negotiated_params_.initial_crypters.encrypter.release()); | 111 crypto_negotiated_params_.initial_crypters.encrypter.release()); |
112 session()->connection()->SetDefaultEncryptionLevel( | 112 session()->connection()->SetDefaultEncryptionLevel( |
113 ENCRYPTION_INITIAL); | 113 ENCRYPTION_INITIAL); |
114 if (!encryption_established_) { | 114 if (!encryption_established_) { |
115 // TODO(agl): the following, commented code should live here and not | 115 encryption_established_ = true; |
116 // down when the handshake is confirmed. However, it causes | 116 session()->OnCryptoHandshakeEvent( |
117 // EndToEndTest.LargePost to be flaky (b/8074678), seemingly because | 117 QuicSession::ENCRYPTION_FIRST_ESTABLISHED); |
118 // the packets dropped when the client hello is dropped cause the | |
119 // congestion control to be too conservative and the server times | |
120 // out. | |
121 // encryption_established_ = true; | |
122 // session()->OnCryptoHandshakeEvent( | |
123 // QuicSession::ENCRYPTION_FIRST_ESTABLISHED); | |
124 } else { | 118 } else { |
125 session()->OnCryptoHandshakeEvent( | 119 session()->OnCryptoHandshakeEvent( |
126 QuicSession::ENCRYPTION_REESTABLISHED); | 120 QuicSession::ENCRYPTION_REESTABLISHED); |
127 } | 121 } |
128 return; | 122 return; |
129 } | 123 } |
130 case STATE_RECV_REJ: | 124 case STATE_RECV_REJ: |
131 // We sent a dummy CHLO because we didn't have enough information to | 125 // We sent a dummy CHLO because we didn't have enough information to |
132 // perform a handshake, or we sent a full hello that the server | 126 // perform a handshake, or we sent a full hello that the server |
133 // rejected. Here we hope to have a REJ that contains the information | 127 // rejected. Here we hope to have a REJ that contains the information |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // has been floated that the server shouldn't send packets encrypted | 213 // has been floated that the server shouldn't send packets encrypted |
220 // with the FORWARD_SECURE key until it receives a FORWARD_SECURE | 214 // with the FORWARD_SECURE key until it receives a FORWARD_SECURE |
221 // packet from the client. | 215 // packet from the client. |
222 session()->connection()->SetAlternativeDecrypter( | 216 session()->connection()->SetAlternativeDecrypter( |
223 crypters->decrypter.release(), false /* don't latch */); | 217 crypters->decrypter.release(), false /* don't latch */); |
224 session()->connection()->SetEncrypter( | 218 session()->connection()->SetEncrypter( |
225 ENCRYPTION_FORWARD_SECURE, crypters->encrypter.release()); | 219 ENCRYPTION_FORWARD_SECURE, crypters->encrypter.release()); |
226 session()->connection()->SetDefaultEncryptionLevel( | 220 session()->connection()->SetDefaultEncryptionLevel( |
227 ENCRYPTION_FORWARD_SECURE); | 221 ENCRYPTION_FORWARD_SECURE); |
228 | 222 |
229 // TODO(agl): this code shouldn't be here. See the TODO further up | |
230 // about it. | |
231 encryption_established_ = true; | |
232 session()->OnCryptoHandshakeEvent( | |
233 QuicSession::ENCRYPTION_FIRST_ESTABLISHED); | |
234 | |
235 handshake_confirmed_ = true; | 223 handshake_confirmed_ = true; |
236 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); | 224 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); |
237 return; | 225 return; |
238 } | 226 } |
239 case STATE_IDLE: | 227 case STATE_IDLE: |
240 // This means that the peer sent us a message that we weren't expecting. | 228 // This means that the peer sent us a message that we weren't expecting. |
241 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE); | 229 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE); |
242 return; | 230 return; |
243 } | 231 } |
244 } | 232 } |
245 } | 233 } |
246 | 234 |
247 } // namespace net | 235 } // namespace net |
OLD | NEW |