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

Side by Side Diff: net/quic/crypto/crypto_handshake.cc

Issue 12381018: QUIC - Some sketching of the crypto handshake. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 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/crypto/crypto_handshake.h ('k') | net/quic/crypto/crypto_handshake_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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/quic/crypto/crypto_handshake.h"
6
7 #include "base/stl_util.h"
8 #include "net/base/net_util.h"
9 #include "net/quic/crypto/key_exchange.h"
10 #include "net/quic/crypto/quic_random.h"
11 #include "net/quic/quic_protocol.h"
12
13 using std::string;
14
15 namespace net {
16
17 QuicCryptoClientConfig::QuicCryptoClientConfig()
18 : version(0),
19 idle_connection_state_lifetime(QuicTime::Delta::Zero()),
20 keepalive_timeout(QuicTime::Delta::Zero()) {
21 }
22
23 QuicCryptoClientConfig::~QuicCryptoClientConfig() {}
24
25 void QuicCryptoClientConfig::SetDefaults() {
26 // Version must be 0.
27 version = 0;
28
29 // Key exchange methods.
30 key_exchange.resize(2);
31 key_exchange[0] = kC255;
32 key_exchange[1] = kP256;
33
34 // Authenticated encryption algorithms.
35 aead.resize(2);
36 aead[0] = kAESG;
37 aead[1] = kAESH;
38
39 // Congestion control feedback types.
40 // TODO(wtc): add kINAR when inter-arrival is supported.
41 congestion_control.resize(1);
42 congestion_control[0] = kQBIC;
43
44 // Idle connection state lifetime.
45 idle_connection_state_lifetime = QuicTime::Delta::FromSeconds(300);
46
47 // Keepalive timeout.
48 keepalive_timeout = QuicTime::Delta::Zero(); // Don't send keepalive probes.
49 }
50
51 void QuicCryptoClientConfig::FillClientHello(const string& nonce,
52 const string& server_hostname,
53 CryptoHandshakeMessage* out) {
54 out->tag = kCHLO;
55
56 out->SetValue(kVERS, version);
57 out->SetVector(kKEXS, key_exchange);
58 out->SetVector(kAEAD, aead);
59 out->SetVector(kCGST, congestion_control);
60 out->tag_value_map[kNONC] = nonce;
61
62 // Idle connection state lifetime.
63 uint32 idle_connection_state_lifetime_secs =
64 idle_connection_state_lifetime.ToSeconds();
65 out->SetValue(kICSL, idle_connection_state_lifetime_secs);
66
67 // Keepalive timeout.
68 uint32 keepalive_timeout_secs = keepalive_timeout.ToSeconds();
69 out->SetValue(kKATO, keepalive_timeout_secs);
70
71 // Server name indication.
72 // If server_hostname is not an IP address literal, it is a DNS hostname.
73 IPAddressNumber ip_number;
74 if (!server_hostname.empty() &&
75 !ParseIPLiteralToNumber(server_hostname, &ip_number)) {
76 out->tag_value_map[kSNI] = server_hostname;
77 }
78 }
79
80 // TODO(rtenneti): Delete QuicCryptoServerConfig.
81 QuicCryptoServerConfig::QuicCryptoServerConfig() {
82 }
83
84 QuicCryptoServerConfig::~QuicCryptoServerConfig() {
85 STLDeleteValues(&configs_);
86 }
87
88 void QuicCryptoServerConfig::AddTestingConfig(QuicRandom* rand,
89 const QuicClock* clock) {
90 }
91
92 bool QuicCryptoServerConfig::ProcessClientHello(
93 const CryptoHandshakeMessage& client_hello,
94 const string& nonce,
95 CryptoHandshakeMessage* out) {
96 CHECK(!configs_.empty());
97 const Config* config(configs_[active_config_]);
98
99 // TODO(agl): This is obviously missing most of the handshake.
100 out->tag = kSHLO;
101 out->tag_value_map[kNONC] = nonce;
102 out->tag_value_map[kSCFG] = config->serialized;
103 return true;
104 }
105
106 QuicCryptoServerConfig::Config::Config() {
107 }
108
109 QuicCryptoServerConfig::Config::~Config() {
110 STLDeleteValues(&key_exchanges);
111 }
112
113 QuicCryptoNegotiatedParams::QuicCryptoNegotiatedParams()
114 : version(0),
115 key_exchange(0),
116 aead(0),
117 congestion_control(0),
118 idle_connection_state_lifetime(QuicTime::Delta::Zero()) {
119 }
120
121 QuicCryptoNegotiatedParams::~QuicCryptoNegotiatedParams() {}
122
123 void QuicCryptoNegotiatedParams::SetDefaults() {
124 // TODO(wtc): actually negotiate the parameters using client defaults
125 // and server defaults.
126
127 // Version must be 0.
128 version = 0;
129
130 // Key exchange method.
131 key_exchange = kP256;
132
133 // Authenticated encryption algorithm.
134 aead = kAESG;
135
136 // Congestion control feedback type.
137 congestion_control = kQBIC;
138
139 // Idle connection state lifetime.
140 idle_connection_state_lifetime = QuicTime::Delta::FromSeconds(300);
141 }
142
143 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/crypto_handshake.h ('k') | net/quic/crypto/crypto_handshake_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698