OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/crypto/quic_crypto_client_config.h" | 5 #include "net/quic/crypto/quic_crypto_client_config.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "net/quic/crypto/cert_compressor.h" | 8 #include "net/quic/crypto/cert_compressor.h" |
9 #include "net/quic/crypto/channel_id.h" | 9 #include "net/quic/crypto/channel_id.h" |
10 #include "net/quic/crypto/common_cert_set.h" | 10 #include "net/quic/crypto/common_cert_set.h" |
11 #include "net/quic/crypto/crypto_framer.h" | 11 #include "net/quic/crypto/crypto_framer.h" |
12 #include "net/quic/crypto/crypto_utils.h" | 12 #include "net/quic/crypto/crypto_utils.h" |
13 #include "net/quic/crypto/curve25519_key_exchange.h" | 13 #include "net/quic/crypto/curve25519_key_exchange.h" |
14 #include "net/quic/crypto/key_exchange.h" | 14 #include "net/quic/crypto/key_exchange.h" |
15 #include "net/quic/crypto/p256_key_exchange.h" | 15 #include "net/quic/crypto/p256_key_exchange.h" |
16 #include "net/quic/crypto/proof_verifier.h" | 16 #include "net/quic/crypto/proof_verifier.h" |
17 #include "net/quic/crypto/quic_encrypter.h" | 17 #include "net/quic/crypto/quic_encrypter.h" |
| 18 #include "net/quic/quic_session_key.h" |
18 #include "net/quic/quic_utils.h" | 19 #include "net/quic/quic_utils.h" |
19 | 20 |
20 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
21 #include "base/win/windows_version.h" | 22 #include "base/win/windows_version.h" |
22 #endif | 23 #endif |
23 | 24 |
24 using base::StringPiece; | 25 using base::StringPiece; |
| 26 using std::make_pair; |
25 using std::map; | 27 using std::map; |
26 using std::string; | 28 using std::string; |
27 using std::vector; | 29 using std::vector; |
28 | 30 |
29 namespace net { | 31 namespace net { |
30 | 32 |
31 QuicCryptoClientConfig::QuicCryptoClientConfig() {} | 33 QuicCryptoClientConfig::QuicCryptoClientConfig() {} |
32 | 34 |
33 QuicCryptoClientConfig::~QuicCryptoClientConfig() { | 35 QuicCryptoClientConfig::~QuicCryptoClientConfig() { |
34 STLDeleteValues(&cached_states_); | 36 STLDeleteValues(&cached_states_); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 kexs.resize(2); | 248 kexs.resize(2); |
247 kexs[0] = kC255; | 249 kexs[0] = kC255; |
248 kexs[1] = kP256; | 250 kexs[1] = kP256; |
249 | 251 |
250 // Authenticated encryption algorithms. | 252 // Authenticated encryption algorithms. |
251 aead.resize(1); | 253 aead.resize(1); |
252 aead[0] = kAESG; | 254 aead[0] = kAESG; |
253 } | 255 } |
254 | 256 |
255 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate( | 257 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate( |
256 const string& server_hostname) { | 258 const QuicSessionKey& server_key) { |
257 map<string, CachedState*>::const_iterator it = | 259 map<QuicSessionKey, CachedState*>::const_iterator it = |
258 cached_states_.find(server_hostname); | 260 cached_states_.find(server_key); |
259 if (it != cached_states_.end()) { | 261 if (it != cached_states_.end()) { |
260 return it->second; | 262 return it->second; |
261 } | 263 } |
262 | 264 |
263 CachedState* cached = new CachedState; | 265 CachedState* cached = new CachedState; |
264 cached_states_.insert(make_pair(server_hostname, cached)); | 266 cached_states_.insert(make_pair(server_key, cached)); |
265 return cached; | 267 return cached; |
266 } | 268 } |
267 | 269 |
268 void QuicCryptoClientConfig::FillInchoateClientHello( | 270 void QuicCryptoClientConfig::FillInchoateClientHello( |
269 const string& server_hostname, | 271 const string& server_hostname, |
270 const QuicVersion preferred_version, | 272 const QuicVersion preferred_version, |
271 const CachedState* cached, | 273 const CachedState* cached, |
272 QuicCryptoNegotiatedParameters* out_params, | 274 QuicCryptoNegotiatedParameters* out_params, |
273 CryptoHandshakeMessage* out) const { | 275 CryptoHandshakeMessage* out) const { |
274 out->set_tag(kCHLO); | 276 out->set_tag(kCHLO); |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 | 661 |
660 ChannelIDSigner* QuicCryptoClientConfig::channel_id_signer() const { | 662 ChannelIDSigner* QuicCryptoClientConfig::channel_id_signer() const { |
661 return channel_id_signer_.get(); | 663 return channel_id_signer_.get(); |
662 } | 664 } |
663 | 665 |
664 void QuicCryptoClientConfig::SetChannelIDSigner(ChannelIDSigner* signer) { | 666 void QuicCryptoClientConfig::SetChannelIDSigner(ChannelIDSigner* signer) { |
665 channel_id_signer_.reset(signer); | 667 channel_id_signer_.reset(signer); |
666 } | 668 } |
667 | 669 |
668 void QuicCryptoClientConfig::InitializeFrom( | 670 void QuicCryptoClientConfig::InitializeFrom( |
669 const std::string& server_hostname, | 671 const QuicSessionKey& server_key, |
670 const std::string& canonical_server_hostname, | 672 const QuicSessionKey& canonical_server_key, |
671 QuicCryptoClientConfig* canonical_crypto_config) { | 673 QuicCryptoClientConfig* canonical_crypto_config) { |
672 CachedState* canonical_cached = | 674 CachedState* canonical_cached = |
673 canonical_crypto_config->LookupOrCreate(canonical_server_hostname); | 675 canonical_crypto_config->LookupOrCreate(canonical_server_key); |
674 if (!canonical_cached->proof_valid()) { | 676 if (!canonical_cached->proof_valid()) { |
675 return; | 677 return; |
676 } | 678 } |
677 CachedState* cached = LookupOrCreate(server_hostname); | 679 CachedState* cached = LookupOrCreate(server_key); |
678 cached->InitializeFrom(*canonical_cached); | 680 cached->InitializeFrom(*canonical_cached); |
679 } | 681 } |
680 | 682 |
681 } // namespace net | 683 } // namespace net |
OLD | NEW |