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

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

Issue 13976007: Land Recent QUIC Changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated copyright notice Created 7 years, 8 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_server_stream.h ('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_utils.h" 8 #include "net/quic/crypto/crypto_utils.h"
9 #include "net/quic/quic_config.h"
9 #include "net/quic/quic_protocol.h" 10 #include "net/quic/quic_protocol.h"
10 #include "net/quic/quic_session.h" 11 #include "net/quic/quic_session.h"
11 12
12 namespace net { 13 namespace net {
13 14
14 QuicCryptoServerStream::QuicCryptoServerStream(QuicSession* session) 15 QuicCryptoServerStream::QuicCryptoServerStream(
16 const QuicConfig& config,
17 const QuicCryptoServerConfig& crypto_config,
18 QuicSession* session)
15 : QuicCryptoStream(session), 19 : QuicCryptoStream(session),
16 // TODO(agl): use real secret. 20 config_(config),
17 crypto_config_("secret") { 21 crypto_config_(crypto_config) {
18 config_.SetDefaults();
19 // Use hardcoded crypto parameters for now.
20 CryptoHandshakeMessage extra_tags;
21 config_.ToHandshakeMessage(&extra_tags);
22
23 // TODO(agl): AddTestingConfig generates a new, random config. In the future
24 // this will be replaced with a real source of configs.
25 scoped_ptr<CryptoHandshakeMessage> scfg(
26 crypto_config_.AddTestingConfig(session->connection()->random_generator(),
27 session->connection()->clock(),
28 extra_tags));
29 // If we were using the same config in many servers then we would have to
30 // parse a QuicConfig from config_tags here.
31
32 // Our non-crypto configuration is also expressed in the SCFG because it's
33 // signed. Thus |config_| needs to be consistent with that.
34 if (!config_.SetFromHandshakeMessage(*scfg)) {
35 // TODO(agl): when we aren't generating testing configs then this can be a
36 // CHECK at startup time.
37 LOG(WARNING) << "SCFG could not be parsed by QuicConfig.";
38 DCHECK(false);
39 }
40 } 22 }
41 23
42 QuicCryptoServerStream::~QuicCryptoServerStream() { 24 QuicCryptoServerStream::~QuicCryptoServerStream() {
43 } 25 }
44 26
45 void QuicCryptoServerStream::OnHandshakeMessage( 27 void QuicCryptoServerStream::OnHandshakeMessage(
46 const CryptoHandshakeMessage& message) { 28 const CryptoHandshakeMessage& message) {
47 // Do not process handshake messages after the handshake is complete. 29 // Do not process handshake messages after the handshake is complete.
48 if (handshake_complete()) { 30 if (handshake_complete()) {
49 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); 31 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE);
50 return; 32 return;
51 } 33 }
52 34
53 if (message.tag() != kCHLO) { 35 if (message.tag() != kCHLO) {
54 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE); 36 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE);
55 return; 37 return;
56 } 38 }
57 39
58 string error_details; 40 string error_details;
59 CryptoHandshakeMessage reply; 41 CryptoHandshakeMessage reply;
60 crypto_config_.ProcessClientHello( 42 crypto_config_.ProcessClientHello(
61 message, session()->connection()->guid(), 43 message, session()->connection()->guid(),
62 session()->connection()->peer_address(), 44 session()->connection()->peer_address(),
63 session()->connection()->clock()->NowAsDeltaSinceUnixEpoch(), 45 session()->connection()->clock()->NowAsDeltaSinceUnixEpoch(),
64 session()->connection()->random_generator(), 46 session()->connection()->random_generator(),
65 &reply, &crypto_negotiated_params_, &error_details); 47 &crypto_negotiated_params_, &reply, &error_details);
66 48
67 if (reply.tag() == kSHLO) { 49 if (reply.tag() == kSHLO) {
68 // If we are returning a SHLO then we accepted the handshake. 50 // If we are returning a SHLO then we accepted the handshake.
69 QuicErrorCode error = config_.ProcessFinalPeerHandshake( 51 QuicErrorCode error = config_.ProcessFinalPeerHandshake(
70 message, CryptoUtils::LOCAL_PRIORITY, &negotiated_params_, 52 message, CryptoUtils::LOCAL_PRIORITY, &negotiated_params_,
71 &error_details); 53 &error_details);
72 if (error != QUIC_NO_ERROR) { 54 if (error != QUIC_NO_ERROR) {
73 CloseConnectionWithDetails(error, error_details); 55 CloseConnectionWithDetails(error, error_details);
74 return; 56 return;
75 } 57 }
(...skipping 20 matching lines...) Expand all
96 QuicCryptoServerStream::negotiated_params() const { 78 QuicCryptoServerStream::negotiated_params() const {
97 return negotiated_params_; 79 return negotiated_params_;
98 } 80 }
99 81
100 const QuicCryptoNegotiatedParameters& 82 const QuicCryptoNegotiatedParameters&
101 QuicCryptoServerStream::crypto_negotiated_params() const { 83 QuicCryptoServerStream::crypto_negotiated_params() const {
102 return crypto_negotiated_params_; 84 return crypto_negotiated_params_;
103 } 85 }
104 86
105 } // namespace net 87 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_server_stream.h ('k') | net/quic/quic_crypto_server_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698