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) { |
| 305 HostPortPair host_port_pair(server_hostname, port); |
304 quic_server_info.reset( | 306 quic_server_info.reset( |
305 quic_server_info_factory->GetForHost(server_hostname)); | 307 quic_server_info_factory->GetForHostPortPair(host_port_pair)); |
306 quic_server_info->Start(); | 308 quic_server_info->Start(); |
307 } | 309 } |
308 | 310 |
309 CachedState* cached = new CachedState(quic_server_info.Pass()); | 311 CachedState* cached = new CachedState(quic_server_info.Pass()); |
310 cached_states_.insert(make_pair(server_hostname, cached)); | 312 cached_states_.insert(make_pair(server_hostname, cached)); |
311 return cached; | 313 return cached; |
312 } | 314 } |
313 | 315 |
314 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate( | 316 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate( |
315 const string& server_hostname) { | 317 const string& server_hostname, |
| 318 uint16 port) { |
316 map<string, CachedState*>::const_iterator it = | 319 map<string, CachedState*>::const_iterator it = |
317 cached_states_.find(server_hostname); | 320 cached_states_.find(server_hostname); |
318 if (it != cached_states_.end()) { | 321 if (it != cached_states_.end()) { |
319 return it->second; | 322 return it->second; |
320 } | 323 } |
321 return Create(server_hostname, NULL); | 324 return Create(server_hostname, port, NULL); |
322 } | 325 } |
323 | 326 |
324 void QuicCryptoClientConfig::FillInchoateClientHello( | 327 void QuicCryptoClientConfig::FillInchoateClientHello( |
325 const string& server_hostname, | 328 const string& server_hostname, |
326 const QuicVersion preferred_version, | 329 const QuicVersion preferred_version, |
327 const CachedState* cached, | 330 const CachedState* cached, |
328 QuicCryptoNegotiatedParameters* out_params, | 331 QuicCryptoNegotiatedParameters* out_params, |
329 CryptoHandshakeMessage* out) const { | 332 CryptoHandshakeMessage* out) const { |
330 out->set_tag(kCHLO); | 333 out->set_tag(kCHLO); |
331 out->set_minimum_size(kClientHelloMinimumSize); | 334 out->set_minimum_size(kClientHelloMinimumSize); |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 ChannelIDSigner* QuicCryptoClientConfig::channel_id_signer() const { | 719 ChannelIDSigner* QuicCryptoClientConfig::channel_id_signer() const { |
717 return channel_id_signer_.get(); | 720 return channel_id_signer_.get(); |
718 } | 721 } |
719 | 722 |
720 void QuicCryptoClientConfig::SetChannelIDSigner(ChannelIDSigner* signer) { | 723 void QuicCryptoClientConfig::SetChannelIDSigner(ChannelIDSigner* signer) { |
721 channel_id_signer_.reset(signer); | 724 channel_id_signer_.reset(signer); |
722 } | 725 } |
723 | 726 |
724 void QuicCryptoClientConfig::InitializeFrom( | 727 void QuicCryptoClientConfig::InitializeFrom( |
725 const std::string& server_hostname, | 728 const std::string& server_hostname, |
| 729 uint16 server_port, |
726 const std::string& canonical_server_hostname, | 730 const std::string& canonical_server_hostname, |
| 731 uint16 canonical_server_port, |
727 QuicCryptoClientConfig* canonical_crypto_config) { | 732 QuicCryptoClientConfig* canonical_crypto_config) { |
728 CachedState* canonical_cached = | 733 CachedState* canonical_cached = |
729 canonical_crypto_config->LookupOrCreate(canonical_server_hostname); | 734 canonical_crypto_config->LookupOrCreate(canonical_server_hostname, |
| 735 canonical_server_port); |
730 if (!canonical_cached->proof_valid()) { | 736 if (!canonical_cached->proof_valid()) { |
731 return; | 737 return; |
732 } | 738 } |
733 CachedState* cached = LookupOrCreate(server_hostname); | 739 CachedState* cached = LookupOrCreate(server_hostname, server_port); |
734 cached->InitializeFrom(*canonical_cached); | 740 cached->InitializeFrom(*canonical_cached); |
735 } | 741 } |
736 | 742 |
737 } // namespace net | 743 } // namespace net |
OLD | NEW |