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_SERVER_CONFIG_H_ | 5 #ifndef NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ |
6 #define NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ | 6 #define NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/strings/string_piece.h" | 18 #include "base/strings/string_piece.h" |
19 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
20 #include "net/base/ip_address.h" | 20 #include "net/base/ip_address.h" |
21 #include "net/base/ip_endpoint.h" | 21 #include "net/base/ip_endpoint.h" |
22 #include "net/base/net_export.h" | 22 #include "net/base/net_export.h" |
23 #include "net/quic/crypto/crypto_handshake.h" | 23 #include "net/quic/crypto/crypto_handshake.h" |
24 #include "net/quic/crypto/crypto_handshake_message.h" | 24 #include "net/quic/crypto/crypto_handshake_message.h" |
25 #include "net/quic/crypto/crypto_protocol.h" | 25 #include "net/quic/crypto/crypto_protocol.h" |
26 #include "net/quic/crypto/crypto_secret_boxer.h" | 26 #include "net/quic/crypto/crypto_secret_boxer.h" |
27 #include "net/quic/crypto/proof_source.h" | 27 #include "net/quic/crypto/proof_source.h" |
| 28 #include "net/quic/crypto/quic_compressed_certs_cache.h" |
28 #include "net/quic/proto/cached_network_parameters.pb.h" | 29 #include "net/quic/proto/cached_network_parameters.pb.h" |
29 #include "net/quic/proto/source_address_token.pb.h" | 30 #include "net/quic/proto/source_address_token.pb.h" |
30 #include "net/quic/quic_time.h" | 31 #include "net/quic/quic_time.h" |
31 | 32 |
32 namespace net { | 33 namespace net { |
33 | 34 |
34 class CryptoHandshakeMessage; | 35 class CryptoHandshakeMessage; |
35 class EphemeralKeySource; | 36 class EphemeralKeySource; |
36 class KeyExchange; | 37 class KeyExchange; |
37 class ProofSource; | 38 class ProofSource; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // derivation. | 250 // derivation. |
250 // server_ip: the IP address of the server. The IP address may be used for | 251 // server_ip: the IP address of the server. The IP address may be used for |
251 // certificate selection. | 252 // certificate selection. |
252 // client_address: the IP address and port of the client. The IP address is | 253 // client_address: the IP address and port of the client. The IP address is |
253 // used to generate and validate source-address tokens. | 254 // used to generate and validate source-address tokens. |
254 // version: version of the QUIC protocol in use for this connection | 255 // version: version of the QUIC protocol in use for this connection |
255 // supported_versions: versions of the QUIC protocol that this server | 256 // supported_versions: versions of the QUIC protocol that this server |
256 // supports. | 257 // supports. |
257 // clock: used to validate client nonces and ephemeral keys. | 258 // clock: used to validate client nonces and ephemeral keys. |
258 // rand: an entropy source | 259 // rand: an entropy source |
| 260 // compressed_certs_cache: the cache that caches a set of most recently used |
| 261 // certs. Owned by QuicDispatcher. |
259 // params: the state of the handshake. This may be updated with a server | 262 // params: the state of the handshake. This may be updated with a server |
260 // nonce when we send a rejection. After a successful handshake, this will | 263 // nonce when we send a rejection. After a successful handshake, this will |
261 // contain the state of the connection. | 264 // contain the state of the connection. |
262 // crypto_proof: output structure containing the crypto proof used in reply to | 265 // crypto_proof: output structure containing the crypto proof used in reply to |
263 // a proof demand. | 266 // a proof demand. |
264 // out: the resulting handshake message (either REJ or SHLO) | 267 // out: the resulting handshake message (either REJ or SHLO) |
265 // error_details: used to store a string describing any error. | 268 // error_details: used to store a string describing any error. |
266 QuicErrorCode ProcessClientHello( | 269 QuicErrorCode ProcessClientHello( |
267 const ValidateClientHelloResultCallback::Result& validate_chlo_result, | 270 const ValidateClientHelloResultCallback::Result& validate_chlo_result, |
268 QuicConnectionId connection_id, | 271 QuicConnectionId connection_id, |
269 const IPAddress& server_ip, | 272 const IPAddress& server_ip, |
270 const IPEndPoint& client_address, | 273 const IPEndPoint& client_address, |
271 QuicVersion version, | 274 QuicVersion version, |
272 const QuicVersionVector& supported_versions, | 275 const QuicVersionVector& supported_versions, |
273 bool use_stateless_rejects, | 276 bool use_stateless_rejects, |
274 QuicConnectionId server_designated_connection_id, | 277 QuicConnectionId server_designated_connection_id, |
275 const QuicClock* clock, | 278 const QuicClock* clock, |
276 QuicRandom* rand, | 279 QuicRandom* rand, |
| 280 QuicCompressedCertsCache* compressed_certs_cache, |
277 QuicCryptoNegotiatedParameters* params, | 281 QuicCryptoNegotiatedParameters* params, |
278 QuicCryptoProof* crypto_proof, | 282 QuicCryptoProof* crypto_proof, |
279 CryptoHandshakeMessage* out, | 283 CryptoHandshakeMessage* out, |
280 std::string* error_details) const; | 284 std::string* error_details) const; |
281 | 285 |
282 // BuildServerConfigUpdateMessage sets |out| to be a SCUP message containing | 286 // BuildServerConfigUpdateMessage sets |out| to be a SCUP message containing |
283 // the current primary config, an up to date source-address token, and cert | 287 // the current primary config, an up to date source-address token, and cert |
284 // chain and proof in the case of secure QUIC. Returns true if successfully | 288 // chain and proof in the case of secure QUIC. Returns true if successfully |
285 // filled |out|. | 289 // filled |out|. |
286 // | 290 // |
287 // |cached_network_params| is optional, and can be nullptr. | 291 // |cached_network_params| is optional, and can be nullptr. |
288 bool BuildServerConfigUpdateMessage( | 292 bool BuildServerConfigUpdateMessage( |
289 QuicVersion version, | 293 QuicVersion version, |
290 const SourceAddressTokens& previous_source_address_tokens, | 294 const SourceAddressTokens& previous_source_address_tokens, |
291 const IPAddress& server_ip, | 295 const IPAddress& server_ip, |
292 const IPAddress& client_ip, | 296 const IPAddress& client_ip, |
293 const QuicClock* clock, | 297 const QuicClock* clock, |
294 QuicRandom* rand, | 298 QuicRandom* rand, |
| 299 QuicCompressedCertsCache* compressed_certs_cache, |
295 const QuicCryptoNegotiatedParameters& params, | 300 const QuicCryptoNegotiatedParameters& params, |
296 const CachedNetworkParameters* cached_network_params, | 301 const CachedNetworkParameters* cached_network_params, |
297 CryptoHandshakeMessage* out) const; | 302 CryptoHandshakeMessage* out) const; |
298 | 303 |
299 // SetEphemeralKeySource installs an object that can cache ephemeral keys for | 304 // SetEphemeralKeySource installs an object that can cache ephemeral keys for |
300 // a short period of time. This object takes ownership of | 305 // a short period of time. This object takes ownership of |
301 // |ephemeral_key_source|. If not set then ephemeral keys will be generated | 306 // |ephemeral_key_source|. If not set then ephemeral keys will be generated |
302 // per-connection. | 307 // per-connection. |
303 void SetEphemeralKeySource(EphemeralKeySource* ephemeral_key_source); | 308 void SetEphemeralKeySource(EphemeralKeySource* ephemeral_key_source); |
304 | 309 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 471 |
467 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|. | 472 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|. |
468 void BuildRejection(QuicVersion version, | 473 void BuildRejection(QuicVersion version, |
469 const Config& config, | 474 const Config& config, |
470 const CryptoHandshakeMessage& client_hello, | 475 const CryptoHandshakeMessage& client_hello, |
471 const ClientHelloInfo& info, | 476 const ClientHelloInfo& info, |
472 const CachedNetworkParameters& cached_network_params, | 477 const CachedNetworkParameters& cached_network_params, |
473 bool use_stateless_rejects, | 478 bool use_stateless_rejects, |
474 QuicConnectionId server_designated_connection_id, | 479 QuicConnectionId server_designated_connection_id, |
475 QuicRandom* rand, | 480 QuicRandom* rand, |
| 481 QuicCompressedCertsCache* compressed_certs_cache, |
476 QuicCryptoNegotiatedParameters* params, | 482 QuicCryptoNegotiatedParameters* params, |
477 const QuicCryptoProof& crypto_proof, | 483 const QuicCryptoProof& crypto_proof, |
478 CryptoHandshakeMessage* out) const; | 484 CryptoHandshakeMessage* out) const; |
479 | 485 |
| 486 // CompressChain compresses the certificates in |chain->certs| and returns a |
| 487 // compressed representation. |common_sets| contains the common certificate |
| 488 // sets known locally and |client_common_set_hashes| contains the hashes of |
| 489 // the common sets known to the peer. |client_cached_cert_hashes| contains |
| 490 // 64-bit, FNV-1a hashes of certificates that the peer already possesses. |
| 491 const std::string CompressChain( |
| 492 QuicCompressedCertsCache* compressed_certs_cache, |
| 493 const scoped_refptr<ProofSource::Chain>& chain, |
| 494 const std::string& client_common_set_hashes, |
| 495 const std::string& client_cached_cert_hashes, |
| 496 const CommonCertSets* common_sets) const; |
| 497 |
480 // ParseConfigProtobuf parses the given config protobuf and returns a | 498 // ParseConfigProtobuf parses the given config protobuf and returns a |
481 // scoped_refptr<Config> if successful. The caller adopts the reference to the | 499 // scoped_refptr<Config> if successful. The caller adopts the reference to the |
482 // Config. On error, ParseConfigProtobuf returns nullptr. | 500 // Config. On error, ParseConfigProtobuf returns nullptr. |
483 scoped_refptr<Config> ParseConfigProtobuf(QuicServerConfigProtobuf* protobuf); | 501 scoped_refptr<Config> ParseConfigProtobuf(QuicServerConfigProtobuf* protobuf); |
484 | 502 |
485 // NewSourceAddressToken returns a fresh source address token for the given | 503 // NewSourceAddressToken returns a fresh source address token for the given |
486 // IP address. |cached_network_params| is optional, and can be nullptr. | 504 // IP address. |cached_network_params| is optional, and can be nullptr. |
487 std::string NewSourceAddressToken( | 505 std::string NewSourceAddressToken( |
488 const Config& config, | 506 const Config& config, |
489 const SourceAddressTokens& previous_tokens, | 507 const SourceAddressTokens& previous_tokens, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 std::string cert_sct; | 659 std::string cert_sct; |
642 // The server config that is used for this proof (and the rest of the | 660 // The server config that is used for this proof (and the rest of the |
643 // request). | 661 // request). |
644 scoped_refptr<QuicCryptoServerConfig::Config> config; | 662 scoped_refptr<QuicCryptoServerConfig::Config> config; |
645 std::string primary_scid; | 663 std::string primary_scid; |
646 }; | 664 }; |
647 | 665 |
648 } // namespace net | 666 } // namespace net |
649 | 667 |
650 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ | 668 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ |
OLD | NEW |