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 13 matching lines...) Expand all Loading... |
24 // client. Note that this object isn't thread-safe. It's designed to be used on | 24 // client. Note that this object isn't thread-safe. It's designed to be used on |
25 // a single thread at a time. | 25 // a single thread at a time. |
26 class NET_EXPORT_PRIVATE QuicCryptoClientConfig : public QuicCryptoConfig { | 26 class NET_EXPORT_PRIVATE QuicCryptoClientConfig : public QuicCryptoConfig { |
27 public: | 27 public: |
28 // A CachedState contains the information that the client needs in order to | 28 // A CachedState contains the information that the client needs in order to |
29 // perform a 0-RTT handshake with a server. This information can be reused | 29 // perform a 0-RTT handshake with a server. This information can be reused |
30 // over several connections to the same server. | 30 // over several connections to the same server. |
31 class NET_EXPORT_PRIVATE CachedState { | 31 class NET_EXPORT_PRIVATE CachedState { |
32 public: | 32 public: |
33 CachedState(); | 33 CachedState(); |
| 34 explicit CachedState(scoped_ptr<QuicServerInfo> quic_server_info); |
34 ~CachedState(); | 35 ~CachedState(); |
35 | 36 |
36 // IsComplete returns true if this object contains enough information to | 37 // IsComplete returns true if this object contains enough information to |
37 // perform a handshake with the server. |now| is used to judge whether any | 38 // perform a handshake with the server. |now| is used to judge whether any |
38 // cached server config has expired. | 39 // cached server config has expired. |
39 bool IsComplete(QuicWallTime now) const; | 40 bool IsComplete(QuicWallTime now) const; |
40 | 41 |
41 // GetServerConfig returns the parsed contents of |server_config|, or NULL | 42 // GetServerConfig returns the parsed contents of |server_config|, or NULL |
42 // if |server_config| is empty. The return value is owned by this object | 43 // if |server_config| is empty. The return value is owned by this object |
43 // and is destroyed when this object is. | 44 // and is destroyed when this object is. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 83 |
83 // SetProofVerifyDetails takes ownership of |details|. | 84 // SetProofVerifyDetails takes ownership of |details|. |
84 void SetProofVerifyDetails(ProofVerifyDetails* details); | 85 void SetProofVerifyDetails(ProofVerifyDetails* details); |
85 | 86 |
86 // Copy the |server_config_|, |source_address_token_|, |certs_| and | 87 // Copy the |server_config_|, |source_address_token_|, |certs_| and |
87 // |server_config_sig_| from the |other|. The remaining fields, | 88 // |server_config_sig_| from the |other|. The remaining fields, |
88 // |generation_counter_|, |proof_verify_details_|, and |scfg_| remain | 89 // |generation_counter_|, |proof_verify_details_|, and |scfg_| remain |
89 // unchanged. | 90 // unchanged. |
90 void InitializeFrom(const CachedState& other); | 91 void InitializeFrom(const CachedState& other); |
91 | 92 |
92 // TODO(rtenneti): Need to flesh out the details of this method. A temporary | |
93 // place holder to load CachedState from disk cache. | |
94 void LoadFromDiskCache(QuicServerInfoFactory* quic_server_info_factory, | |
95 const std::string& server_hostname); | |
96 | |
97 private: | 93 private: |
98 std::string server_config_id_; // An opaque id from the server. | 94 std::string server_config_id_; // An opaque id from the server. |
99 std::string server_config_; // A serialized handshake message. | 95 std::string server_config_; // A serialized handshake message. |
100 std::string source_address_token_; // An opaque proof of IP ownership. | 96 std::string source_address_token_; // An opaque proof of IP ownership. |
101 std::vector<std::string> certs_; // A list of certificates in leaf-first | 97 std::vector<std::string> certs_; // A list of certificates in leaf-first |
102 // order. | 98 // order. |
103 std::string server_config_sig_; // A signature of |server_config_|. | 99 std::string server_config_sig_; // A signature of |server_config_|. |
104 bool server_config_valid_; // True if |server_config_| is correctly | 100 bool server_config_valid_; // True if |server_config_| is correctly |
105 // signed and |certs_| has been | 101 // signed and |certs_| has been |
106 // validated. | 102 // validated. |
107 // Generation counter associated with the |server_config_|, |certs_| and | 103 // Generation counter associated with the |server_config_|, |certs_| and |
108 // |server_config_sig_| combination. It is incremented whenever we set | 104 // |server_config_sig_| combination. It is incremented whenever we set |
109 // server_config_valid_ to false. | 105 // server_config_valid_ to false. |
110 uint64 generation_counter_; | 106 uint64 generation_counter_; |
111 | 107 |
112 scoped_ptr<ProofVerifyDetails> proof_verify_details_; | 108 scoped_ptr<ProofVerifyDetails> proof_verify_details_; |
113 | 109 |
114 // scfg contains the cached, parsed value of |server_config|. | 110 // scfg contains the cached, parsed value of |server_config|. |
115 mutable scoped_ptr<CryptoHandshakeMessage> scfg_; | 111 mutable scoped_ptr<CryptoHandshakeMessage> scfg_; |
116 | 112 |
| 113 // |quic_server_info_| is used to fetch crypto config information from disk. |
117 scoped_ptr<QuicServerInfo> quic_server_info_; | 114 scoped_ptr<QuicServerInfo> quic_server_info_; |
118 | 115 |
119 DISALLOW_COPY_AND_ASSIGN(CachedState); | 116 DISALLOW_COPY_AND_ASSIGN(CachedState); |
120 }; | 117 }; |
121 | 118 |
122 QuicCryptoClientConfig(); | 119 QuicCryptoClientConfig(); |
123 explicit QuicCryptoClientConfig( | |
124 QuicServerInfoFactory* quic_server_info_factory); | |
125 ~QuicCryptoClientConfig(); | 120 ~QuicCryptoClientConfig(); |
126 | 121 |
127 // Sets the members to reasonable, default values. | 122 // Sets the members to reasonable, default values. |
128 void SetDefaults(); | 123 void SetDefaults(); |
129 | 124 |
| 125 // Create returns a CachedState for the given hostname. It creates a |
| 126 // CachedState and caches it. If |quic_server_info_factory| is not NULL, then |
| 127 // it is used to create QuicServerInfo which is used to fetch crypto config |
| 128 // information from disk for the given hostname. |
| 129 CachedState* Create(const std::string& server_hostname, |
| 130 QuicServerInfoFactory* quic_server_info_factory); |
| 131 |
130 // LookupOrCreate returns a CachedState for the given hostname. If no such | 132 // LookupOrCreate returns a CachedState for the given hostname. If no such |
131 // CachedState currently exists, it will be created and cached. | 133 // CachedState currently exists, it will be created and cached. |
| 134 // TODO(rtenneti): fix the server code and pass QuicServerInfoFactory as |
| 135 // argument. |
132 CachedState* LookupOrCreate(const std::string& server_hostname); | 136 CachedState* LookupOrCreate(const std::string& server_hostname); |
133 | 137 |
134 // FillInchoateClientHello sets |out| to be a CHLO message that elicits a | 138 // FillInchoateClientHello sets |out| to be a CHLO message that elicits a |
135 // source-address token or SCFG from a server. If |cached| is non-NULL, the | 139 // source-address token or SCFG from a server. If |cached| is non-NULL, the |
136 // source-address token will be taken from it. |out_params| is used in order | 140 // source-address token will be taken from it. |out_params| is used in order |
137 // to store the cached certs that were sent as hints to the server in | 141 // to store the cached certs that were sent as hints to the server in |
138 // |out_params->cached_certs|. |preferred_version| is the version of the QUIC | 142 // |out_params->cached_certs|. |preferred_version| is the version of the QUIC |
139 // protocol that this client chose to use initially. This allows the server to | 143 // protocol that this client chose to use initially. This allows the server to |
140 // detect downgrade attacks. | 144 // detect downgrade attacks. |
141 void FillInchoateClientHello(const std::string& server_hostname, | 145 void FillInchoateClientHello(const std::string& server_hostname, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 // |canonical_crypto_config| has valid proof. | 216 // |canonical_crypto_config| has valid proof. |
213 void InitializeFrom(const std::string& server_hostname, | 217 void InitializeFrom(const std::string& server_hostname, |
214 const std::string& canonical_server_hostname, | 218 const std::string& canonical_server_hostname, |
215 QuicCryptoClientConfig* canonical_crypto_config); | 219 QuicCryptoClientConfig* canonical_crypto_config); |
216 | 220 |
217 private: | 221 private: |
218 // cached_states_ maps from the server hostname to the cached information | 222 // cached_states_ maps from the server hostname to the cached information |
219 // about that server. | 223 // about that server. |
220 std::map<std::string, CachedState*> cached_states_; | 224 std::map<std::string, CachedState*> cached_states_; |
221 | 225 |
222 QuicServerInfoFactory* quic_server_info_factory_; | |
223 scoped_ptr<ProofVerifier> proof_verifier_; | 226 scoped_ptr<ProofVerifier> proof_verifier_; |
224 scoped_ptr<ChannelIDSigner> channel_id_signer_; | 227 scoped_ptr<ChannelIDSigner> channel_id_signer_; |
225 | 228 |
226 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientConfig); | 229 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientConfig); |
227 }; | 230 }; |
228 | 231 |
229 } // namespace net | 232 } // namespace net |
230 | 233 |
231 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ | 234 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ |
OLD | NEW |