Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: net/quic/core/crypto/quic_crypto_server_config.h

Issue 2516033003: Landing Recent QUIC changes until Mon Nov 14 04:43:50 2016 +0000 (Closed)
Patch Set: Remove unused UpdatePacketGapSentHistogram() function. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 23 matching lines...) Expand all
34 34
35 class CryptoHandshakeMessage; 35 class CryptoHandshakeMessage;
36 class EphemeralKeySource; 36 class EphemeralKeySource;
37 class KeyExchange; 37 class KeyExchange;
38 class ProofSource; 38 class ProofSource;
39 class QuicClock; 39 class QuicClock;
40 class QuicDecrypter; 40 class QuicDecrypter;
41 class QuicEncrypter; 41 class QuicEncrypter;
42 class QuicRandom; 42 class QuicRandom;
43 class QuicServerConfigProtobuf; 43 class QuicServerConfigProtobuf;
44 class StrikeRegister; 44 struct QuicSignedServerConfig;
45 class StrikeRegisterClient;
46 struct QuicCryptoProof;
47 45
48 // ClientHelloInfo contains information about a client hello message that is 46 // ClientHelloInfo contains information about a client hello message that is
49 // only kept for as long as it's being processed. 47 // only kept for as long as it's being processed.
50 struct ClientHelloInfo { 48 struct ClientHelloInfo {
51 ClientHelloInfo(const IPAddress& in_client_ip, QuicWallTime in_now); 49 ClientHelloInfo(const IPAddress& in_client_ip, QuicWallTime in_now);
52 ClientHelloInfo(const ClientHelloInfo& other); 50 ClientHelloInfo(const ClientHelloInfo& other);
53 ~ClientHelloInfo(); 51 ~ClientHelloInfo();
54 52
55 // Inputs to EvaluateClientHello. 53 // Inputs to EvaluateClientHello.
56 const IPAddress client_ip; 54 const IPAddress client_ip;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // ValidatedClientHelloMsg token that holds information about 272 // ValidatedClientHelloMsg token that holds information about
275 // the client hello. The callback will always be called exactly 273 // the client hello. The callback will always be called exactly
276 // once, either under the current call stack, or after the 274 // once, either under the current call stack, or after the
277 // completion of an asynchronous operation. 275 // completion of an asynchronous operation.
278 void ValidateClientHello( 276 void ValidateClientHello(
279 const CryptoHandshakeMessage& client_hello, 277 const CryptoHandshakeMessage& client_hello,
280 const IPAddress& client_ip, 278 const IPAddress& client_ip,
281 const IPAddress& server_ip, 279 const IPAddress& server_ip,
282 QuicVersion version, 280 QuicVersion version,
283 const QuicClock* clock, 281 const QuicClock* clock,
284 scoped_refptr<QuicCryptoProof> crypto_proof, 282 scoped_refptr<QuicSignedServerConfig> crypto_proof,
285 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; 283 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const;
286 284
287 // ProcessClientHello processes |client_hello| and decides whether to accept 285 // ProcessClientHello processes |client_hello| and decides whether to accept
288 // or reject the connection. If the connection is to be accepted, |done_cb| is 286 // or reject the connection. If the connection is to be accepted, |done_cb| is
289 // invoked with the contents of the ServerHello and QUIC_NO_ERROR. Otherwise 287 // invoked with the contents of the ServerHello and QUIC_NO_ERROR. Otherwise
290 // |done_cb| is called with a REJ or SREJ message and QUIC_NO_ERROR. 288 // |done_cb| is called with a REJ or SREJ message and QUIC_NO_ERROR.
291 // 289 //
292 // validate_chlo_result: Output from the asynchronous call to 290 // validate_chlo_result: Output from the asynchronous call to
293 // ValidateClientHello. Contains the client hello message and 291 // ValidateClientHello. Contains the client hello message and
294 // information about it. 292 // information about it.
(...skipping 26 matching lines...) Expand all
321 const IPAddress& server_ip, 319 const IPAddress& server_ip,
322 const IPEndPoint& client_address, 320 const IPEndPoint& client_address,
323 QuicVersion version, 321 QuicVersion version,
324 const QuicVersionVector& supported_versions, 322 const QuicVersionVector& supported_versions,
325 bool use_stateless_rejects, 323 bool use_stateless_rejects,
326 QuicConnectionId server_designated_connection_id, 324 QuicConnectionId server_designated_connection_id,
327 const QuicClock* clock, 325 const QuicClock* clock,
328 QuicRandom* rand, 326 QuicRandom* rand,
329 QuicCompressedCertsCache* compressed_certs_cache, 327 QuicCompressedCertsCache* compressed_certs_cache,
330 scoped_refptr<QuicCryptoNegotiatedParameters> params, 328 scoped_refptr<QuicCryptoNegotiatedParameters> params,
331 scoped_refptr<QuicCryptoProof> crypto_proof, 329 scoped_refptr<QuicSignedServerConfig> crypto_proof,
332 QuicByteCount total_framing_overhead, 330 QuicByteCount total_framing_overhead,
333 QuicByteCount chlo_packet_size, 331 QuicByteCount chlo_packet_size,
334 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const; 332 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const;
335 333
336 // BuildServerConfigUpdateMessage sets |out| to be a SCUP message containing 334 // BuildServerConfigUpdateMessage sets |out| to be a SCUP message containing
337 // the current primary config, an up to date source-address token, and cert 335 // the current primary config, an up to date source-address token, and cert
338 // chain and proof in the case of secure QUIC. Returns true if successfully 336 // chain and proof in the case of secure QUIC. Returns true if successfully
339 // filled |out|. 337 // filled |out|.
340 // 338 //
341 // |cached_network_params| is optional, and can be nullptr. 339 // |cached_network_params| is optional, and can be nullptr.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 const CachedNetworkParameters* cached_network_params, 376 const CachedNetworkParameters* cached_network_params,
379 const QuicTagVector& connection_options, 377 const QuicTagVector& connection_options,
380 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb) const; 378 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb) const;
381 379
382 // SetEphemeralKeySource installs an object that can cache ephemeral keys for 380 // SetEphemeralKeySource installs an object that can cache ephemeral keys for
383 // a short period of time. This object takes ownership of 381 // a short period of time. This object takes ownership of
384 // |ephemeral_key_source|. If not set then ephemeral keys will be generated 382 // |ephemeral_key_source|. If not set then ephemeral keys will be generated
385 // per-connection. 383 // per-connection.
386 void SetEphemeralKeySource(EphemeralKeySource* ephemeral_key_source); 384 void SetEphemeralKeySource(EphemeralKeySource* ephemeral_key_source);
387 385
388 // Install an externally created StrikeRegisterClient for use to
389 // interact with the strike register. This object takes ownership
390 // of the |strike_register_client|.
391 void SetStrikeRegisterClient(StrikeRegisterClient* strike_register_client);
392
393 // set_replay_protection controls whether replay protection is enabled. If 386 // set_replay_protection controls whether replay protection is enabled. If
394 // replay protection is disabled then no strike registers are needed and 387 // replay protection is disabled then no strike registers are needed and
395 // frontends can share an orbit value without a shared strike-register. 388 // frontends can share an orbit value without a shared strike-register.
396 // However, an attacker can duplicate a handshake and cause a client's 389 // However, an attacker can duplicate a handshake and cause a client's
397 // request to be processed twice. 390 // request to be processed twice.
398 void set_replay_protection(bool on); 391 void set_replay_protection(bool on);
399 392
400 // set_chlo_multiplier specifies the multiple of the CHLO message size 393 // set_chlo_multiplier specifies the multiple of the CHLO message size
401 // that a REJ message must stay under when the client doesn't present a 394 // that a REJ message must stay under when the client doesn't present a
402 // valid source-address token. 395 // valid source-address token.
403 void set_chlo_multiplier(size_t multiplier); 396 void set_chlo_multiplier(size_t multiplier);
404 397
405 // set_strike_register_no_startup_period configures the strike register to
406 // not have a startup period.
407 void set_strike_register_no_startup_period();
408
409 // set_strike_register_max_entries sets the maximum number of entries that
410 // the internal strike register will hold. If the strike register fills up
411 // then the oldest entries (by the client's clock) will be dropped.
412 void set_strike_register_max_entries(uint32_t max_entries);
413
414 // set_strike_register_window_secs sets the number of seconds around the
415 // current time that the strike register will attempt to be authoritative
416 // for. Setting a larger value allows for greater client clock-skew, but
417 // means that the quiescent startup period must be longer.
418 void set_strike_register_window_secs(uint32_t window_secs);
419
420 // set_source_address_token_future_secs sets the number of seconds into the 398 // set_source_address_token_future_secs sets the number of seconds into the
421 // future that source-address tokens will be accepted from. Since 399 // future that source-address tokens will be accepted from. Since
422 // source-address tokens are authenticated, this should only happen if 400 // source-address tokens are authenticated, this should only happen if
423 // another, valid server has clock-skew. 401 // another, valid server has clock-skew.
424 void set_source_address_token_future_secs(uint32_t future_secs); 402 void set_source_address_token_future_secs(uint32_t future_secs);
425 403
426 // set_source_address_token_lifetime_secs sets the number of seconds that a 404 // set_source_address_token_lifetime_secs sets the number of seconds that a
427 // source-address token will be valid for. 405 // source-address token will be valid for.
428 void set_source_address_token_lifetime_secs(uint32_t lifetime_secs); 406 void set_source_address_token_lifetime_secs(uint32_t lifetime_secs);
429 407
430 // set_server_nonce_strike_register_max_entries sets the number of entries in
431 // the server-nonce strike-register. This is used to record that server nonce
432 // values have been used. If the number of entries is too small then clients
433 // which are depending on server nonces may fail to handshake because their
434 // nonce has expired in the amount of time it took to go from the server to
435 // the client and back.
436 void set_server_nonce_strike_register_max_entries(uint32_t max_entries);
437
438 // set_server_nonce_strike_register_window_secs sets the number of seconds
439 // around the current time that the server-nonce strike-register will accept
440 // nonces from. Setting a larger value allows for clients to delay follow-up
441 // client hellos for longer and still use server nonces as proofs of
442 // uniqueness.
443 void set_server_nonce_strike_register_window_secs(uint32_t window_secs);
444
445 // set_enable_serving_sct enables or disables serving signed cert timestamp 408 // set_enable_serving_sct enables or disables serving signed cert timestamp
446 // (RFC6962) in server hello. 409 // (RFC6962) in server hello.
447 void set_enable_serving_sct(bool enable_serving_sct); 410 void set_enable_serving_sct(bool enable_serving_sct);
448 411
449 // Set and take ownership of the callback to invoke on primary config changes. 412 // Set and take ownership of the callback to invoke on primary config changes.
450 void AcquirePrimaryConfigChangedCb( 413 void AcquirePrimaryConfigChangedCb(
451 std::unique_ptr<PrimaryConfigChangedCallback> cb); 414 std::unique_ptr<PrimaryConfigChangedCallback> cb);
452 415
453 // Returns the number of configs this object owns. 416 // Returns the number of configs this object owns.
454 int NumberOfConfigs() const; 417 int NumberOfConfigs() const;
455 418
456 // Callers retain the ownership of |rejection_observer| which must outlive the 419 // Callers retain the ownership of |rejection_observer| which must outlive the
457 // config. 420 // config.
458 void set_rejection_observer(RejectionObserver* rejection_observer) { 421 void set_rejection_observer(RejectionObserver* rejection_observer) {
459 rejection_observer_ = rejection_observer; 422 rejection_observer_ = rejection_observer;
460 } 423 }
461 424
462 private: 425 private:
463 friend class test::QuicCryptoServerConfigPeer; 426 friend class test::QuicCryptoServerConfigPeer;
464 friend struct QuicCryptoProof; 427 friend struct QuicSignedServerConfig;
465 428
466 // Config represents a server config: a collection of preferences and 429 // Config represents a server config: a collection of preferences and
467 // Diffie-Hellman public values. 430 // Diffie-Hellman public values.
468 class NET_EXPORT_PRIVATE Config : public QuicCryptoConfig, 431 class NET_EXPORT_PRIVATE Config : public QuicCryptoConfig,
469 public base::RefCounted<Config> { 432 public base::RefCounted<Config> {
470 public: 433 public:
471 Config(); 434 Config();
472 435
473 // TODO(rtenneti): since this is a class, we should probably do 436 // TODO(rtenneti): since this is a class, we should probably do
474 // getters/setters here. 437 // getters/setters here.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 void SelectNewPrimaryConfig(QuicWallTime now) const; 508 void SelectNewPrimaryConfig(QuicWallTime now) const;
546 509
547 // EvaluateClientHello checks |client_hello| for gross errors and determines 510 // EvaluateClientHello checks |client_hello| for gross errors and determines
548 // whether it can be shown to be fresh (i.e. not a replay). The results are 511 // whether it can be shown to be fresh (i.e. not a replay). The results are
549 // written to |info|. 512 // written to |info|.
550 void EvaluateClientHello( 513 void EvaluateClientHello(
551 const IPAddress& server_ip, 514 const IPAddress& server_ip,
552 QuicVersion version, 515 QuicVersion version,
553 scoped_refptr<Config> requested_config, 516 scoped_refptr<Config> requested_config,
554 scoped_refptr<Config> primary_config, 517 scoped_refptr<Config> primary_config,
555 scoped_refptr<QuicCryptoProof> crypto_proof, 518 scoped_refptr<QuicSignedServerConfig> crypto_proof,
556 scoped_refptr<ValidateClientHelloResultCallback::Result> 519 scoped_refptr<ValidateClientHelloResultCallback::Result>
557 client_hello_state, 520 client_hello_state,
558 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; 521 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const;
559 522
560 // Callback class for bridging between EvaluateClientHello and 523 // Callback class for bridging between EvaluateClientHello and
561 // EvaluateClientHelloAfterGetProof. 524 // EvaluateClientHelloAfterGetProof.
562 class EvaluateClientHelloCallback; 525 class EvaluateClientHelloCallback;
563 friend class EvaluateClientHelloCallback; 526 friend class EvaluateClientHelloCallback;
564 527
565 // Continuation of EvaluateClientHello after the call to 528 // Continuation of EvaluateClientHello after the call to
566 // ProofSource::GetProof. |found_error| indicates whether an error was 529 // ProofSource::GetProof. |found_error| indicates whether an error was
567 // detected in EvaluateClientHello, and |get_proof_failed| indicates whether 530 // detected in EvaluateClientHello, and |get_proof_failed| indicates whether
568 // GetProof failed. If GetProof was not run, then |get_proof_failed| will be 531 // GetProof failed. If GetProof was not run, then |get_proof_failed| will be
569 // set to false. 532 // set to false.
570 void EvaluateClientHelloAfterGetProof( 533 void EvaluateClientHelloAfterGetProof(
571 bool found_error, 534 bool found_error,
572 const IPAddress& server_ip, 535 const IPAddress& server_ip,
573 QuicVersion version, 536 QuicVersion version,
574 scoped_refptr<Config> requested_config, 537 scoped_refptr<Config> requested_config,
575 scoped_refptr<Config> primary_config, 538 scoped_refptr<Config> primary_config,
576 scoped_refptr<QuicCryptoProof> crypto_proof, 539 scoped_refptr<QuicSignedServerConfig> crypto_proof,
577 std::unique_ptr<ProofSource::Details> proof_source_details, 540 std::unique_ptr<ProofSource::Details> proof_source_details,
578 bool get_proof_failed, 541 bool get_proof_failed,
579 scoped_refptr<ValidateClientHelloResultCallback::Result> 542 scoped_refptr<ValidateClientHelloResultCallback::Result>
580 client_hello_state, 543 client_hello_state,
581 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; 544 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const;
582 545
583 // Callback class for bridging between ProcessClientHello and 546 // Callback class for bridging between ProcessClientHello and
584 // ProcessClientHelloAfterGetProof. 547 // ProcessClientHelloAfterGetProof.
585 class ProcessClientHelloCallback; 548 class ProcessClientHelloCallback;
586 friend class ProcessClientHelloCallback; 549 friend class ProcessClientHelloCallback;
587 550
588 // Portion of ProcessClientHello which executes after GetProof. 551 // Portion of ProcessClientHello which executes after GetProof.
589 void ProcessClientHelloAfterGetProof( 552 void ProcessClientHelloAfterGetProof(
590 bool found_error, 553 bool found_error,
591 std::unique_ptr<ProofSource::Details> proof_source_details, 554 std::unique_ptr<ProofSource::Details> proof_source_details,
592 const ValidateClientHelloResultCallback::Result& validate_chlo_result, 555 const ValidateClientHelloResultCallback::Result& validate_chlo_result,
593 bool reject_only, 556 bool reject_only,
594 QuicConnectionId connection_id, 557 QuicConnectionId connection_id,
595 const IPEndPoint& client_address, 558 const IPEndPoint& client_address,
596 QuicVersion version, 559 QuicVersion version,
597 const QuicVersionVector& supported_versions, 560 const QuicVersionVector& supported_versions,
598 bool use_stateless_rejects, 561 bool use_stateless_rejects,
599 QuicConnectionId server_designated_connection_id, 562 QuicConnectionId server_designated_connection_id,
600 const QuicClock* clock, 563 const QuicClock* clock,
601 QuicRandom* rand, 564 QuicRandom* rand,
602 QuicCompressedCertsCache* compressed_certs_cache, 565 QuicCompressedCertsCache* compressed_certs_cache,
603 scoped_refptr<QuicCryptoNegotiatedParameters> params, 566 scoped_refptr<QuicCryptoNegotiatedParameters> params,
604 scoped_refptr<QuicCryptoProof> crypto_proof, 567 scoped_refptr<QuicSignedServerConfig> crypto_proof,
605 QuicByteCount total_framing_overhead, 568 QuicByteCount total_framing_overhead,
606 QuicByteCount chlo_packet_size, 569 QuicByteCount chlo_packet_size,
607 const scoped_refptr<Config>& requested_config, 570 const scoped_refptr<Config>& requested_config,
608 const scoped_refptr<Config>& primary_config, 571 const scoped_refptr<Config>& primary_config,
609 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const; 572 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const;
610 573
611 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|. 574 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|.
612 void BuildRejection(QuicVersion version, 575 void BuildRejection(QuicVersion version,
613 QuicWallTime now, 576 QuicWallTime now,
614 const Config& config, 577 const Config& config,
615 const CryptoHandshakeMessage& client_hello, 578 const CryptoHandshakeMessage& client_hello,
616 const ClientHelloInfo& info, 579 const ClientHelloInfo& info,
617 const CachedNetworkParameters& cached_network_params, 580 const CachedNetworkParameters& cached_network_params,
618 bool use_stateless_rejects, 581 bool use_stateless_rejects,
619 QuicConnectionId server_designated_connection_id, 582 QuicConnectionId server_designated_connection_id,
620 QuicRandom* rand, 583 QuicRandom* rand,
621 QuicCompressedCertsCache* compressed_certs_cache, 584 QuicCompressedCertsCache* compressed_certs_cache,
622 scoped_refptr<QuicCryptoNegotiatedParameters> params, 585 scoped_refptr<QuicCryptoNegotiatedParameters> params,
623 const QuicCryptoProof& crypto_proof, 586 const QuicSignedServerConfig& crypto_proof,
624 QuicByteCount total_framing_overhead, 587 QuicByteCount total_framing_overhead,
625 QuicByteCount chlo_packet_size, 588 QuicByteCount chlo_packet_size,
626 CryptoHandshakeMessage* out) const; 589 CryptoHandshakeMessage* out) const;
627 590
628 // CompressChain compresses the certificates in |chain->certs| and returns a 591 // CompressChain compresses the certificates in |chain->certs| and returns a
629 // compressed representation. |common_sets| contains the common certificate 592 // compressed representation. |common_sets| contains the common certificate
630 // sets known locally and |client_common_set_hashes| contains the hashes of 593 // sets known locally and |client_common_set_hashes| contains the hashes of
631 // the common sets known to the peer. |client_cached_cert_hashes| contains 594 // the common sets known to the peer. |client_cached_cert_hashes| contains
632 // 64-bit, FNV-1a hashes of certificates that the peer already possesses. 595 // 64-bit, FNV-1a hashes of certificates that the peer already possesses.
633 static std::string CompressChain( 596 static std::string CompressChain(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 // Returns HANDSHAKE_OK if the source address token in |token| is a timely 648 // Returns HANDSHAKE_OK if the source address token in |token| is a timely
686 // token given that the current time is |now|. Otherwise it returns the 649 // token given that the current time is |now|. Otherwise it returns the
687 // reason for failure. 650 // reason for failure.
688 HandshakeFailureReason ValidateSourceAddressTokenTimestamp( 651 HandshakeFailureReason ValidateSourceAddressTokenTimestamp(
689 const SourceAddressToken& token, 652 const SourceAddressToken& token,
690 QuicWallTime now) const; 653 QuicWallTime now) const;
691 654
692 // NewServerNonce generates and encrypts a random nonce. 655 // NewServerNonce generates and encrypts a random nonce.
693 std::string NewServerNonce(QuicRandom* rand, QuicWallTime now) const; 656 std::string NewServerNonce(QuicRandom* rand, QuicWallTime now) const;
694 657
695 // ValidateServerNonce decrypts |token| and verifies that it hasn't been
696 // previously used and is recent enough that it is plausible that it was part
697 // of a very recently provided rejection ("recent" will be on the order of
698 // 10-30 seconds). If so, it records that it has been used and returns
699 // HANDSHAKE_OK. Otherwise it returns the reason for failure.
700 HandshakeFailureReason ValidateServerNonce(
701 base::StringPiece echoed_server_nonce,
702 QuicWallTime now) const;
703
704 // ValidateExpectedLeafCertificate checks the |client_hello| to see if it has 658 // ValidateExpectedLeafCertificate checks the |client_hello| to see if it has
705 // an XLCT tag, and if so, verifies that its value matches the hash of the 659 // an XLCT tag, and if so, verifies that its value matches the hash of the
706 // server's leaf certificate. The certs field of |crypto_proof| is used to 660 // server's leaf certificate. The certs field of |crypto_proof| is used to
707 // compare against the XLCT value. This method returns true if the XLCT tag 661 // compare against the XLCT value. This method returns true if the XLCT tag
708 // is not present, or if the XLCT tag is present and valid. It returns false 662 // is not present, or if the XLCT tag is present and valid. It returns false
709 // otherwise. 663 // otherwise.
710 bool ValidateExpectedLeafCertificate( 664 bool ValidateExpectedLeafCertificate(
711 const CryptoHandshakeMessage& client_hello, 665 const CryptoHandshakeMessage& client_hello,
712 const QuicCryptoProof& crypto_proof) const; 666 const QuicSignedServerConfig& crypto_proof) const;
713 667
714 // Returns true if the PDMD field from the client hello demands an X509 668 // Returns true if the PDMD field from the client hello demands an X509
715 // certificate. 669 // certificate.
716 bool ClientDemandsX509Proof(const CryptoHandshakeMessage& client_hello) const; 670 bool ClientDemandsX509Proof(const CryptoHandshakeMessage& client_hello) const;
717 671
718 // Callback to receive the results of ProofSource::GetProof. Note: this 672 // Callback to receive the results of ProofSource::GetProof. Note: this
719 // callback has no cancellation support, since the lifetime of the ProofSource 673 // callback has no cancellation support, since the lifetime of the ProofSource
720 // is controlled by this object via unique ownership. If that ownership 674 // is controlled by this object via unique ownership. If that ownership
721 // stricture changes, this decision may need to be revisited. 675 // stricture changes, this decision may need to be revisited.
722 class BuildServerConfigUpdateMessageProofSourceCallback 676 class BuildServerConfigUpdateMessageProofSourceCallback
723 : public ProofSource::Callback { 677 : public ProofSource::Callback {
724 public: 678 public:
725 BuildServerConfigUpdateMessageProofSourceCallback( 679 BuildServerConfigUpdateMessageProofSourceCallback(
726 const BuildServerConfigUpdateMessageProofSourceCallback&) = delete; 680 const BuildServerConfigUpdateMessageProofSourceCallback&) = delete;
727 ~BuildServerConfigUpdateMessageProofSourceCallback() override; 681 ~BuildServerConfigUpdateMessageProofSourceCallback() override;
728 void operator=(const BuildServerConfigUpdateMessageProofSourceCallback&) = 682 void operator=(const BuildServerConfigUpdateMessageProofSourceCallback&) =
729 delete; 683 delete;
730 BuildServerConfigUpdateMessageProofSourceCallback( 684 BuildServerConfigUpdateMessageProofSourceCallback(
731 const QuicCryptoServerConfig* config, 685 const QuicCryptoServerConfig* config,
732 QuicVersion version, 686 QuicVersion version,
733 QuicCompressedCertsCache* compressed_certs_cache, 687 QuicCompressedCertsCache* compressed_certs_cache,
734 const CommonCertSets* common_cert_sets, 688 const CommonCertSets* common_cert_sets,
735 const QuicCryptoNegotiatedParameters& params, 689 const QuicCryptoNegotiatedParameters& params,
736 CryptoHandshakeMessage message, 690 CryptoHandshakeMessage message,
737 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb); 691 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb);
738 692
739 void Run(bool ok, 693 void Run(bool ok,
740 const scoped_refptr<ProofSource::Chain>& chain, 694 const scoped_refptr<ProofSource::Chain>& chain,
741 const std::string& signature, 695 const QuicCryptoProof& proof,
742 const std::string& leaf_cert_sct,
743 std::unique_ptr<ProofSource::Details> details) override; 696 std::unique_ptr<ProofSource::Details> details) override;
744 697
745 private: 698 private:
746 const QuicCryptoServerConfig* config_; 699 const QuicCryptoServerConfig* config_;
747 const QuicVersion version_; 700 const QuicVersion version_;
748 QuicCompressedCertsCache* compressed_certs_cache_; 701 QuicCompressedCertsCache* compressed_certs_cache_;
749 const CommonCertSets* common_cert_sets_; 702 const CommonCertSets* common_cert_sets_;
750 const std::string client_common_set_hashes_; 703 const std::string client_common_set_hashes_;
751 const std::string client_cached_cert_hashes_; 704 const std::string client_cached_cert_hashes_;
752 const bool sct_supported_by_client_; 705 const bool sct_supported_by_client_;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 ConfigMap configs_; 744 ConfigMap configs_;
792 // primary_config_ points to a Config (which is also in |configs_|) which is 745 // primary_config_ points to a Config (which is also in |configs_|) which is
793 // the primary config - i.e. the one that we'll give out to new clients. 746 // the primary config - i.e. the one that we'll give out to new clients.
794 mutable scoped_refptr<Config> primary_config_; 747 mutable scoped_refptr<Config> primary_config_;
795 // next_config_promotion_time_ contains the nearest, future time when an 748 // next_config_promotion_time_ contains the nearest, future time when an
796 // active config will be promoted to primary. 749 // active config will be promoted to primary.
797 mutable QuicWallTime next_config_promotion_time_; 750 mutable QuicWallTime next_config_promotion_time_;
798 // Callback to invoke when the primary config changes. 751 // Callback to invoke when the primary config changes.
799 std::unique_ptr<PrimaryConfigChangedCallback> primary_config_changed_cb_; 752 std::unique_ptr<PrimaryConfigChangedCallback> primary_config_changed_cb_;
800 753
801 // Protects access to the pointer held by strike_register_client_.
802 mutable base::Lock strike_register_client_lock_;
803 // strike_register_ contains a data structure that keeps track of previously
804 // observed client nonces in order to prevent replay attacks.
805 mutable std::unique_ptr<StrikeRegisterClient> strike_register_client_;
806
807 // Used to protect the source-address tokens that are given to clients. 754 // Used to protect the source-address tokens that are given to clients.
808 CryptoSecretBoxer source_address_token_boxer_; 755 CryptoSecretBoxer source_address_token_boxer_;
809 756
810 // server_nonce_boxer_ is used to encrypt and validate suggested server 757 // server_nonce_boxer_ is used to encrypt and validate suggested server
811 // nonces. 758 // nonces.
812 CryptoSecretBoxer server_nonce_boxer_; 759 CryptoSecretBoxer server_nonce_boxer_;
813 760
814 // server_nonce_orbit_ contains the random, per-server orbit values that this 761 // server_nonce_orbit_ contains the random, per-server orbit values that this
815 // server will use to generate server nonces (the moral equivalent of a SYN 762 // server will use to generate server nonces (the moral equivalent of a SYN
816 // cookies). 763 // cookies).
817 uint8_t server_nonce_orbit_[8]; 764 uint8_t server_nonce_orbit_[8];
818 765
819 mutable base::Lock server_nonce_strike_register_lock_;
820 // server_nonce_strike_register_ contains a data structure that keeps track of
821 // previously observed server nonces from this server, in order to prevent
822 // replay attacks.
823 mutable std::unique_ptr<StrikeRegister> server_nonce_strike_register_;
824
825 // proof_source_ contains an object that can provide certificate chains and 766 // proof_source_ contains an object that can provide certificate chains and
826 // signatures. 767 // signatures.
827 std::unique_ptr<ProofSource> proof_source_; 768 std::unique_ptr<ProofSource> proof_source_;
828 769
829 // ephemeral_key_source_ contains an object that caches ephemeral keys for a 770 // ephemeral_key_source_ contains an object that caches ephemeral keys for a
830 // short period of time. 771 // short period of time.
831 std::unique_ptr<EphemeralKeySource> ephemeral_key_source_; 772 std::unique_ptr<EphemeralKeySource> ephemeral_key_source_;
832 773
833 // These fields store configuration values. See the comments for their 774 // These fields store configuration values. See the comments for their
834 // respective setter functions. 775 // respective setter functions.
835 bool strike_register_no_startup_period_;
836 uint32_t strike_register_max_entries_;
837 uint32_t strike_register_window_secs_;
838 uint32_t source_address_token_future_secs_; 776 uint32_t source_address_token_future_secs_;
839 uint32_t source_address_token_lifetime_secs_; 777 uint32_t source_address_token_lifetime_secs_;
840 uint32_t server_nonce_strike_register_max_entries_;
841 uint32_t server_nonce_strike_register_window_secs_;
842 778
843 // Enable serving SCT or not. 779 // Enable serving SCT or not.
844 bool enable_serving_sct_; 780 bool enable_serving_sct_;
845 781
846 // Does not own this observer. 782 // Does not own this observer.
847 RejectionObserver* rejection_observer_; 783 RejectionObserver* rejection_observer_;
848 784
849 DISALLOW_COPY_AND_ASSIGN(QuicCryptoServerConfig); 785 DISALLOW_COPY_AND_ASSIGN(QuicCryptoServerConfig);
850 }; 786 };
851 787
852 struct NET_EXPORT_PRIVATE QuicCryptoProof 788 struct NET_EXPORT_PRIVATE QuicSignedServerConfig
853 : public base::RefCounted<QuicCryptoProof> { 789 : public base::RefCounted<QuicSignedServerConfig> {
854 QuicCryptoProof(); 790 QuicSignedServerConfig();
855 791
792 // TODO(eranm): Have a QuicCryptoProof field instead of signature, cert_sct.
856 std::string signature; 793 std::string signature;
857 scoped_refptr<ProofSource::Chain> chain; 794 scoped_refptr<ProofSource::Chain> chain;
858 std::string cert_sct; 795 std::string cert_sct;
859 // The server config that is used for this proof (and the rest of the 796 // The server config that is used for this proof (and the rest of the
860 // request). 797 // request).
861 scoped_refptr<QuicCryptoServerConfig::Config> config; 798 scoped_refptr<QuicCryptoServerConfig::Config> config;
862 std::string primary_scid; 799 std::string primary_scid;
800 // Indication whether the Expect-CT header should be sent on the session
801 // this proof relates to (for background, see
802 // https://www.ietf.org/id/draft-stark-expect-ct-00.txt).
803 // NOTE: This field is intentionally independent from the |cert_sct| one
804 // and can be true even if |cert_sct| is empty.
805 // The goal of the Expect-CT header is uncover cases where valid SCTs are
806 // expected to be served, but aren't.
807 bool send_expect_ct_header;
863 808
864 private: 809 private:
865 friend class base::RefCounted<QuicCryptoProof>; 810 friend class base::RefCounted<QuicSignedServerConfig>;
866 virtual ~QuicCryptoProof(); 811 virtual ~QuicSignedServerConfig();
867 }; 812 };
868 813
869 } // namespace net 814 } // namespace net
870 815
871 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ 816 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_
OLDNEW
« no previous file with comments | « net/quic/core/crypto/quic_crypto_proof.cc ('k') | net/quic/core/crypto/quic_crypto_server_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698