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

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

Issue 2513113002: Remove strike-register code from QuicCryptoServerConfig (Closed)
Patch Set: 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;
45 class StrikeRegisterClient;
46 struct QuicSignedServerConfig; 44 struct QuicSignedServerConfig;
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.
(...skipping 322 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;
(...skipping 230 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 QuicSignedServerConfig& crypto_proof) const; 666 const QuicSignedServerConfig& crypto_proof) const;
713 667
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 ConfigMap configs_; 744 ConfigMap configs_;
791 // 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
792 // 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.
793 mutable scoped_refptr<Config> primary_config_; 747 mutable scoped_refptr<Config> primary_config_;
794 // next_config_promotion_time_ contains the nearest, future time when an 748 // next_config_promotion_time_ contains the nearest, future time when an
795 // active config will be promoted to primary. 749 // active config will be promoted to primary.
796 mutable QuicWallTime next_config_promotion_time_; 750 mutable QuicWallTime next_config_promotion_time_;
797 // Callback to invoke when the primary config changes. 751 // Callback to invoke when the primary config changes.
798 std::unique_ptr<PrimaryConfigChangedCallback> primary_config_changed_cb_; 752 std::unique_ptr<PrimaryConfigChangedCallback> primary_config_changed_cb_;
799 753
800 // Protects access to the pointer held by strike_register_client_.
801 mutable base::Lock strike_register_client_lock_;
802 // strike_register_ contains a data structure that keeps track of previously
803 // observed client nonces in order to prevent replay attacks.
804 mutable std::unique_ptr<StrikeRegisterClient> strike_register_client_;
805
806 // 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.
807 CryptoSecretBoxer source_address_token_boxer_; 755 CryptoSecretBoxer source_address_token_boxer_;
808 756
809 // server_nonce_boxer_ is used to encrypt and validate suggested server 757 // server_nonce_boxer_ is used to encrypt and validate suggested server
810 // nonces. 758 // nonces.
811 CryptoSecretBoxer server_nonce_boxer_; 759 CryptoSecretBoxer server_nonce_boxer_;
812 760
813 // 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
814 // 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
815 // cookies). 763 // cookies).
816 uint8_t server_nonce_orbit_[8]; 764 uint8_t server_nonce_orbit_[8];
817 765
818 mutable base::Lock server_nonce_strike_register_lock_;
819 // server_nonce_strike_register_ contains a data structure that keeps track of
820 // previously observed server nonces from this server, in order to prevent
821 // replay attacks.
822 mutable std::unique_ptr<StrikeRegister> server_nonce_strike_register_;
823
824 // proof_source_ contains an object that can provide certificate chains and 766 // proof_source_ contains an object that can provide certificate chains and
825 // signatures. 767 // signatures.
826 std::unique_ptr<ProofSource> proof_source_; 768 std::unique_ptr<ProofSource> proof_source_;
827 769
828 // 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
829 // short period of time. 771 // short period of time.
830 std::unique_ptr<EphemeralKeySource> ephemeral_key_source_; 772 std::unique_ptr<EphemeralKeySource> ephemeral_key_source_;
831 773
832 // These fields store configuration values. See the comments for their 774 // These fields store configuration values. See the comments for their
833 // respective setter functions. 775 // respective setter functions.
834 bool strike_register_no_startup_period_;
835 uint32_t strike_register_max_entries_;
836 uint32_t strike_register_window_secs_;
837 uint32_t source_address_token_future_secs_; 776 uint32_t source_address_token_future_secs_;
838 uint32_t source_address_token_lifetime_secs_; 777 uint32_t source_address_token_lifetime_secs_;
839 uint32_t server_nonce_strike_register_max_entries_;
840 uint32_t server_nonce_strike_register_window_secs_;
841 778
842 // Enable serving SCT or not. 779 // Enable serving SCT or not.
843 bool enable_serving_sct_; 780 bool enable_serving_sct_;
844 781
845 // Does not own this observer. 782 // Does not own this observer.
846 RejectionObserver* rejection_observer_; 783 RejectionObserver* rejection_observer_;
847 784
848 DISALLOW_COPY_AND_ASSIGN(QuicCryptoServerConfig); 785 DISALLOW_COPY_AND_ASSIGN(QuicCryptoServerConfig);
849 }; 786 };
850 787
(...skipping 19 matching lines...) Expand all
870 bool send_expect_ct_header; 807 bool send_expect_ct_header;
871 808
872 private: 809 private:
873 friend class base::RefCounted<QuicSignedServerConfig>; 810 friend class base::RefCounted<QuicSignedServerConfig>;
874 virtual ~QuicSignedServerConfig(); 811 virtual ~QuicSignedServerConfig();
875 }; 812 };
876 813
877 } // namespace net 814 } // namespace net
878 815
879 #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/crypto_server_test.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