| 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 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 ValidateClientHelloResultCallback(); | 110 ValidateClientHelloResultCallback(); |
| 111 virtual void Run(scoped_refptr<Result> result, | 111 virtual void Run(scoped_refptr<Result> result, |
| 112 std::unique_ptr<ProofSource::Details> details) = 0; | 112 std::unique_ptr<ProofSource::Details> details) = 0; |
| 113 virtual ~ValidateClientHelloResultCallback(); | 113 virtual ~ValidateClientHelloResultCallback(); |
| 114 | 114 |
| 115 private: | 115 private: |
| 116 DISALLOW_COPY_AND_ASSIGN(ValidateClientHelloResultCallback); | 116 DISALLOW_COPY_AND_ASSIGN(ValidateClientHelloResultCallback); |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 // Callback used to accept the result of the ProcessClientHello method. |
| 120 class NET_EXPORT_PRIVATE ProcessClientHelloResultCallback { |
| 121 public: |
| 122 ProcessClientHelloResultCallback(); |
| 123 virtual ~ProcessClientHelloResultCallback(); |
| 124 virtual void Run( |
| 125 QuicErrorCode error, |
| 126 const std::string& error_details, |
| 127 std::unique_ptr<CryptoHandshakeMessage> message, |
| 128 std::unique_ptr<DiversificationNonce> diversification_nonce) = 0; |
| 129 |
| 130 private: |
| 131 DISALLOW_COPY_AND_ASSIGN(ProcessClientHelloResultCallback); |
| 132 }; |
| 133 |
| 119 // Callback used to receive the results of a call to | 134 // Callback used to receive the results of a call to |
| 120 // BuildServerConfigUpdateMessage. | 135 // BuildServerConfigUpdateMessage. |
| 121 class BuildServerConfigUpdateMessageResultCallback { | 136 class BuildServerConfigUpdateMessageResultCallback { |
| 122 public: | 137 public: |
| 123 BuildServerConfigUpdateMessageResultCallback() = default; | 138 BuildServerConfigUpdateMessageResultCallback() = default; |
| 124 virtual ~BuildServerConfigUpdateMessageResultCallback() {} | 139 virtual ~BuildServerConfigUpdateMessageResultCallback() {} |
| 125 virtual void Run(bool ok, const CryptoHandshakeMessage& message) = 0; | 140 virtual void Run(bool ok, const CryptoHandshakeMessage& message) = 0; |
| 126 | 141 |
| 127 private: | 142 private: |
| 128 DISALLOW_COPY_AND_ASSIGN(BuildServerConfigUpdateMessageResultCallback); | 143 DISALLOW_COPY_AND_ASSIGN(BuildServerConfigUpdateMessageResultCallback); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 241 |
| 227 // SetSourceAddressTokenKeys sets the keys to be tried, in order, when | 242 // SetSourceAddressTokenKeys sets the keys to be tried, in order, when |
| 228 // decrypting a source address token. Note that these keys are used *without* | 243 // decrypting a source address token. Note that these keys are used *without* |
| 229 // passing them through a KDF, in contradistinction to the | 244 // passing them through a KDF, in contradistinction to the |
| 230 // |source_address_token_secret| argument to the constructor. | 245 // |source_address_token_secret| argument to the constructor. |
| 231 void SetSourceAddressTokenKeys(const std::vector<std::string>& keys); | 246 void SetSourceAddressTokenKeys(const std::vector<std::string>& keys); |
| 232 | 247 |
| 233 // Get the server config ids for all known configs. | 248 // Get the server config ids for all known configs. |
| 234 void GetConfigIds(std::vector<std::string>* scids) const; | 249 void GetConfigIds(std::vector<std::string>* scids) const; |
| 235 | 250 |
| 236 // Checks |client_hello| for gross errors and determines whether it | 251 // Checks |client_hello| for gross errors and determines whether it can be |
| 237 // can be shown to be fresh (i.e. not a replay). The result of the | 252 // shown to be fresh (i.e. not a replay). The result of the validation step |
| 238 // validation step must be interpreted by calling | 253 // must be interpreted by calling QuicCryptoServerConfig::ProcessClientHello |
| 239 // QuicCryptoServerConfig::ProcessClientHello from the done_cb. | 254 // from the done_cb. |
| 240 // | 255 // |
| 241 // ValidateClientHello may invoke the done_cb before unrolling the | 256 // ValidateClientHello may invoke the done_cb before unrolling the |
| 242 // stack if it is able to assess the validity of the client_nonce | 257 // stack if it is able to assess the validity of the client_nonce |
| 243 // without asynchronous operations. | 258 // without asynchronous operations. |
| 244 // | 259 // |
| 245 // client_hello: the incoming client hello message. | 260 // client_hello: the incoming client hello message. |
| 246 // client_ip: the IP address of the client, which is used to generate and | 261 // client_ip: the IP address of the client, which is used to generate and |
| 247 // validate source-address tokens. | 262 // validate source-address tokens. |
| 248 // server_ip: the IP address of the server. The IP address may be used for | 263 // server_ip: the IP address of the server. The IP address may be used for |
| 249 // certificate selection. | 264 // certificate selection. |
| 250 // version: protocol version used for this connection. | 265 // version: protocol version used for this connection. |
| 251 // clock: used to validate client nonces and ephemeral keys. | 266 // clock: used to validate client nonces and ephemeral keys. |
| 252 // crypto_proof: output structure containing the crypto proof used in reply to | 267 // crypto_proof: in/out parameter to which will be written the crypto proof |
| 253 // a proof demand. | 268 // used in reply to a proof demand. The pointed-to-object must |
| 269 // live until the callback is invoked. |
| 254 // done_cb: single-use callback that accepts an opaque | 270 // done_cb: single-use callback that accepts an opaque |
| 255 // ValidatedClientHelloMsg token that holds information about | 271 // ValidatedClientHelloMsg token that holds information about |
| 256 // the client hello. The callback will always be called exactly | 272 // the client hello. The callback will always be called exactly |
| 257 // once, either under the current call stack, or after the | 273 // once, either under the current call stack, or after the |
| 258 // completion of an asynchronous operation. | 274 // completion of an asynchronous operation. |
| 259 void ValidateClientHello( | 275 void ValidateClientHello( |
| 260 const CryptoHandshakeMessage& client_hello, | 276 const CryptoHandshakeMessage& client_hello, |
| 261 const IPAddress& client_ip, | 277 const IPAddress& client_ip, |
| 262 const IPAddress& server_ip, | 278 const IPAddress& server_ip, |
| 263 QuicVersion version, | 279 QuicVersion version, |
| 264 const QuicClock* clock, | 280 const QuicClock* clock, |
| 265 QuicCryptoProof* crypto_proof, | 281 QuicCryptoProof* crypto_proof, |
| 266 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; | 282 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; |
| 267 | 283 |
| 268 // ProcessClientHello processes |client_hello| and decides whether to accept | 284 // ProcessClientHello processes |client_hello| and decides whether to accept |
| 269 // or reject the connection. If the connection is to be accepted, |out| is | 285 // or reject the connection. If the connection is to be accepted, |done_cb| is |
| 270 // set to the contents of the ServerHello, |out_params| is completed and | 286 // invoked with the contents of the ServerHello and QUIC_NO_ERROR. Otherwise |
| 271 // QUIC_NO_ERROR is returned. Otherwise |out| is set to be a REJ or SREJ | 287 // |done_cb| is called with a REJ or SREJ message and QUIC_NO_ERROR. |
| 272 // message and QUIC_NO_ERROR is returned. | |
| 273 // | 288 // |
| 274 // validate_chlo_result: Output from the asynchronous call to | 289 // validate_chlo_result: Output from the asynchronous call to |
| 275 // ValidateClientHello. Contains the client hello message and | 290 // ValidateClientHello. Contains the client hello message and |
| 276 // information about it. | 291 // information about it. |
| 277 // reject_only: Only generate rejections, not server hello messages. | 292 // reject_only: Only generate rejections, not server hello messages. |
| 278 // connection_id: the ConnectionId for the connection, which is used in key | 293 // connection_id: the ConnectionId for the connection, which is used in key |
| 279 // derivation. | 294 // derivation. |
| 280 // server_ip: the IP address of the server. The IP address may be used for | 295 // server_ip: the IP address of the server. The IP address may be used for |
| 281 // certificate selection. | 296 // certificate selection. |
| 282 // client_address: the IP address and port of the client. The IP address is | 297 // client_address: the IP address and port of the client. The IP address is |
| 283 // used to generate and validate source-address tokens. | 298 // used to generate and validate source-address tokens. |
| 284 // version: version of the QUIC protocol in use for this connection | 299 // version: version of the QUIC protocol in use for this connection |
| 285 // supported_versions: versions of the QUIC protocol that this server | 300 // supported_versions: versions of the QUIC protocol that this server |
| 286 // supports. | 301 // supports. |
| 287 // clock: used to validate client nonces and ephemeral keys. | 302 // clock: used to validate client nonces and ephemeral keys. |
| 288 // rand: an entropy source | 303 // rand: an entropy source |
| 289 // compressed_certs_cache: the cache that caches a set of most recently used | 304 // compressed_certs_cache: the cache that caches a set of most recently used |
| 290 // certs. Owned by QuicDispatcher. | 305 // certs. Owned by QuicDispatcher. |
| 291 // params: the state of the handshake. This may be updated with a server | 306 // params: the state of the handshake. This may be updated with a server |
| 292 // nonce when we send a rejection. After a successful handshake, this will | 307 // nonce when we send a rejection. |
| 293 // contain the state of the connection. | |
| 294 // crypto_proof: output structure containing the crypto proof used in reply to | 308 // crypto_proof: output structure containing the crypto proof used in reply to |
| 295 // a proof demand. | 309 // a proof demand. |
| 296 // total_framing_overhead: the total per-packet overhead for a stream frame | 310 // total_framing_overhead: the total per-packet overhead for a stream frame |
| 297 // chlo_packet_size: the size, in bytes, of the CHLO packet | 311 // chlo_packet_size: the size, in bytes, of the CHLO packet |
| 298 // out: the resulting handshake message (either REJ or SHLO) | 312 // done_cb: the callback invoked on completion |
| 299 // out_diversification_nonce: If the resulting handshake message is SHLO and | 313 void ProcessClientHello( |
| 300 // the version is greater than QUIC_VERSION_32 then this contains a | |
| 301 // 32-byte value that should be included in the public header of | |
| 302 // initially encrypted packets. | |
| 303 // error_details: used to store a std::string describing any error. | |
| 304 QuicErrorCode ProcessClientHello( | |
| 305 scoped_refptr<ValidateClientHelloResultCallback::Result> | 314 scoped_refptr<ValidateClientHelloResultCallback::Result> |
| 306 validate_chlo_result, | 315 validate_chlo_result, |
| 307 bool reject_only, | 316 bool reject_only, |
| 308 QuicConnectionId connection_id, | 317 QuicConnectionId connection_id, |
| 309 const IPAddress& server_ip, | 318 const IPAddress& server_ip, |
| 310 const IPEndPoint& client_address, | 319 const IPEndPoint& client_address, |
| 311 QuicVersion version, | 320 QuicVersion version, |
| 312 const QuicVersionVector& supported_versions, | 321 const QuicVersionVector& supported_versions, |
| 313 bool use_stateless_rejects, | 322 bool use_stateless_rejects, |
| 314 QuicConnectionId server_designated_connection_id, | 323 QuicConnectionId server_designated_connection_id, |
| 315 const QuicClock* clock, | 324 const QuicClock* clock, |
| 316 QuicRandom* rand, | 325 QuicRandom* rand, |
| 317 QuicCompressedCertsCache* compressed_certs_cache, | 326 QuicCompressedCertsCache* compressed_certs_cache, |
| 318 QuicCryptoNegotiatedParameters* params, | 327 QuicCryptoNegotiatedParameters* params, |
| 319 QuicCryptoProof* crypto_proof, | 328 QuicCryptoProof* crypto_proof, |
| 320 QuicByteCount total_framing_overhead, | 329 QuicByteCount total_framing_overhead, |
| 321 QuicByteCount chlo_packet_size, | 330 QuicByteCount chlo_packet_size, |
| 322 CryptoHandshakeMessage* out, | 331 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const; |
| 323 DiversificationNonce* out_diversification_nonce, | |
| 324 std::string* error_details) const; | |
| 325 | 332 |
| 326 // BuildServerConfigUpdateMessage sets |out| to be a SCUP message containing | 333 // BuildServerConfigUpdateMessage sets |out| to be a SCUP message containing |
| 327 // the current primary config, an up to date source-address token, and cert | 334 // the current primary config, an up to date source-address token, and cert |
| 328 // chain and proof in the case of secure QUIC. Returns true if successfully | 335 // chain and proof in the case of secure QUIC. Returns true if successfully |
| 329 // filled |out|. | 336 // filled |out|. |
| 330 // | 337 // |
| 331 // |cached_network_params| is optional, and can be nullptr. | 338 // |cached_network_params| is optional, and can be nullptr. |
| 332 // | 339 // |
| 333 // TODO(gredner): remove this when --FLAGS_enable_async_get_proof is removed. | 340 // TODO(gredner): remove this when --FLAGS_enable_async_get_proof is removed. |
| 334 bool BuildServerConfigUpdateMessage( | 341 bool BuildServerConfigUpdateMessage( |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 const uint8_t* primary_orbit, | 570 const uint8_t* primary_orbit, |
| 564 scoped_refptr<Config> requested_config, | 571 scoped_refptr<Config> requested_config, |
| 565 scoped_refptr<Config> primary_config, | 572 scoped_refptr<Config> primary_config, |
| 566 QuicCryptoProof* crypto_proof, | 573 QuicCryptoProof* crypto_proof, |
| 567 std::unique_ptr<ProofSource::Details> proof_source_details, | 574 std::unique_ptr<ProofSource::Details> proof_source_details, |
| 568 bool get_proof_failed, | 575 bool get_proof_failed, |
| 569 scoped_refptr<ValidateClientHelloResultCallback::Result> | 576 scoped_refptr<ValidateClientHelloResultCallback::Result> |
| 570 client_hello_state, | 577 client_hello_state, |
| 571 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; | 578 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; |
| 572 | 579 |
| 580 // Portion of ProcessClientHello which executes after GetProof. |
| 581 void ProcessClientHelloAfterGetProof( |
| 582 const ValidateClientHelloResultCallback::Result& validate_chlo_result, |
| 583 bool reject_only, |
| 584 QuicConnectionId connection_id, |
| 585 const IPEndPoint& client_address, |
| 586 QuicVersion version, |
| 587 const QuicVersionVector& supported_versions, |
| 588 bool use_stateless_rejects, |
| 589 QuicConnectionId server_designated_connection_id, |
| 590 const QuicClock* clock, |
| 591 QuicRandom* rand, |
| 592 QuicCompressedCertsCache* compressed_certs_cache, |
| 593 QuicCryptoNegotiatedParameters* params, |
| 594 QuicCryptoProof* crypto_proof, |
| 595 QuicByteCount total_framing_overhead, |
| 596 QuicByteCount chlo_packet_size, |
| 597 const scoped_refptr<Config>& requested_config, |
| 598 const scoped_refptr<Config>& primary_config, |
| 599 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const; |
| 600 |
| 573 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|. | 601 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|. |
| 574 void BuildRejection(QuicVersion version, | 602 void BuildRejection(QuicVersion version, |
| 575 QuicWallTime now, | 603 QuicWallTime now, |
| 576 const Config& config, | 604 const Config& config, |
| 577 const CryptoHandshakeMessage& client_hello, | 605 const CryptoHandshakeMessage& client_hello, |
| 578 const ClientHelloInfo& info, | 606 const ClientHelloInfo& info, |
| 579 const CachedNetworkParameters& cached_network_params, | 607 const CachedNetworkParameters& cached_network_params, |
| 580 bool use_stateless_rejects, | 608 bool use_stateless_rejects, |
| 581 QuicConnectionId server_designated_connection_id, | 609 QuicConnectionId server_designated_connection_id, |
| 582 QuicRandom* rand, | 610 QuicRandom* rand, |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 std::string cert_sct; | 847 std::string cert_sct; |
| 820 // The server config that is used for this proof (and the rest of the | 848 // The server config that is used for this proof (and the rest of the |
| 821 // request). | 849 // request). |
| 822 scoped_refptr<QuicCryptoServerConfig::Config> config; | 850 scoped_refptr<QuicCryptoServerConfig::Config> config; |
| 823 std::string primary_scid; | 851 std::string primary_scid; |
| 824 }; | 852 }; |
| 825 | 853 |
| 826 } // namespace net | 854 } // namespace net |
| 827 | 855 |
| 828 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ | 856 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ |
| OLD | NEW |