| 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/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 CachedState* canonical_cached = | 803 CachedState* canonical_cached = |
| 804 canonical_crypto_config->LookupOrCreate(canonical_server_id); | 804 canonical_crypto_config->LookupOrCreate(canonical_server_id); |
| 805 if (!canonical_cached->proof_valid()) { | 805 if (!canonical_cached->proof_valid()) { |
| 806 return; | 806 return; |
| 807 } | 807 } |
| 808 CachedState* cached = LookupOrCreate(server_id); | 808 CachedState* cached = LookupOrCreate(server_id); |
| 809 cached->InitializeFrom(*canonical_cached); | 809 cached->InitializeFrom(*canonical_cached); |
| 810 } | 810 } |
| 811 | 811 |
| 812 void QuicCryptoClientConfig::AddCanonicalSuffix(const string& suffix) { | 812 void QuicCryptoClientConfig::AddCanonicalSuffix(const string& suffix) { |
| 813 canoncial_suffixes_.push_back(suffix); | 813 canonical_suffixes_.push_back(suffix); |
| 814 } | 814 } |
| 815 | 815 |
| 816 void QuicCryptoClientConfig::PreferAesGcm() { | 816 void QuicCryptoClientConfig::PreferAesGcm() { |
| 817 DCHECK(!aead.empty()); | 817 DCHECK(!aead.empty()); |
| 818 if (aead.size() <= 1) { | 818 if (aead.size() <= 1) { |
| 819 return; | 819 return; |
| 820 } | 820 } |
| 821 QuicTagVector::iterator pos = find(aead.begin(), aead.end(), kAESG); | 821 QuicTagVector::iterator pos = find(aead.begin(), aead.end(), kAESG); |
| 822 if (pos != aead.end()) { | 822 if (pos != aead.end()) { |
| 823 aead.erase(pos); | 823 aead.erase(pos); |
| 824 aead.insert(aead.begin(), kAESG); | 824 aead.insert(aead.begin(), kAESG); |
| 825 } | 825 } |
| 826 } | 826 } |
| 827 | 827 |
| 828 void QuicCryptoClientConfig::DisableEcdsa() { | 828 void QuicCryptoClientConfig::DisableEcdsa() { |
| 829 disable_ecdsa_ = true; | 829 disable_ecdsa_ = true; |
| 830 } | 830 } |
| 831 | 831 |
| 832 void QuicCryptoClientConfig::PopulateFromCanonicalConfig( | 832 void QuicCryptoClientConfig::PopulateFromCanonicalConfig( |
| 833 const QuicServerId& server_id, | 833 const QuicServerId& server_id, |
| 834 CachedState* server_state) { | 834 CachedState* server_state) { |
| 835 DCHECK(server_state->IsEmpty()); | 835 DCHECK(server_state->IsEmpty()); |
| 836 size_t i = 0; | 836 size_t i = 0; |
| 837 for (; i < canoncial_suffixes_.size(); ++i) { | 837 for (; i < canonical_suffixes_.size(); ++i) { |
| 838 if (EndsWith(server_id.host(), canoncial_suffixes_[i], false)) { | 838 if (EndsWith(server_id.host(), canonical_suffixes_[i], false)) { |
| 839 break; | 839 break; |
| 840 } | 840 } |
| 841 } | 841 } |
| 842 if (i == canoncial_suffixes_.size()) | 842 if (i == canonical_suffixes_.size()) |
| 843 return; | 843 return; |
| 844 | 844 |
| 845 QuicServerId suffix_server_id(canoncial_suffixes_[i], server_id.port(), | 845 QuicServerId suffix_server_id(canonical_suffixes_[i], server_id.port(), |
| 846 server_id.is_https(), | 846 server_id.is_https(), |
| 847 server_id.privacy_mode()); | 847 server_id.privacy_mode()); |
| 848 if (!ContainsKey(canonical_server_map_, suffix_server_id)) { | 848 if (!ContainsKey(canonical_server_map_, suffix_server_id)) { |
| 849 // This is the first host we've seen which matches the suffix, so make it | 849 // This is the first host we've seen which matches the suffix, so make it |
| 850 // canonical. | 850 // canonical. |
| 851 canonical_server_map_[suffix_server_id] = server_id; | 851 canonical_server_map_[suffix_server_id] = server_id; |
| 852 return; | 852 return; |
| 853 } | 853 } |
| 854 | 854 |
| 855 const QuicServerId& canonical_server_id = | 855 const QuicServerId& canonical_server_id = |
| 856 canonical_server_map_[suffix_server_id]; | 856 canonical_server_map_[suffix_server_id]; |
| 857 CachedState* canonical_state = cached_states_[canonical_server_id]; | 857 CachedState* canonical_state = cached_states_[canonical_server_id]; |
| 858 if (!canonical_state->proof_valid()) { | 858 if (!canonical_state->proof_valid()) { |
| 859 return; | 859 return; |
| 860 } | 860 } |
| 861 | 861 |
| 862 // Update canonical version to point at the "most recent" entry. | 862 // Update canonical version to point at the "most recent" entry. |
| 863 canonical_server_map_[suffix_server_id] = server_id; | 863 canonical_server_map_[suffix_server_id] = server_id; |
| 864 | 864 |
| 865 server_state->InitializeFrom(*canonical_state); | 865 server_state->InitializeFrom(*canonical_state); |
| 866 } | 866 } |
| 867 | 867 |
| 868 } // namespace net | 868 } // namespace net |
| OLD | NEW |