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

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

Issue 14718011: Land Recent QUIC Changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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_test.cc ('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 "net/quic/crypto/crypto_protocol.h" 7 #include "net/quic/crypto/crypto_protocol.h"
8 #include "net/quic/crypto/crypto_server_config.h" 8 #include "net/quic/crypto/crypto_server_config.h"
9 #include "net/quic/crypto/crypto_utils.h" 9 #include "net/quic/crypto/crypto_utils.h"
10 #include "net/quic/quic_config.h" 10 #include "net/quic/quic_config.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 QuicCryptoServerStream::QuicCryptoServerStream( 16 QuicCryptoServerStream::QuicCryptoServerStream(
17 const QuicConfig& config, 17 const QuicConfig& config,
18 const QuicCryptoServerConfig& crypto_config, 18 const QuicCryptoServerConfig& crypto_config,
19 QuicSession* session) 19 QuicSession* session)
20 : QuicCryptoStream(session), 20 : QuicCryptoStream(session),
21 config_(config), 21 config_(config),
22 crypto_config_(crypto_config) { 22 crypto_config_(crypto_config) {
23 } 23 }
24 24
25 QuicCryptoServerStream::~QuicCryptoServerStream() { 25 QuicCryptoServerStream::~QuicCryptoServerStream() {
26 } 26 }
27 27
28 void QuicCryptoServerStream::OnHandshakeMessage( 28 void QuicCryptoServerStream::OnHandshakeMessage(
29 const CryptoHandshakeMessage& message) { 29 const CryptoHandshakeMessage& message) {
30 // Do not process handshake messages after the handshake is complete. 30 // Do not process handshake messages after the handshake is confirmed.
31 if (handshake_complete()) { 31 if (handshake_confirmed_) {
32 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); 32 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE);
33 return; 33 return;
34 } 34 }
35 35
36 if (message.tag() != kCHLO) { 36 if (message.tag() != kCHLO) {
37 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE); 37 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE);
38 return; 38 return;
39 } 39 }
40 40
41 string error_details; 41 string error_details;
(...skipping 13 matching lines...) Expand all
55 if (error != QUIC_NO_ERROR) { 55 if (error != QUIC_NO_ERROR) {
56 CloseConnectionWithDetails(error, error_details); 56 CloseConnectionWithDetails(error, error_details);
57 return; 57 return;
58 } 58 }
59 59
60 // Receiving a full CHLO implies the client is prepared to decrypt with 60 // Receiving a full CHLO implies the client is prepared to decrypt with
61 // the new server write key. We can start to encrypt with the new server 61 // the new server write key. We can start to encrypt with the new server
62 // write key. 62 // write key.
63 // 63 //
64 // NOTE: the SHLO will be encrypted with the new server write key. 64 // NOTE: the SHLO will be encrypted with the new server write key.
65 session()->connection()->ChangeEncrypter( 65 session()->connection()->SetEncrypter(
66 ENCRYPTION_INITIAL,
66 crypto_negotiated_params_.encrypter.release()); 67 crypto_negotiated_params_.encrypter.release());
67 // Be prepared to decrypt with the new client write key, as the client 68 session()->connection()->SetDefaultEncryptionLevel(
68 // will start to use it upon receiving the SHLO. 69 ENCRYPTION_INITIAL);
69 session()->connection()->PushDecrypter( 70 // Set the decrypter immediately so that we no longer accept unencrypted
71 // packets.
72 session()->connection()->SetDecrypter(
70 crypto_negotiated_params_.decrypter.release()); 73 crypto_negotiated_params_.decrypter.release());
71 SetHandshakeComplete(QUIC_NO_ERROR); 74 encryption_established_ = true;
75 handshake_confirmed_ = true;
76 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED);
72 } 77 }
73 78
74 SendHandshakeMessage(reply); 79 SendHandshakeMessage(reply);
75 return; 80 return;
76 } 81 }
77 82
78 const QuicNegotiatedParameters& 83 const QuicNegotiatedParameters&
79 QuicCryptoServerStream::negotiated_params() const { 84 QuicCryptoServerStream::negotiated_params() const {
80 return negotiated_params_; 85 return negotiated_params_;
81 } 86 }
82 87
83 const QuicCryptoNegotiatedParameters& 88 const QuicCryptoNegotiatedParameters&
84 QuicCryptoServerStream::crypto_negotiated_params() const { 89 QuicCryptoServerStream::crypto_negotiated_params() const {
85 return crypto_negotiated_params_; 90 return crypto_negotiated_params_;
86 } 91 }
87 92
88 } // namespace net 93 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_client_stream_test.cc ('k') | net/quic/quic_crypto_server_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698