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