OLD | NEW |
---|---|
(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 "crypto/secure_hash.h" | |
9 #include "net/base/net_util.h" | |
10 #include "net/quic/crypto/crypto_framer.h" | |
11 #include "net/quic/crypto/curve25519_key_exchange.h" | |
wtc
2013/03/01 19:07:58
Remove these two headers. They are currently only
ramant (doing other things)
2013/03/01 22:02:04
Changed it to key_exchange.h and deleted secure_ha
| |
12 #include "net/quic/crypto/quic_random.h" | |
13 #include "net/quic/quic_protocol.h" | |
14 | |
15 using std::string; | |
16 | |
17 namespace net { | |
18 | |
19 using crypto::SecureHash; | |
wtc
2013/03/01 19:07:58
This can be removed.
ramant (doing other things)
2013/03/01 22:02:04
Done.
| |
20 | |
21 QuicCryptoClientConfig::QuicCryptoClientConfig() | |
22 : version(0), | |
23 idle_connection_state_lifetime(QuicTime::Delta::Zero()), | |
24 keepalive_timeout(QuicTime::Delta::Zero()) { | |
25 } | |
26 | |
27 QuicCryptoClientConfig::~QuicCryptoClientConfig() {} | |
28 | |
29 void QuicCryptoClientConfig::SetDefaults() { | |
30 // Version must be 0. | |
31 version = 0; | |
32 | |
33 // Key exchange methods. | |
34 key_exchange.resize(2); | |
35 key_exchange[0] = kC255; | |
36 key_exchange[1] = kP256; | |
37 | |
38 // Authenticated encryption algorithms. | |
39 aead.resize(2); | |
40 aead[0] = kAESG; | |
41 aead[1] = kAESH; | |
42 | |
43 // Congestion control feedback types. | |
44 // TODO(wtc): add kINAR when inter-arrival is supported. | |
45 congestion_control.resize(1); | |
46 congestion_control[0] = kQBIC; | |
47 | |
48 // Idle connection state lifetime. | |
49 idle_connection_state_lifetime = QuicTime::Delta::FromSeconds(300); | |
50 | |
51 // Keepalive timeout. | |
52 keepalive_timeout = QuicTime::Delta::Zero(); // Don't send keepalive probes. | |
53 } | |
54 | |
55 void QuicCryptoClientConfig::FillClientHello(const string& nonce, | |
56 const string& server_hostname, | |
57 CryptoHandshakeMessage* out) { | |
58 out->tag = kCHLO; | |
59 | |
60 out->SetValue(kVERS, version); | |
61 out->SetVector(kKEXS, key_exchange); | |
62 out->SetVector(kAEAD, aead); | |
63 out->SetVector(kCGST, congestion_control); | |
64 out->tag_value_map[kNONC] = nonce; | |
65 | |
66 // Idle connection state lifetime. | |
67 uint32 idle_connection_state_lifetime_secs = | |
68 idle_connection_state_lifetime.ToSeconds(); | |
69 out->SetValue(kICSL, idle_connection_state_lifetime_secs); | |
70 | |
71 // Keepalive timeout. | |
72 uint32 keepalive_timeout_secs = keepalive_timeout.ToSeconds(); | |
73 out->SetValue(kKATO, keepalive_timeout_secs); | |
74 | |
75 // Server name indication. | |
76 // If server_hostname is not an IP address literal, it is a DNS hostname. | |
77 IPAddressNumber ip_number; | |
78 if (!server_hostname.empty() && | |
79 !ParseIPLiteralToNumber(server_hostname, &ip_number)) { | |
80 out->tag_value_map[kSNI] = server_hostname; | |
81 } | |
82 } | |
83 | |
84 // TODO(rtenneti): Delete QuicCryptoServerConfig. | |
85 QuicCryptoServerConfig::QuicCryptoServerConfig() { | |
86 } | |
wtc
2013/03/01 19:07:58
Do we need this? This is not in the internal CL.
ramant (doing other things)
2013/03/01 22:02:04
Added it for compiling it on other platforms. Will
| |
87 | |
88 QuicCryptoServerConfig::~QuicCryptoServerConfig() { | |
89 STLDeleteValues(&configs_); | |
90 } | |
91 | |
92 void QuicCryptoServerConfig::AddTestingConfig(QuicRandom* rand, | |
93 const QuicClock* clock) { | |
94 } | |
95 | |
96 bool QuicCryptoServerConfig::ProcessClientHello( | |
97 const CryptoHandshakeMessage& client_hello, | |
98 const string& nonce, | |
99 CryptoHandshakeMessage* out) { | |
100 CHECK(!configs_.empty()); | |
101 const Config* config(configs_[active_config_]); | |
102 | |
103 // TODO(agl): This is obviously missing most of the handshake. | |
104 out->tag = kSHLO; | |
105 out->tag_value_map[kNONC] = nonce; | |
106 out->tag_value_map[kSCFG] = config->serialized; | |
107 return true; | |
108 } | |
109 | |
110 QuicCryptoServerConfig::Config::Config() { | |
111 } | |
wtc
2013/03/01 19:07:58
This is not in the internal CL.
ramant (doing other things)
2013/03/01 22:02:04
Added it for compiling it on other platforms. Will
| |
112 | |
113 QuicCryptoServerConfig::Config::~Config() { | |
114 STLDeleteValues(&key_exchanges); | |
115 } | |
116 | |
117 QuicCryptoNegotiatedParams::QuicCryptoNegotiatedParams() | |
118 : version(0), | |
119 key_exchange(0), | |
120 aead(0), | |
121 congestion_control(0), | |
122 idle_connection_state_lifetime(QuicTime::Delta::Zero()) { | |
123 } | |
124 | |
125 QuicCryptoNegotiatedParams::~QuicCryptoNegotiatedParams() {} | |
126 | |
127 void QuicCryptoNegotiatedParams::SetDefaults() { | |
128 // TODO(wtc): actually negotiate the parameters using client defaults | |
129 // and server defaults. | |
130 | |
131 // Version must be 0. | |
132 version = 0; | |
133 | |
134 // Key exchange method. | |
135 key_exchange = kP256; | |
136 | |
137 // Authenticated encryption algorithm. | |
138 aead = kAESG; | |
139 | |
140 // Congestion control feedback type. | |
141 congestion_control = kQBIC; | |
142 | |
143 // Idle connection state lifetime. | |
144 idle_connection_state_lifetime = QuicTime::Delta::FromSeconds(300); | |
145 } | |
146 | |
147 } // namespace net | |
OLD | NEW |