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/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
8 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
10 #include "net/quic/crypto/cert_compressor.h" | 11 #include "net/quic/crypto/cert_compressor.h" |
11 #include "net/quic/crypto/chacha20_poly1305_encrypter.h" | 12 #include "net/quic/crypto/chacha20_poly1305_encrypter.h" |
12 #include "net/quic/crypto/channel_id.h" | 13 #include "net/quic/crypto/channel_id.h" |
13 #include "net/quic/crypto/common_cert_set.h" | 14 #include "net/quic/crypto/common_cert_set.h" |
14 #include "net/quic/crypto/crypto_framer.h" | 15 #include "net/quic/crypto/crypto_framer.h" |
15 #include "net/quic/crypto/crypto_utils.h" | 16 #include "net/quic/crypto/crypto_utils.h" |
16 #include "net/quic/crypto/curve25519_key_exchange.h" | 17 #include "net/quic/crypto/curve25519_key_exchange.h" |
17 #include "net/quic/crypto/key_exchange.h" | 18 #include "net/quic/crypto/key_exchange.h" |
18 #include "net/quic/crypto/p256_key_exchange.h" | 19 #include "net/quic/crypto/p256_key_exchange.h" |
19 #include "net/quic/crypto/proof_verifier.h" | 20 #include "net/quic/crypto/proof_verifier.h" |
20 #include "net/quic/crypto/quic_encrypter.h" | 21 #include "net/quic/crypto/quic_encrypter.h" |
21 #include "net/quic/quic_utils.h" | 22 #include "net/quic/quic_utils.h" |
22 | 23 |
23 using base::StringPiece; | 24 using base::StringPiece; |
24 using std::find; | 25 using std::find; |
25 using std::make_pair; | 26 using std::make_pair; |
26 using std::map; | 27 using std::map; |
27 using std::string; | 28 using std::string; |
28 using std::vector; | 29 using std::vector; |
29 | 30 |
30 namespace net { | 31 namespace net { |
31 | 32 |
33 namespace { | |
34 | |
35 enum ServerConfigState { | |
36 // WARNING: Do not change the numerical values of any of server config state. | |
37 // Do not remove deprecated server config states - just comment them as | |
38 // deprecated. | |
39 SERVER_CONFIG_EMPTY = 0, | |
40 SERVER_CONFIG_INVALID = 1, | |
41 SERVER_CONFIG_CORRUPTED = 2, | |
42 SERVER_CONFIG_EXPIRED = 3, | |
43 | |
44 // NOTE: Add new server config states only immediately above this line. Make | |
45 // sure to update the QuicServerConfigState enum in | |
46 // tools/metrics/histograms/histograms.xml accordingly. | |
47 SERVER_CONFIG_COUNT | |
48 }; | |
49 | |
50 void RecordServerConfigState(ServerConfigState server_config_state) { | |
51 UMA_HISTOGRAM_ENUMERATION("Net.QuicClientHelloServerConfigState", | |
52 server_config_state, SERVER_CONFIG_COUNT); | |
53 } | |
54 | |
55 } // namespace | |
56 | |
32 QuicCryptoClientConfig::QuicCryptoClientConfig() | 57 QuicCryptoClientConfig::QuicCryptoClientConfig() |
33 : disable_ecdsa_(false) {} | 58 : disable_ecdsa_(false) {} |
34 | 59 |
35 QuicCryptoClientConfig::~QuicCryptoClientConfig() { | 60 QuicCryptoClientConfig::~QuicCryptoClientConfig() { |
36 STLDeleteValues(&cached_states_); | 61 STLDeleteValues(&cached_states_); |
37 } | 62 } |
38 | 63 |
39 QuicCryptoClientConfig::CachedState::CachedState() | 64 QuicCryptoClientConfig::CachedState::CachedState() |
40 : server_config_valid_(false), | 65 : server_config_valid_(false), |
41 generation_counter_(0) {} | 66 generation_counter_(0) {} |
42 | 67 |
43 QuicCryptoClientConfig::CachedState::~CachedState() {} | 68 QuicCryptoClientConfig::CachedState::~CachedState() {} |
44 | 69 |
45 bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const { | 70 bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const { |
46 if (server_config_.empty() || !server_config_valid_) { | 71 if (server_config_.empty()) { |
72 RecordServerConfigState(SERVER_CONFIG_EMPTY); | |
47 return false; | 73 return false; |
48 } | 74 } |
49 | 75 |
76 if (!server_config_valid_) { | |
77 RecordServerConfigState(SERVER_CONFIG_INVALID); | |
78 return false; | |
79 } | |
80 | |
50 const CryptoHandshakeMessage* scfg = GetServerConfig(); | 81 const CryptoHandshakeMessage* scfg = GetServerConfig(); |
51 if (!scfg) { | 82 if (!scfg) { |
52 // Should be impossible short of cache corruption. | 83 // Should be impossible short of cache corruption. |
53 DCHECK(false); | 84 DCHECK(false); |
85 RecordServerConfigState(SERVER_CONFIG_CORRUPTED); | |
54 return false; | 86 return false; |
55 } | 87 } |
56 | 88 |
57 uint64 expiry_seconds; | 89 uint64 expiry_seconds; |
58 if (scfg->GetUint64(kEXPY, &expiry_seconds) != QUIC_NO_ERROR || | 90 if (scfg->GetUint64(kEXPY, &expiry_seconds) != QUIC_NO_ERROR || |
wtc
2014/07/29 01:29:06
Nit: scfg->GetUint64(kEXPY, &expiry_seconds) != QU
ramant (doing other things)
2014/07/29 23:52:32
Thanks Wan-Teh. Fixed it in https://codereview.chr
| |
59 now.ToUNIXSeconds() >= expiry_seconds) { | 91 now.ToUNIXSeconds() >= expiry_seconds) { |
92 RecordServerConfigState(SERVER_CONFIG_EXPIRED); | |
60 return false; | 93 return false; |
61 } | 94 } |
62 | 95 |
63 return true; | 96 return true; |
64 } | 97 } |
65 | 98 |
66 bool QuicCryptoClientConfig::CachedState::IsEmpty() const { | 99 bool QuicCryptoClientConfig::CachedState::IsEmpty() const { |
67 return server_config_.empty(); | 100 return server_config_.empty(); |
68 } | 101 } |
69 | 102 |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
799 return; | 832 return; |
800 } | 833 } |
801 | 834 |
802 // Update canonical version to point at the "most recent" entry. | 835 // Update canonical version to point at the "most recent" entry. |
803 canonical_server_map_[suffix_server_id] = server_id; | 836 canonical_server_map_[suffix_server_id] = server_id; |
804 | 837 |
805 server_state->InitializeFrom(*canonical_state); | 838 server_state->InitializeFrom(*canonical_state); |
806 } | 839 } |
807 | 840 |
808 } // namespace net | 841 } // namespace net |
OLD | NEW |