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 #ifndef NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ | 5 #ifndef NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ |
6 #define NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ | 6 #define NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 17 matching lines...) Expand all Loading... |
28 // QuicCryptoClientConfig contains crypto-related configuration settings for a | 28 // QuicCryptoClientConfig contains crypto-related configuration settings for a |
29 // client. Note that this object isn't thread-safe. It's designed to be used on | 29 // client. Note that this object isn't thread-safe. It's designed to be used on |
30 // a single thread at a time. | 30 // a single thread at a time. |
31 class NET_EXPORT_PRIVATE QuicCryptoClientConfig : public QuicCryptoConfig { | 31 class NET_EXPORT_PRIVATE QuicCryptoClientConfig : public QuicCryptoConfig { |
32 public: | 32 public: |
33 // A CachedState contains the information that the client needs in order to | 33 // A CachedState contains the information that the client needs in order to |
34 // perform a 0-RTT handshake with a server. This information can be reused | 34 // perform a 0-RTT handshake with a server. This information can be reused |
35 // over several connections to the same server. | 35 // over several connections to the same server. |
36 class NET_EXPORT_PRIVATE CachedState { | 36 class NET_EXPORT_PRIVATE CachedState { |
37 public: | 37 public: |
| 38 // Enum to track if the server config is valid or not. If it is not valid, |
| 39 // it specifies why it is invalid. |
| 40 enum ServerConfigState { |
| 41 // WARNING: Do not change the numerical values of any of server config |
| 42 // state. Do not remove deprecated server config states - just comment |
| 43 // them as deprecated. |
| 44 SERVER_CONFIG_EMPTY = 0, |
| 45 SERVER_CONFIG_INVALID = 1, |
| 46 SERVER_CONFIG_CORRUPTED = 2, |
| 47 SERVER_CONFIG_EXPIRED = 3, |
| 48 SERVER_CONFIG_INVALID_EXPIRY = 4, |
| 49 SERVER_CONFIG_VALID = 5, |
| 50 // NOTE: Add new server config states only immediately above this line. |
| 51 // Make sure to update the QuicServerConfigState enum in |
| 52 // tools/metrics/histograms/histograms.xml accordingly. |
| 53 SERVER_CONFIG_COUNT |
| 54 }; |
| 55 |
38 CachedState(); | 56 CachedState(); |
39 ~CachedState(); | 57 ~CachedState(); |
40 | 58 |
41 // IsComplete returns true if this object contains enough information to | 59 // IsComplete returns true if this object contains enough information to |
42 // perform a handshake with the server. |now| is used to judge whether any | 60 // perform a handshake with the server. |now| is used to judge whether any |
43 // cached server config has expired. | 61 // cached server config has expired. |
44 bool IsComplete(QuicWallTime now) const; | 62 bool IsComplete(QuicWallTime now) const; |
45 | 63 |
46 // IsEmpty returns true if |server_config_| is empty. | 64 // IsEmpty returns true if |server_config_| is empty. |
47 bool IsEmpty() const; | 65 bool IsEmpty() const; |
48 | 66 |
49 // GetServerConfig returns the parsed contents of |server_config|, or | 67 // GetServerConfig returns the parsed contents of |server_config|, or |
50 // nullptr if |server_config| is empty. The return value is owned by this | 68 // nullptr if |server_config| is empty. The return value is owned by this |
51 // object and is destroyed when this object is. | 69 // object and is destroyed when this object is. |
52 const CryptoHandshakeMessage* GetServerConfig() const; | 70 const CryptoHandshakeMessage* GetServerConfig() const; |
53 | 71 |
54 // SetServerConfig checks that |server_config| parses correctly and stores | 72 // SetServerConfig checks that |server_config| parses correctly and stores |
55 // it in |server_config_|. |now| is used to judge whether |server_config| | 73 // it in |server_config_|. |now| is used to judge whether |server_config| |
56 // has expired. | 74 // has expired. |
57 QuicErrorCode SetServerConfig(base::StringPiece server_config, | 75 ServerConfigState SetServerConfig(base::StringPiece server_config, |
58 QuicWallTime now, | 76 QuicWallTime now, |
59 std::string* error_details); | 77 std::string* error_details); |
60 | 78 |
61 // InvalidateServerConfig clears the cached server config (if any). | 79 // InvalidateServerConfig clears the cached server config (if any). |
62 void InvalidateServerConfig(); | 80 void InvalidateServerConfig(); |
63 | 81 |
64 // SetProof stores a certificate chain and signature. | 82 // SetProof stores a certificate chain and signature. |
65 void SetProof(const std::vector<std::string>& certs, | 83 void SetProof(const std::vector<std::string>& certs, |
66 base::StringPiece signature); | 84 base::StringPiece signature); |
67 | 85 |
68 // Clears all the data. | 86 // Clears all the data. |
69 void Clear(); | 87 void Clear(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 // updated server config during a connection. | 293 // updated server config during a connection. |
276 QuicErrorCode CacheNewServerConfig( | 294 QuicErrorCode CacheNewServerConfig( |
277 const CryptoHandshakeMessage& message, | 295 const CryptoHandshakeMessage& message, |
278 QuicWallTime now, | 296 QuicWallTime now, |
279 const std::vector<std::string>& cached_certs, | 297 const std::vector<std::string>& cached_certs, |
280 CachedState* cached, | 298 CachedState* cached, |
281 std::string* error_details); | 299 std::string* error_details); |
282 | 300 |
283 // If the suffix of the hostname in |server_id| is in |canonical_suffixes_|, | 301 // If the suffix of the hostname in |server_id| is in |canonical_suffixes_|, |
284 // then populate |cached| with the canonical cached state from | 302 // then populate |cached| with the canonical cached state from |
285 // |canonical_server_map_| for that suffix. | 303 // |canonical_server_map_| for that suffix. Returns true if |cached| is |
286 void PopulateFromCanonicalConfig(const QuicServerId& server_id, | 304 // initialized with canonical cached state. |
| 305 bool PopulateFromCanonicalConfig(const QuicServerId& server_id, |
287 CachedState* cached); | 306 CachedState* cached); |
288 | 307 |
289 // cached_states_ maps from the server_id to the cached information about | 308 // cached_states_ maps from the server_id to the cached information about |
290 // that server. | 309 // that server. |
291 CachedStateMap cached_states_; | 310 CachedStateMap cached_states_; |
292 | 311 |
293 // Contains a map of servers which could share the same server config. Map | 312 // Contains a map of servers which could share the same server config. Map |
294 // from a canonical host suffix/port/scheme to a representative server with | 313 // from a canonical host suffix/port/scheme to a representative server with |
295 // the canonical suffix, which has a plausible set of initial certificates | 314 // the canonical suffix, which has a plausible set of initial certificates |
296 // (or at least server public key). | 315 // (or at least server public key). |
(...skipping 11 matching lines...) Expand all Loading... |
308 | 327 |
309 // The |user_agent_id_| passed in QUIC's CHLO message. | 328 // The |user_agent_id_| passed in QUIC's CHLO message. |
310 std::string user_agent_id_; | 329 std::string user_agent_id_; |
311 | 330 |
312 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientConfig); | 331 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientConfig); |
313 }; | 332 }; |
314 | 333 |
315 } // namespace net | 334 } // namespace net |
316 | 335 |
317 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ | 336 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ |
OLD | NEW |