| 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> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
| 14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
| 15 #include "net/quic/crypto/crypto_handshake.h" | 15 #include "net/quic/crypto/crypto_handshake.h" |
| 16 #include "net/quic/quic_protocol.h" | 16 #include "net/quic/quic_protocol.h" |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 | 19 |
| 20 class ChannelIDSigner; | 20 class ChannelIDSigner; |
| 21 class CryptoHandshakeMessage; | 21 class CryptoHandshakeMessage; |
| 22 class ProofVerifier; | 22 class ProofVerifier; |
| 23 class ProofVerifyDetails; | 23 class ProofVerifyDetails; |
| 24 class QuicRandom; | 24 class QuicRandom; |
| 25 class QuicServerInfo; | 25 class QuicServerInfo; |
| 26 class QuicServerInfoFactory; | 26 class QuicServerInfoFactory; |
| 27 class QuicSessionKey; |
| 27 | 28 |
| 28 // QuicCryptoClientConfig contains crypto-related configuration settings for a | 29 // 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 | 30 // client. Note that this object isn't thread-safe. It's designed to be used on |
| 30 // a single thread at a time. | 31 // a single thread at a time. |
| 31 class NET_EXPORT_PRIVATE QuicCryptoClientConfig : public QuicCryptoConfig { | 32 class NET_EXPORT_PRIVATE QuicCryptoClientConfig : public QuicCryptoConfig { |
| 32 public: | 33 public: |
| 33 // A CachedState contains the information that the client needs in order to | 34 // 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 | 35 // perform a 0-RTT handshake with a server. This information can be reused |
| 35 // over several connections to the same server. | 36 // over several connections to the same server. |
| 36 class NET_EXPORT_PRIVATE CachedState { | 37 class NET_EXPORT_PRIVATE CachedState { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 137 |
| 137 DISALLOW_COPY_AND_ASSIGN(CachedState); | 138 DISALLOW_COPY_AND_ASSIGN(CachedState); |
| 138 }; | 139 }; |
| 139 | 140 |
| 140 QuicCryptoClientConfig(); | 141 QuicCryptoClientConfig(); |
| 141 ~QuicCryptoClientConfig(); | 142 ~QuicCryptoClientConfig(); |
| 142 | 143 |
| 143 // Sets the members to reasonable, default values. | 144 // Sets the members to reasonable, default values. |
| 144 void SetDefaults(); | 145 void SetDefaults(); |
| 145 | 146 |
| 146 // Create returns a CachedState for the given hostname. It creates a | 147 // Create returns a CachedState for the given |server_key|. It creates a |
| 147 // CachedState and caches it. If |quic_server_info_factory| is not NULL, then | 148 // CachedState and caches it. If |quic_server_info_factory| is not NULL, then |
| 148 // it is used to create QuicServerInfo which is used to fetch crypto config | 149 // it is used to create QuicServerInfo which is used to fetch crypto config |
| 149 // information from disk for the given hostname. | 150 // information from disk for the given |server_key|. |
| 150 CachedState* Create(const std::string& server_hostname, | 151 CachedState* Create(const QuicSessionKey& server_key, |
| 151 QuicServerInfoFactory* quic_server_info_factory); | 152 QuicServerInfoFactory* quic_server_info_factory); |
| 152 | 153 |
| 153 // LookupOrCreate returns a CachedState for the given hostname. If no such | 154 // LookupOrCreate returns a CachedState for the given |server_key|. If no such |
| 154 // CachedState currently exists, it will be created and cached. | 155 // CachedState currently exists, it will be created and cached. |
| 155 // TODO(rtenneti): fix the server code and pass QuicServerInfoFactory as | 156 // TODO(rtenneti): fix the server code and pass QuicServerInfoFactory as |
| 156 // argument. | 157 // argument. |
| 157 CachedState* LookupOrCreate(const std::string& server_hostname); | 158 CachedState* LookupOrCreate(const QuicSessionKey& server_key); |
| 158 | 159 |
| 159 // FillInchoateClientHello sets |out| to be a CHLO message that elicits a | 160 // FillInchoateClientHello sets |out| to be a CHLO message that elicits a |
| 160 // source-address token or SCFG from a server. If |cached| is non-NULL, the | 161 // source-address token or SCFG from a server. If |cached| is non-NULL, the |
| 161 // source-address token will be taken from it. |out_params| is used in order | 162 // source-address token will be taken from it. |out_params| is used in order |
| 162 // to store the cached certs that were sent as hints to the server in | 163 // to store the cached certs that were sent as hints to the server in |
| 163 // |out_params->cached_certs|. |preferred_version| is the version of the | 164 // |out_params->cached_certs|. |preferred_version| is the version of the |
| 164 // QUIC protocol that this client chose to use initially. This allows the | 165 // QUIC protocol that this client chose to use initially. This allows the |
| 165 // server to detect downgrade attacks. | 166 // server to detect downgrade attacks. |
| 166 void FillInchoateClientHello(const std::string& server_hostname, | 167 void FillInchoateClientHello(const std::string& server_hostname, |
| 167 const QuicVersion preferred_version, | 168 const QuicVersion preferred_version, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 void SetProofVerifier(ProofVerifier* verifier); | 226 void SetProofVerifier(ProofVerifier* verifier); |
| 226 | 227 |
| 227 ChannelIDSigner* channel_id_signer() const; | 228 ChannelIDSigner* channel_id_signer() const; |
| 228 | 229 |
| 229 // SetChannelIDSigner sets a ChannelIDSigner that will be called when the | 230 // SetChannelIDSigner sets a ChannelIDSigner that will be called when the |
| 230 // server supports channel IDs to sign a message proving possession of the | 231 // server supports channel IDs to sign a message proving possession of the |
| 231 // given ChannelID. This object takes ownership of |signer|. | 232 // given ChannelID. This object takes ownership of |signer|. |
| 232 void SetChannelIDSigner(ChannelIDSigner* signer); | 233 void SetChannelIDSigner(ChannelIDSigner* signer); |
| 233 | 234 |
| 234 // Initialize the CachedState from |canonical_crypto_config| for the | 235 // Initialize the CachedState from |canonical_crypto_config| for the |
| 235 // |canonical_server_hostname| as the initial CachedState for | 236 // |canonical_server_key| as the initial CachedState for |server_key|. We will |
| 236 // |server_hostname|. We will copy config data only if | 237 // copy config data only if |canonical_crypto_config| has valid proof. |
| 237 // |canonical_crypto_config| has valid proof. | 238 void InitializeFrom(const QuicSessionKey& server_key, |
| 238 void InitializeFrom(const std::string& server_hostname, | 239 const QuicSessionKey& canonical_server_key, |
| 239 const std::string& canonical_server_hostname, | |
| 240 QuicCryptoClientConfig* canonical_crypto_config); | 240 QuicCryptoClientConfig* canonical_crypto_config); |
| 241 | 241 |
| 242 private: | 242 private: |
| 243 // cached_states_ maps from the server hostname to the cached information | 243 // cached_states_ maps from the server_key to the cached information about |
| 244 // about that server. | 244 // that server. |
| 245 std::map<std::string, CachedState*> cached_states_; | 245 std::map<QuicSessionKey, CachedState*> cached_states_; |
| 246 | 246 |
| 247 scoped_ptr<ProofVerifier> proof_verifier_; | 247 scoped_ptr<ProofVerifier> proof_verifier_; |
| 248 scoped_ptr<ChannelIDSigner> channel_id_signer_; | 248 scoped_ptr<ChannelIDSigner> channel_id_signer_; |
| 249 | 249 |
| 250 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientConfig); | 250 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientConfig); |
| 251 }; | 251 }; |
| 252 | 252 |
| 253 } // namespace net | 253 } // namespace net |
| 254 | 254 |
| 255 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ | 255 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ |
| OLD | NEW |