| 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" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 DCHECK(!server_config_valid_); | 225 DCHECK(!server_config_valid_); |
| 226 server_config_ = other.server_config_; | 226 server_config_ = other.server_config_; |
| 227 source_address_token_ = other.source_address_token_; | 227 source_address_token_ = other.source_address_token_; |
| 228 certs_ = other.certs_; | 228 certs_ = other.certs_; |
| 229 server_config_sig_ = other.server_config_sig_; | 229 server_config_sig_ = other.server_config_sig_; |
| 230 server_config_valid_ = other.server_config_valid_; | 230 server_config_valid_ = other.server_config_valid_; |
| 231 ++generation_counter_; | 231 ++generation_counter_; |
| 232 } | 232 } |
| 233 | 233 |
| 234 // An issue to be solved: while we are loading the data from disk cache, it is | 234 // An issue to be solved: while we are loading the data from disk cache, it is |
| 235 // possible for another request for the same hostname update the CachedState | 235 // possible for another request for the same hostname and port update the |
| 236 // because that request has sent FillInchoateClientHello and got REJ message. | 236 // CachedState because that request has sent FillInchoateClientHello and got REJ |
| 237 // Loading of data from disk cache shouldn't blindly overwrite what is in | 237 // message. Loading of data from disk cache shouldn't blindly overwrite what is |
| 238 // CachedState. | 238 // in CachedState. |
| 239 bool QuicCryptoClientConfig::CachedState::LoadQuicServerInfo(QuicWallTime now) { | 239 bool QuicCryptoClientConfig::CachedState::LoadQuicServerInfo(QuicWallTime now) { |
| 240 DCHECK(server_config_.empty()); | 240 DCHECK(server_config_.empty()); |
| 241 DCHECK(quic_server_info_.get()); | 241 DCHECK(quic_server_info_.get()); |
| 242 DCHECK(quic_server_info_->IsDataReady()); | 242 DCHECK(quic_server_info_->IsDataReady()); |
| 243 | 243 |
| 244 const QuicServerInfo::State& state(quic_server_info_->state()); | 244 const QuicServerInfo::State& state(quic_server_info_->state()); |
| 245 if (state.server_config.empty()) { | 245 if (state.server_config.empty()) { |
| 246 return false; | 246 return false; |
| 247 } | 247 } |
| 248 | 248 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 kexs[0] = kC255; | 290 kexs[0] = kC255; |
| 291 kexs[1] = kP256; | 291 kexs[1] = kP256; |
| 292 | 292 |
| 293 // Authenticated encryption algorithms. | 293 // Authenticated encryption algorithms. |
| 294 aead.resize(1); | 294 aead.resize(1); |
| 295 aead[0] = kAESG; | 295 aead[0] = kAESG; |
| 296 } | 296 } |
| 297 | 297 |
| 298 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::Create( | 298 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::Create( |
| 299 const string& server_hostname, | 299 const string& server_hostname, |
| 300 uint16 port, |
| 300 QuicServerInfoFactory* quic_server_info_factory) { | 301 QuicServerInfoFactory* quic_server_info_factory) { |
| 301 DCHECK(cached_states_.find(server_hostname) == cached_states_.end()); | 302 DCHECK(cached_states_.find(server_hostname) == cached_states_.end()); |
| 302 scoped_ptr<QuicServerInfo> quic_server_info; | 303 scoped_ptr<QuicServerInfo> quic_server_info; |
| 303 if (quic_server_info_factory) { | 304 if (quic_server_info_factory) { |
| 304 quic_server_info.reset( | 305 quic_server_info.reset( |
| 305 quic_server_info_factory->GetForHost(server_hostname)); | 306 quic_server_info_factory->GetForHost(server_hostname, port)); |
| 306 quic_server_info->Start(); | 307 quic_server_info->Start(); |
| 307 } | 308 } |
| 308 | 309 |
| 309 CachedState* cached = new CachedState(quic_server_info.Pass()); | 310 CachedState* cached = new CachedState(quic_server_info.Pass()); |
| 310 cached_states_.insert(make_pair(server_hostname, cached)); | 311 cached_states_.insert(make_pair(server_hostname, cached)); |
| 311 return cached; | 312 return cached; |
| 312 } | 313 } |
| 313 | 314 |
| 314 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate( | 315 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate( |
| 315 const string& server_hostname) { | 316 const string& server_hostname, |
| 317 uint16 port) { |
| 316 map<string, CachedState*>::const_iterator it = | 318 map<string, CachedState*>::const_iterator it = |
| 317 cached_states_.find(server_hostname); | 319 cached_states_.find(server_hostname); |
| 318 if (it != cached_states_.end()) { | 320 if (it != cached_states_.end()) { |
| 319 return it->second; | 321 return it->second; |
| 320 } | 322 } |
| 321 return Create(server_hostname, NULL); | 323 return Create(server_hostname, port, NULL); |
| 322 } | 324 } |
| 323 | 325 |
| 324 void QuicCryptoClientConfig::FillInchoateClientHello( | 326 void QuicCryptoClientConfig::FillInchoateClientHello( |
| 325 const string& server_hostname, | 327 const string& server_hostname, |
| 326 const QuicVersion preferred_version, | 328 const QuicVersion preferred_version, |
| 327 const CachedState* cached, | 329 const CachedState* cached, |
| 328 QuicCryptoNegotiatedParameters* out_params, | 330 QuicCryptoNegotiatedParameters* out_params, |
| 329 CryptoHandshakeMessage* out) const { | 331 CryptoHandshakeMessage* out) const { |
| 330 out->set_tag(kCHLO); | 332 out->set_tag(kCHLO); |
| 331 out->set_minimum_size(kClientHelloMinimumSize); | 333 out->set_minimum_size(kClientHelloMinimumSize); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 std::string& server_hostname, |
| 727 uint16 server_port, |
| 725 const std::string& canonical_server_hostname, | 728 const std::string& canonical_server_hostname, |
| 729 uint16 canonical_server_port, |
| 726 QuicCryptoClientConfig* canonical_crypto_config) { | 730 QuicCryptoClientConfig* canonical_crypto_config) { |
| 727 CachedState* canonical_cached = | 731 CachedState* canonical_cached = |
| 728 canonical_crypto_config->LookupOrCreate(canonical_server_hostname); | 732 canonical_crypto_config->LookupOrCreate(canonical_server_hostname, |
| 733 canonical_server_port); |
| 729 if (!canonical_cached->proof_valid()) { | 734 if (!canonical_cached->proof_valid()) { |
| 730 return; | 735 return; |
| 731 } | 736 } |
| 732 CachedState* cached = LookupOrCreate(server_hostname); | 737 CachedState* cached = LookupOrCreate(server_hostname, server_port); |
| 733 cached->InitializeFrom(*canonical_cached); | 738 cached->InitializeFrom(*canonical_cached); |
| 734 } | 739 } |
| 735 | 740 |
| 736 } // namespace net | 741 } // namespace net |
| OLD | NEW |