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

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

Issue 15074007: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for windows Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_crypto_client_stream.h ('k') | net/quic/quic_crypto_client_stream_factory.h » ('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_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"
11 #include "net/quic/quic_protocol.h" 11 #include "net/quic/quic_protocol.h"
12 #include "net/quic/quic_session.h" 12 #include "net/quic/quic_session.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 QuicCryptoClientStream::QuicCryptoClientStream( 16 QuicCryptoClientStream::QuicCryptoClientStream(
17 const string& server_hostname, 17 const string& server_hostname,
18 const QuicConfig& config,
19 QuicSession* session, 18 QuicSession* session,
20 QuicCryptoClientConfig* crypto_config) 19 QuicCryptoClientConfig* crypto_config)
21 : QuicCryptoStream(session), 20 : QuicCryptoStream(session),
22 next_state_(STATE_IDLE), 21 next_state_(STATE_IDLE),
23 num_client_hellos_(0), 22 num_client_hellos_(0),
24 config_(config),
25 crypto_config_(crypto_config), 23 crypto_config_(crypto_config),
26 server_hostname_(server_hostname) { 24 server_hostname_(server_hostname) {
27 } 25 }
28 26
29 QuicCryptoClientStream::~QuicCryptoClientStream() { 27 QuicCryptoClientStream::~QuicCryptoClientStream() {
30 } 28 }
31 29
32 void QuicCryptoClientStream::OnHandshakeMessage( 30 void QuicCryptoClientStream::OnHandshakeMessage(
33 const CryptoHandshakeMessage& message) { 31 const CryptoHandshakeMessage& message) {
34 DoHandshakeLoop(&message); 32 DoHandshakeLoop(&message);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 num_client_hellos_++; 73 num_client_hellos_++;
76 74
77 if (!cached->is_complete()) { 75 if (!cached->is_complete()) {
78 crypto_config_->FillInchoateClientHello( 76 crypto_config_->FillInchoateClientHello(
79 server_hostname_, cached, &crypto_negotiated_params_, &out); 77 server_hostname_, cached, &crypto_negotiated_params_, &out);
80 next_state_ = STATE_RECV_REJ; 78 next_state_ = STATE_RECV_REJ;
81 DLOG(INFO) << "Client Sending: " << out.DebugString(); 79 DLOG(INFO) << "Client Sending: " << out.DebugString();
82 SendHandshakeMessage(out); 80 SendHandshakeMessage(out);
83 return; 81 return;
84 } 82 }
85 const CryptoHandshakeMessage* scfg = cached->GetServerConfig(); 83 session()->config()->ToHandshakeMessage(&out);
86 config_.ToHandshakeMessage(&out);
87 error = crypto_config_->FillClientHello( 84 error = crypto_config_->FillClientHello(
88 server_hostname_, 85 server_hostname_,
89 session()->connection()->guid(), 86 session()->connection()->guid(),
90 cached, 87 cached,
91 session()->connection()->clock()->WallNow(), 88 session()->connection()->clock()->WallNow(),
92 session()->connection()->random_generator(), 89 session()->connection()->random_generator(),
93 &crypto_negotiated_params_, 90 &crypto_negotiated_params_,
94 &out, 91 &out,
95 &error_details); 92 &error_details);
96 if (error != QUIC_NO_ERROR) { 93 if (error != QUIC_NO_ERROR) {
97 CloseConnectionWithDetails(error, error_details); 94 CloseConnectionWithDetails(error, error_details);
98 return; 95 return;
99 } 96 }
100 error = config_.ProcessFinalPeerHandshake(
101 *scfg, CryptoUtils::PEER_PRIORITY, &negotiated_params_,
102 &error_details);
103 if (error != QUIC_NO_ERROR) {
104 CloseConnectionWithDetails(error, error_details);
105 return;
106 }
107 next_state_ = STATE_RECV_SHLO; 97 next_state_ = STATE_RECV_SHLO;
108 DLOG(INFO) << "Client Sending: " << out.DebugString(); 98 DLOG(INFO) << "Client Sending: " << out.DebugString();
109 SendHandshakeMessage(out); 99 SendHandshakeMessage(out);
110 // Be prepared to decrypt with the new server write key. 100 // Be prepared to decrypt with the new server write key.
111 session()->connection()->SetAlternativeDecrypter( 101 session()->connection()->SetAlternativeDecrypter(
112 crypto_negotiated_params_.initial_crypters.decrypter.release(), 102 crypto_negotiated_params_.initial_crypters.decrypter.release(),
113 true /* latch once used */); 103 true /* latch once used */);
114 // Send subsequent packets under encryption on the assumption that the 104 // Send subsequent packets under encryption on the assumption that the
115 // server will accept the handshake. 105 // server will accept the handshake.
116 session()->connection()->SetEncrypter( 106 session()->connection()->SetEncrypter(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 return; 197 return;
208 } 198 }
209 error = crypto_config_->ProcessServerHello( 199 error = crypto_config_->ProcessServerHello(
210 *in, session()->connection()->guid(), &crypto_negotiated_params_, 200 *in, session()->connection()->guid(), &crypto_negotiated_params_,
211 &error_details); 201 &error_details);
212 if (error != QUIC_NO_ERROR) { 202 if (error != QUIC_NO_ERROR) {
213 CloseConnectionWithDetails( 203 CloseConnectionWithDetails(
214 error, "Server hello invalid: " + error_details); 204 error, "Server hello invalid: " + error_details);
215 return; 205 return;
216 } 206 }
207 error = session()->config()->ProcessServerHello(*in, &error_details);
208 if (error != QUIC_NO_ERROR) {
209 CloseConnectionWithDetails(
210 error, "Server hello invalid: " + error_details);
211 return;
212 }
217 CrypterPair* crypters = 213 CrypterPair* crypters =
218 &crypto_negotiated_params_.forward_secure_crypters; 214 &crypto_negotiated_params_.forward_secure_crypters;
219 // TODO(agl): we don't currently latch this decrypter because the idea 215 // TODO(agl): we don't currently latch this decrypter because the idea
220 // has been floated that the server shouldn't send packets encrypted 216 // has been floated that the server shouldn't send packets encrypted
221 // with the FORWARD_SECURE key until it receives a FORWARD_SECURE 217 // with the FORWARD_SECURE key until it receives a FORWARD_SECURE
222 // packet from the client. 218 // packet from the client.
223 session()->connection()->SetAlternativeDecrypter( 219 session()->connection()->SetAlternativeDecrypter(
224 crypters->decrypter.release(), false /* don't latch */); 220 crypters->decrypter.release(), false /* don't latch */);
225 session()->connection()->SetEncrypter( 221 session()->connection()->SetEncrypter(
226 ENCRYPTION_FORWARD_SECURE, crypters->encrypter.release()); 222 ENCRYPTION_FORWARD_SECURE, crypters->encrypter.release());
(...skipping 12 matching lines...) Expand all
239 } 235 }
240 case STATE_IDLE: 236 case STATE_IDLE:
241 // This means that the peer sent us a message that we weren't expecting. 237 // This means that the peer sent us a message that we weren't expecting.
242 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE); 238 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE);
243 return; 239 return;
244 } 240 }
245 } 241 }
246 } 242 }
247 243
248 } // namespace net 244 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_client_stream.h ('k') | net/quic/quic_crypto_client_stream_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698