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

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

Issue 192583004: QUIC - use QuicSessionKey tuple (host, port, is_https) instead of server_hostname (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use QuicSessionKey as arg and delete server_hostname as arg Created 6 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
OLDNEW
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/crypto/quic_server_info.h" 18 #include "net/quic/crypto/quic_server_info.h"
19 #include "net/quic/quic_session_key.h"
19 #include "net/quic/quic_utils.h" 20 #include "net/quic/quic_utils.h"
20 21
21 #if defined(OS_WIN) 22 #if defined(OS_WIN)
22 #include "base/win/windows_version.h" 23 #include "base/win/windows_version.h"
23 #endif 24 #endif
24 25
25 using base::StringPiece; 26 using base::StringPiece;
27 using std::make_pair;
26 using std::map; 28 using std::map;
27 using std::string; 29 using std::string;
28 using std::vector; 30 using std::vector;
29 31
30 namespace net { 32 namespace net {
31 33
32 QuicCryptoClientConfig::QuicCryptoClientConfig() {} 34 QuicCryptoClientConfig::QuicCryptoClientConfig() {}
33 35
34 QuicCryptoClientConfig::~QuicCryptoClientConfig() { 36 QuicCryptoClientConfig::~QuicCryptoClientConfig() {
35 STLDeleteValues(&cached_states_); 37 STLDeleteValues(&cached_states_);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 DCHECK(!server_config_valid_); 226 DCHECK(!server_config_valid_);
225 server_config_ = other.server_config_; 227 server_config_ = other.server_config_;
226 source_address_token_ = other.source_address_token_; 228 source_address_token_ = other.source_address_token_;
227 certs_ = other.certs_; 229 certs_ = other.certs_;
228 server_config_sig_ = other.server_config_sig_; 230 server_config_sig_ = other.server_config_sig_;
229 server_config_valid_ = other.server_config_valid_; 231 server_config_valid_ = other.server_config_valid_;
230 ++generation_counter_; 232 ++generation_counter_;
231 } 233 }
232 234
233 // An issue to be solved: while we are loading the data from disk cache, it is 235 // An issue to be solved: while we are loading the data from disk cache, it is
234 // possible for another request for the same hostname update the CachedState 236 // possible for another request for the same |server_key| update the CachedState
235 // because that request has sent FillInchoateClientHello and got REJ message. 237 // because that request has sent FillInchoateClientHello and got REJ message.
236 // Loading of data from disk cache shouldn't blindly overwrite what is in 238 // Loading of data from disk cache shouldn't blindly overwrite what is in
237 // CachedState. 239 // CachedState.
238 bool QuicCryptoClientConfig::CachedState::LoadQuicServerInfo(QuicWallTime now) { 240 bool QuicCryptoClientConfig::CachedState::LoadQuicServerInfo(QuicWallTime now) {
239 DCHECK(server_config_.empty()); 241 DCHECK(server_config_.empty());
240 DCHECK(quic_server_info_.get()); 242 DCHECK(quic_server_info_.get());
241 DCHECK(quic_server_info_->IsDataReady()); 243 DCHECK(quic_server_info_->IsDataReady());
242 244
243 const QuicServerInfo::State& state(quic_server_info_->state()); 245 const QuicServerInfo::State& state(quic_server_info_->state());
244 if (state.server_config.empty()) { 246 if (state.server_config.empty()) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 kexs.resize(2); 290 kexs.resize(2);
289 kexs[0] = kC255; 291 kexs[0] = kC255;
290 kexs[1] = kP256; 292 kexs[1] = kP256;
291 293
292 // Authenticated encryption algorithms. 294 // Authenticated encryption algorithms.
293 aead.resize(1); 295 aead.resize(1);
294 aead[0] = kAESG; 296 aead[0] = kAESG;
295 } 297 }
296 298
297 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::Create( 299 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::Create(
298 const string& server_hostname, 300 const QuicSessionKey& server_key,
299 QuicServerInfoFactory* quic_server_info_factory) { 301 QuicServerInfoFactory* quic_server_info_factory) {
300 DCHECK(cached_states_.find(server_hostname) == cached_states_.end()); 302 DCHECK(cached_states_.find(server_key) == cached_states_.end());
301 scoped_ptr<QuicServerInfo> quic_server_info; 303 scoped_ptr<QuicServerInfo> quic_server_info;
302 if (quic_server_info_factory) { 304 if (quic_server_info_factory) {
303 quic_server_info.reset( 305 quic_server_info.reset(
304 quic_server_info_factory->GetForHost(server_hostname)); 306 quic_server_info_factory->GetForServer(server_key));
305 quic_server_info->Start(); 307 quic_server_info->Start();
306 } 308 }
307 309
308 CachedState* cached = new CachedState(quic_server_info.Pass()); 310 CachedState* cached = new CachedState(quic_server_info.Pass());
309 cached_states_.insert(make_pair(server_hostname, cached)); 311 cached_states_.insert(make_pair(server_key, cached));
310 return cached; 312 return cached;
311 } 313 }
312 314
313 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate( 315 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate(
314 const string& server_hostname) { 316 const QuicSessionKey& server_key) {
315 map<string, CachedState*>::const_iterator it = 317 map<QuicSessionKey, CachedState*>::const_iterator it =
316 cached_states_.find(server_hostname); 318 cached_states_.find(server_key);
317 if (it != cached_states_.end()) { 319 if (it != cached_states_.end()) {
318 return it->second; 320 return it->second;
319 } 321 }
320 return Create(server_hostname, NULL); 322 return Create(server_key, NULL);
321 } 323 }
322 324
323 void QuicCryptoClientConfig::FillInchoateClientHello( 325 void QuicCryptoClientConfig::FillInchoateClientHello(
324 const string& server_hostname, 326 const string& server_hostname,
325 const QuicVersion preferred_version, 327 const QuicVersion preferred_version,
326 const CachedState* cached, 328 const CachedState* cached,
327 QuicCryptoNegotiatedParameters* out_params, 329 QuicCryptoNegotiatedParameters* out_params,
328 CryptoHandshakeMessage* out) const { 330 CryptoHandshakeMessage* out) const {
329 out->set_tag(kCHLO); 331 out->set_tag(kCHLO);
330 out->set_minimum_size(kClientHelloMinimumSize); 332 out->set_minimum_size(kClientHelloMinimumSize);
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 716
715 ChannelIDSigner* QuicCryptoClientConfig::channel_id_signer() const { 717 ChannelIDSigner* QuicCryptoClientConfig::channel_id_signer() const {
716 return channel_id_signer_.get(); 718 return channel_id_signer_.get();
717 } 719 }
718 720
719 void QuicCryptoClientConfig::SetChannelIDSigner(ChannelIDSigner* signer) { 721 void QuicCryptoClientConfig::SetChannelIDSigner(ChannelIDSigner* signer) {
720 channel_id_signer_.reset(signer); 722 channel_id_signer_.reset(signer);
721 } 723 }
722 724
723 void QuicCryptoClientConfig::InitializeFrom( 725 void QuicCryptoClientConfig::InitializeFrom(
724 const std::string& server_hostname, 726 const QuicSessionKey& server_key,
725 const std::string& canonical_server_hostname, 727 const QuicSessionKey& canonical_server_key,
726 QuicCryptoClientConfig* canonical_crypto_config) { 728 QuicCryptoClientConfig* canonical_crypto_config) {
727 CachedState* canonical_cached = 729 CachedState* canonical_cached =
728 canonical_crypto_config->LookupOrCreate(canonical_server_hostname); 730 canonical_crypto_config->LookupOrCreate(canonical_server_key);
729 if (!canonical_cached->proof_valid()) { 731 if (!canonical_cached->proof_valid()) {
730 return; 732 return;
731 } 733 }
732 CachedState* cached = LookupOrCreate(server_hostname); 734 CachedState* cached = LookupOrCreate(server_key);
733 cached->InitializeFrom(*canonical_cached); 735 cached->InitializeFrom(*canonical_cached);
734 } 736 }
735 737
736 } // namespace net 738 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698