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

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

Issue 2511643002: Refactoring output of ProofSource::GetProof (no functional changes). (Closed)
Patch Set: Refactoring output of ProofSource::GetProof (no functional changes). 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 25 matching lines...) Expand all
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 class StrikeRegister;
45 class StrikeRegisterClient; 45 class StrikeRegisterClient;
46 struct QuicCryptoProof; 46 struct QuicSignedServerConfig;
47 47
48 // ClientHelloInfo contains information about a client hello message that is 48 // ClientHelloInfo contains information about a client hello message that is
49 // only kept for as long as it's being processed. 49 // only kept for as long as it's being processed.
50 struct ClientHelloInfo { 50 struct ClientHelloInfo {
51 ClientHelloInfo(const IPAddress& in_client_ip, QuicWallTime in_now); 51 ClientHelloInfo(const IPAddress& in_client_ip, QuicWallTime in_now);
52 ClientHelloInfo(const ClientHelloInfo& other); 52 ClientHelloInfo(const ClientHelloInfo& other);
53 ~ClientHelloInfo(); 53 ~ClientHelloInfo();
54 54
55 // Inputs to EvaluateClientHello. 55 // Inputs to EvaluateClientHello.
56 const IPAddress client_ip; 56 const IPAddress client_ip;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // ValidatedClientHelloMsg token that holds information about 274 // ValidatedClientHelloMsg token that holds information about
275 // the client hello. The callback will always be called exactly 275 // the client hello. The callback will always be called exactly
276 // once, either under the current call stack, or after the 276 // once, either under the current call stack, or after the
277 // completion of an asynchronous operation. 277 // completion of an asynchronous operation.
278 void ValidateClientHello( 278 void ValidateClientHello(
279 const CryptoHandshakeMessage& client_hello, 279 const CryptoHandshakeMessage& client_hello,
280 const IPAddress& client_ip, 280 const IPAddress& client_ip,
281 const IPAddress& server_ip, 281 const IPAddress& server_ip,
282 QuicVersion version, 282 QuicVersion version,
283 const QuicClock* clock, 283 const QuicClock* clock,
284 scoped_refptr<QuicCryptoProof> crypto_proof, 284 scoped_refptr<QuicSignedServerConfig> crypto_proof,
285 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; 285 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const;
286 286
287 // ProcessClientHello processes |client_hello| and decides whether to accept 287 // ProcessClientHello processes |client_hello| and decides whether to accept
288 // or reject the connection. If the connection is to be accepted, |done_cb| is 288 // 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 289 // 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. 290 // |done_cb| is called with a REJ or SREJ message and QUIC_NO_ERROR.
291 // 291 //
292 // validate_chlo_result: Output from the asynchronous call to 292 // validate_chlo_result: Output from the asynchronous call to
293 // ValidateClientHello. Contains the client hello message and 293 // ValidateClientHello. Contains the client hello message and
294 // information about it. 294 // information about it.
(...skipping 26 matching lines...) Expand all
321 const IPAddress& server_ip, 321 const IPAddress& server_ip,
322 const IPEndPoint& client_address, 322 const IPEndPoint& client_address,
323 QuicVersion version, 323 QuicVersion version,
324 const QuicVersionVector& supported_versions, 324 const QuicVersionVector& supported_versions,
325 bool use_stateless_rejects, 325 bool use_stateless_rejects,
326 QuicConnectionId server_designated_connection_id, 326 QuicConnectionId server_designated_connection_id,
327 const QuicClock* clock, 327 const QuicClock* clock,
328 QuicRandom* rand, 328 QuicRandom* rand,
329 QuicCompressedCertsCache* compressed_certs_cache, 329 QuicCompressedCertsCache* compressed_certs_cache,
330 scoped_refptr<QuicCryptoNegotiatedParameters> params, 330 scoped_refptr<QuicCryptoNegotiatedParameters> params,
331 scoped_refptr<QuicCryptoProof> crypto_proof, 331 scoped_refptr<QuicSignedServerConfig> crypto_proof,
332 QuicByteCount total_framing_overhead, 332 QuicByteCount total_framing_overhead,
333 QuicByteCount chlo_packet_size, 333 QuicByteCount chlo_packet_size,
334 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const; 334 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const;
335 335
336 // BuildServerConfigUpdateMessage sets |out| to be a SCUP message containing 336 // BuildServerConfigUpdateMessage sets |out| to be a SCUP message containing
337 // the current primary config, an up to date source-address token, and cert 337 // 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 338 // chain and proof in the case of secure QUIC. Returns true if successfully
339 // filled |out|. 339 // filled |out|.
340 // 340 //
341 // |cached_network_params| is optional, and can be nullptr. 341 // |cached_network_params| is optional, and can be nullptr.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 int NumberOfConfigs() const; 454 int NumberOfConfigs() const;
455 455
456 // Callers retain the ownership of |rejection_observer| which must outlive the 456 // Callers retain the ownership of |rejection_observer| which must outlive the
457 // config. 457 // config.
458 void set_rejection_observer(RejectionObserver* rejection_observer) { 458 void set_rejection_observer(RejectionObserver* rejection_observer) {
459 rejection_observer_ = rejection_observer; 459 rejection_observer_ = rejection_observer;
460 } 460 }
461 461
462 private: 462 private:
463 friend class test::QuicCryptoServerConfigPeer; 463 friend class test::QuicCryptoServerConfigPeer;
464 friend struct QuicCryptoProof; 464 friend struct QuicSignedServerConfig;
465 465
466 // Config represents a server config: a collection of preferences and 466 // Config represents a server config: a collection of preferences and
467 // Diffie-Hellman public values. 467 // Diffie-Hellman public values.
468 class NET_EXPORT_PRIVATE Config : public QuicCryptoConfig, 468 class NET_EXPORT_PRIVATE Config : public QuicCryptoConfig,
469 public base::RefCounted<Config> { 469 public base::RefCounted<Config> {
470 public: 470 public:
471 Config(); 471 Config();
472 472
473 // TODO(rtenneti): since this is a class, we should probably do 473 // TODO(rtenneti): since this is a class, we should probably do
474 // getters/setters here. 474 // getters/setters here.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 void SelectNewPrimaryConfig(QuicWallTime now) const; 545 void SelectNewPrimaryConfig(QuicWallTime now) const;
546 546
547 // EvaluateClientHello checks |client_hello| for gross errors and determines 547 // 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 548 // whether it can be shown to be fresh (i.e. not a replay). The results are
549 // written to |info|. 549 // written to |info|.
550 void EvaluateClientHello( 550 void EvaluateClientHello(
551 const IPAddress& server_ip, 551 const IPAddress& server_ip,
552 QuicVersion version, 552 QuicVersion version,
553 scoped_refptr<Config> requested_config, 553 scoped_refptr<Config> requested_config,
554 scoped_refptr<Config> primary_config, 554 scoped_refptr<Config> primary_config,
555 scoped_refptr<QuicCryptoProof> crypto_proof, 555 scoped_refptr<QuicSignedServerConfig> crypto_proof,
556 scoped_refptr<ValidateClientHelloResultCallback::Result> 556 scoped_refptr<ValidateClientHelloResultCallback::Result>
557 client_hello_state, 557 client_hello_state,
558 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; 558 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const;
559 559
560 // Callback class for bridging between EvaluateClientHello and 560 // Callback class for bridging between EvaluateClientHello and
561 // EvaluateClientHelloAfterGetProof. 561 // EvaluateClientHelloAfterGetProof.
562 class EvaluateClientHelloCallback; 562 class EvaluateClientHelloCallback;
563 friend class EvaluateClientHelloCallback; 563 friend class EvaluateClientHelloCallback;
564 564
565 // Continuation of EvaluateClientHello after the call to 565 // Continuation of EvaluateClientHello after the call to
566 // ProofSource::GetProof. |found_error| indicates whether an error was 566 // ProofSource::GetProof. |found_error| indicates whether an error was
567 // detected in EvaluateClientHello, and |get_proof_failed| indicates whether 567 // detected in EvaluateClientHello, and |get_proof_failed| indicates whether
568 // GetProof failed. If GetProof was not run, then |get_proof_failed| will be 568 // GetProof failed. If GetProof was not run, then |get_proof_failed| will be
569 // set to false. 569 // set to false.
570 void EvaluateClientHelloAfterGetProof( 570 void EvaluateClientHelloAfterGetProof(
571 bool found_error, 571 bool found_error,
572 const IPAddress& server_ip, 572 const IPAddress& server_ip,
573 QuicVersion version, 573 QuicVersion version,
574 scoped_refptr<Config> requested_config, 574 scoped_refptr<Config> requested_config,
575 scoped_refptr<Config> primary_config, 575 scoped_refptr<Config> primary_config,
576 scoped_refptr<QuicCryptoProof> crypto_proof, 576 scoped_refptr<QuicSignedServerConfig> crypto_proof,
577 std::unique_ptr<ProofSource::Details> proof_source_details, 577 std::unique_ptr<ProofSource::Details> proof_source_details,
578 bool get_proof_failed, 578 bool get_proof_failed,
579 scoped_refptr<ValidateClientHelloResultCallback::Result> 579 scoped_refptr<ValidateClientHelloResultCallback::Result>
580 client_hello_state, 580 client_hello_state,
581 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; 581 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const;
582 582
583 // Callback class for bridging between ProcessClientHello and 583 // Callback class for bridging between ProcessClientHello and
584 // ProcessClientHelloAfterGetProof. 584 // ProcessClientHelloAfterGetProof.
585 class ProcessClientHelloCallback; 585 class ProcessClientHelloCallback;
586 friend class ProcessClientHelloCallback; 586 friend class ProcessClientHelloCallback;
587 587
588 // Portion of ProcessClientHello which executes after GetProof. 588 // Portion of ProcessClientHello which executes after GetProof.
589 void ProcessClientHelloAfterGetProof( 589 void ProcessClientHelloAfterGetProof(
590 bool found_error, 590 bool found_error,
591 std::unique_ptr<ProofSource::Details> proof_source_details, 591 std::unique_ptr<ProofSource::Details> proof_source_details,
592 const ValidateClientHelloResultCallback::Result& validate_chlo_result, 592 const ValidateClientHelloResultCallback::Result& validate_chlo_result,
593 bool reject_only, 593 bool reject_only,
594 QuicConnectionId connection_id, 594 QuicConnectionId connection_id,
595 const IPEndPoint& client_address, 595 const IPEndPoint& client_address,
596 QuicVersion version, 596 QuicVersion version,
597 const QuicVersionVector& supported_versions, 597 const QuicVersionVector& supported_versions,
598 bool use_stateless_rejects, 598 bool use_stateless_rejects,
599 QuicConnectionId server_designated_connection_id, 599 QuicConnectionId server_designated_connection_id,
600 const QuicClock* clock, 600 const QuicClock* clock,
601 QuicRandom* rand, 601 QuicRandom* rand,
602 QuicCompressedCertsCache* compressed_certs_cache, 602 QuicCompressedCertsCache* compressed_certs_cache,
603 scoped_refptr<QuicCryptoNegotiatedParameters> params, 603 scoped_refptr<QuicCryptoNegotiatedParameters> params,
604 scoped_refptr<QuicCryptoProof> crypto_proof, 604 scoped_refptr<QuicSignedServerConfig> crypto_proof,
605 QuicByteCount total_framing_overhead, 605 QuicByteCount total_framing_overhead,
606 QuicByteCount chlo_packet_size, 606 QuicByteCount chlo_packet_size,
607 const scoped_refptr<Config>& requested_config, 607 const scoped_refptr<Config>& requested_config,
608 const scoped_refptr<Config>& primary_config, 608 const scoped_refptr<Config>& primary_config,
609 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const; 609 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const;
610 610
611 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|. 611 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|.
612 void BuildRejection(QuicVersion version, 612 void BuildRejection(QuicVersion version,
613 QuicWallTime now, 613 QuicWallTime now,
614 const Config& config, 614 const Config& config,
615 const CryptoHandshakeMessage& client_hello, 615 const CryptoHandshakeMessage& client_hello,
616 const ClientHelloInfo& info, 616 const ClientHelloInfo& info,
617 const CachedNetworkParameters& cached_network_params, 617 const CachedNetworkParameters& cached_network_params,
618 bool use_stateless_rejects, 618 bool use_stateless_rejects,
619 QuicConnectionId server_designated_connection_id, 619 QuicConnectionId server_designated_connection_id,
620 QuicRandom* rand, 620 QuicRandom* rand,
621 QuicCompressedCertsCache* compressed_certs_cache, 621 QuicCompressedCertsCache* compressed_certs_cache,
622 scoped_refptr<QuicCryptoNegotiatedParameters> params, 622 scoped_refptr<QuicCryptoNegotiatedParameters> params,
623 const QuicCryptoProof& crypto_proof, 623 const QuicSignedServerConfig& crypto_proof,
624 QuicByteCount total_framing_overhead, 624 QuicByteCount total_framing_overhead,
625 QuicByteCount chlo_packet_size, 625 QuicByteCount chlo_packet_size,
626 CryptoHandshakeMessage* out) const; 626 CryptoHandshakeMessage* out) const;
627 627
628 // CompressChain compresses the certificates in |chain->certs| and returns a 628 // CompressChain compresses the certificates in |chain->certs| and returns a
629 // compressed representation. |common_sets| contains the common certificate 629 // compressed representation. |common_sets| contains the common certificate
630 // sets known locally and |client_common_set_hashes| contains the hashes of 630 // 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 631 // 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. 632 // 64-bit, FNV-1a hashes of certificates that the peer already possesses.
633 static std::string CompressChain( 633 static std::string CompressChain(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 QuicWallTime now) const; 702 QuicWallTime now) const;
703 703
704 // ValidateExpectedLeafCertificate checks the |client_hello| to see if it has 704 // 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 705 // 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 706 // 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 707 // 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 708 // is not present, or if the XLCT tag is present and valid. It returns false
709 // otherwise. 709 // otherwise.
710 bool ValidateExpectedLeafCertificate( 710 bool ValidateExpectedLeafCertificate(
711 const CryptoHandshakeMessage& client_hello, 711 const CryptoHandshakeMessage& client_hello,
712 const QuicCryptoProof& crypto_proof) const; 712 const QuicSignedServerConfig& crypto_proof) const;
713 713
714 // Returns true if the PDMD field from the client hello demands an X509 714 // Returns true if the PDMD field from the client hello demands an X509
715 // certificate. 715 // certificate.
716 bool ClientDemandsX509Proof(const CryptoHandshakeMessage& client_hello) const; 716 bool ClientDemandsX509Proof(const CryptoHandshakeMessage& client_hello) const;
717 717
718 // Callback to receive the results of ProofSource::GetProof. Note: this 718 // Callback to receive the results of ProofSource::GetProof. Note: this
719 // callback has no cancellation support, since the lifetime of the ProofSource 719 // callback has no cancellation support, since the lifetime of the ProofSource
720 // is controlled by this object via unique ownership. If that ownership 720 // is controlled by this object via unique ownership. If that ownership
721 // stricture changes, this decision may need to be revisited. 721 // stricture changes, this decision may need to be revisited.
722 class BuildServerConfigUpdateMessageProofSourceCallback 722 class BuildServerConfigUpdateMessageProofSourceCallback
723 : public ProofSource::Callback { 723 : public ProofSource::Callback {
724 public: 724 public:
725 BuildServerConfigUpdateMessageProofSourceCallback( 725 BuildServerConfigUpdateMessageProofSourceCallback(
726 const BuildServerConfigUpdateMessageProofSourceCallback&) = delete; 726 const BuildServerConfigUpdateMessageProofSourceCallback&) = delete;
727 ~BuildServerConfigUpdateMessageProofSourceCallback() override; 727 ~BuildServerConfigUpdateMessageProofSourceCallback() override;
728 void operator=(const BuildServerConfigUpdateMessageProofSourceCallback&) = 728 void operator=(const BuildServerConfigUpdateMessageProofSourceCallback&) =
729 delete; 729 delete;
730 BuildServerConfigUpdateMessageProofSourceCallback( 730 BuildServerConfigUpdateMessageProofSourceCallback(
731 const QuicCryptoServerConfig* config, 731 const QuicCryptoServerConfig* config,
732 QuicVersion version, 732 QuicVersion version,
733 QuicCompressedCertsCache* compressed_certs_cache, 733 QuicCompressedCertsCache* compressed_certs_cache,
734 const CommonCertSets* common_cert_sets, 734 const CommonCertSets* common_cert_sets,
735 const QuicCryptoNegotiatedParameters& params, 735 const QuicCryptoNegotiatedParameters& params,
736 CryptoHandshakeMessage message, 736 CryptoHandshakeMessage message,
737 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb); 737 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb);
738 738
739 void Run(bool ok, 739 void Run(bool ok,
740 const scoped_refptr<ProofSource::Chain>& chain, 740 const scoped_refptr<ProofSource::Chain>& chain,
741 const std::string& signature, 741 const QuicCryptoProof& proof,
742 const std::string& leaf_cert_sct,
743 std::unique_ptr<ProofSource::Details> details) override; 742 std::unique_ptr<ProofSource::Details> details) override;
744 743
745 private: 744 private:
746 const QuicCryptoServerConfig* config_; 745 const QuicCryptoServerConfig* config_;
747 const QuicVersion version_; 746 const QuicVersion version_;
748 QuicCompressedCertsCache* compressed_certs_cache_; 747 QuicCompressedCertsCache* compressed_certs_cache_;
749 const CommonCertSets* common_cert_sets_; 748 const CommonCertSets* common_cert_sets_;
750 const std::string client_common_set_hashes_; 749 const std::string client_common_set_hashes_;
751 const std::string client_cached_cert_hashes_; 750 const std::string client_cached_cert_hashes_;
752 const bool sct_supported_by_client_; 751 const bool sct_supported_by_client_;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 841
843 // Enable serving SCT or not. 842 // Enable serving SCT or not.
844 bool enable_serving_sct_; 843 bool enable_serving_sct_;
845 844
846 // Does not own this observer. 845 // Does not own this observer.
847 RejectionObserver* rejection_observer_; 846 RejectionObserver* rejection_observer_;
848 847
849 DISALLOW_COPY_AND_ASSIGN(QuicCryptoServerConfig); 848 DISALLOW_COPY_AND_ASSIGN(QuicCryptoServerConfig);
850 }; 849 };
851 850
852 struct NET_EXPORT_PRIVATE QuicCryptoProof 851 struct NET_EXPORT_PRIVATE QuicSignedServerConfig
853 : public base::RefCounted<QuicCryptoProof> { 852 : public base::RefCounted<QuicSignedServerConfig> {
854 QuicCryptoProof(); 853 QuicSignedServerConfig();
855 854
855 // TODO(eranm): Have a QuicCryptoProof field instead of signature, cert_sct.
856 std::string signature; 856 std::string signature;
857 scoped_refptr<ProofSource::Chain> chain; 857 scoped_refptr<ProofSource::Chain> chain;
858 std::string cert_sct; 858 std::string cert_sct;
859 // The server config that is used for this proof (and the rest of the 859 // The server config that is used for this proof (and the rest of the
860 // request). 860 // request).
861 scoped_refptr<QuicCryptoServerConfig::Config> config; 861 scoped_refptr<QuicCryptoServerConfig::Config> config;
862 std::string primary_scid; 862 std::string primary_scid;
863 863
864 private: 864 private:
865 friend class base::RefCounted<QuicCryptoProof>; 865 friend class base::RefCounted<QuicSignedServerConfig>;
866 virtual ~QuicCryptoProof(); 866 virtual ~QuicSignedServerConfig();
867 }; 867 };
868 868
869 } // namespace net 869 } // namespace net
870 870
871 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ 871 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_
OLDNEW
« no previous file with comments | « net/quic/core/crypto/quic_crypto_proof.h ('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