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

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

Issue 2334363002: Landing Recent QUIC changes until Sat Sep 10 00:32:41 (Closed)
Patch Set: Revase Created 4 years, 3 months 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 QuicCryptoProof;
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(); 53 ~ClientHelloInfo();
53 54
54 // Inputs to EvaluateClientHello. 55 // Inputs to EvaluateClientHello.
55 const IPAddress client_ip; 56 const IPAddress client_ip;
56 const QuicWallTime now; 57 const QuicWallTime now;
57 58
58 // Outputs from EvaluateClientHello. 59 // Outputs from EvaluateClientHello.
59 bool valid_source_address_token; 60 bool valid_source_address_token;
60 base::StringPiece sni; 61 base::StringPiece sni;
61 base::StringPiece client_nonce; 62 base::StringPiece client_nonce;
(...skipping 19 matching lines...) Expand all
81 82
82 private: 83 private:
83 DISALLOW_COPY_AND_ASSIGN(PrimaryConfigChangedCallback); 84 DISALLOW_COPY_AND_ASSIGN(PrimaryConfigChangedCallback);
84 }; 85 };
85 86
86 // Callback used to accept the result of the |client_hello| validation step. 87 // Callback used to accept the result of the |client_hello| validation step.
87 class NET_EXPORT_PRIVATE ValidateClientHelloResultCallback { 88 class NET_EXPORT_PRIVATE ValidateClientHelloResultCallback {
88 public: 89 public:
89 // Opaque token that holds information about the client_hello and 90 // Opaque token that holds information about the client_hello and
90 // its validity. Can be interpreted by calling ProcessClientHello. 91 // its validity. Can be interpreted by calling ProcessClientHello.
91 struct Result { 92 struct NET_EXPORT_PRIVATE Result {
92 Result(const CryptoHandshakeMessage& in_client_hello, 93 Result(const CryptoHandshakeMessage& in_client_hello,
93 IPAddress in_client_ip, 94 IPAddress in_client_ip,
94 QuicWallTime in_now); 95 QuicWallTime in_now);
95 ~Result(); 96 ~Result();
96 97
97 CryptoHandshakeMessage client_hello; 98 CryptoHandshakeMessage client_hello;
98 ClientHelloInfo info; 99 ClientHelloInfo info;
99 QuicErrorCode error_code; 100 QuicErrorCode error_code;
100 std::string error_details; 101 std::string error_details;
101 102
102 // Populated if the CHLO STK contained a CachedNetworkParameters proto. 103 // Populated if the CHLO STK contained a CachedNetworkParameters proto.
103 CachedNetworkParameters cached_network_params; 104 CachedNetworkParameters cached_network_params;
104 }; 105 };
105 106
106 ValidateClientHelloResultCallback(); 107 ValidateClientHelloResultCallback();
107 virtual ~ValidateClientHelloResultCallback(); 108 virtual ~ValidateClientHelloResultCallback();
108 void Run(const Result* result, std::unique_ptr<ProofSource::Details> details); 109 virtual void Run(std::unique_ptr<Result> result,
109 110 std::unique_ptr<ProofSource::Details> details) = 0;
110 protected:
111 virtual void RunImpl(const CryptoHandshakeMessage& client_hello,
112 const Result& result,
113 std::unique_ptr<ProofSource::Details> details) = 0;
114 111
115 private: 112 private:
116 DISALLOW_COPY_AND_ASSIGN(ValidateClientHelloResultCallback); 113 DISALLOW_COPY_AND_ASSIGN(ValidateClientHelloResultCallback);
117 }; 114 };
118 115
119 // Callback used to receive the results of a call to 116 // Callback used to receive the results of a call to
120 // BuildServerConfigUpdateMessage. 117 // BuildServerConfigUpdateMessage.
121 class BuildServerConfigUpdateMessageResultCallback { 118 class BuildServerConfigUpdateMessageResultCallback {
122 public: 119 public:
123 BuildServerConfigUpdateMessageResultCallback() = default; 120 BuildServerConfigUpdateMessageResultCallback() = default;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // certificate selection. 232 // certificate selection.
236 // version: protocol version used for this connection. 233 // version: protocol version used for this connection.
237 // clock: used to validate client nonces and ephemeral keys. 234 // clock: used to validate client nonces and ephemeral keys.
238 // crypto_proof: output structure containing the crypto proof used in reply to 235 // crypto_proof: output structure containing the crypto proof used in reply to
239 // a proof demand. 236 // a proof demand.
240 // done_cb: single-use callback that accepts an opaque 237 // done_cb: single-use callback that accepts an opaque
241 // ValidatedClientHelloMsg token that holds information about 238 // ValidatedClientHelloMsg token that holds information about
242 // the client hello. The callback will always be called exactly 239 // the client hello. The callback will always be called exactly
243 // once, either under the current call stack, or after the 240 // once, either under the current call stack, or after the
244 // completion of an asynchronous operation. 241 // completion of an asynchronous operation.
245 void ValidateClientHello(const CryptoHandshakeMessage& client_hello, 242 void ValidateClientHello(
246 const IPAddress& client_ip, 243 const CryptoHandshakeMessage& client_hello,
247 const IPAddress& server_ip, 244 const IPAddress& client_ip,
248 QuicVersion version, 245 const IPAddress& server_ip,
249 const QuicClock* clock, 246 QuicVersion version,
250 QuicCryptoProof* crypto_proof, 247 const QuicClock* clock,
251 ValidateClientHelloResultCallback* done_cb) const; 248 QuicCryptoProof* crypto_proof,
249 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const;
252 250
253 // ProcessClientHello processes |client_hello| and decides whether to accept 251 // ProcessClientHello processes |client_hello| and decides whether to accept
254 // or reject the connection. If the connection is to be accepted, |out| is 252 // or reject the connection. If the connection is to be accepted, |out| is
255 // set to the contents of the ServerHello, |out_params| is completed and 253 // set to the contents of the ServerHello, |out_params| is completed and
256 // QUIC_NO_ERROR is returned. Otherwise |out| is set to be a REJ or SREJ 254 // QUIC_NO_ERROR is returned. Otherwise |out| is set to be a REJ or SREJ
257 // message and QUIC_NO_ERROR is returned. 255 // message and QUIC_NO_ERROR is returned.
258 // 256 //
259 // validate_chlo_result: Output from the asynchronous call to 257 // validate_chlo_result: Output from the asynchronous call to
260 // ValidateClientHello. Contains the client hello message and 258 // ValidateClientHello. Contains the client hello message and
261 // information about it. 259 // information about it.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 // nonces from. Setting a larger value allows for clients to delay follow-up 410 // nonces from. Setting a larger value allows for clients to delay follow-up
413 // client hellos for longer and still use server nonces as proofs of 411 // client hellos for longer and still use server nonces as proofs of
414 // uniqueness. 412 // uniqueness.
415 void set_server_nonce_strike_register_window_secs(uint32_t window_secs); 413 void set_server_nonce_strike_register_window_secs(uint32_t window_secs);
416 414
417 // set_enable_serving_sct enables or disables serving signed cert timestamp 415 // set_enable_serving_sct enables or disables serving signed cert timestamp
418 // (RFC6962) in server hello. 416 // (RFC6962) in server hello.
419 void set_enable_serving_sct(bool enable_serving_sct); 417 void set_enable_serving_sct(bool enable_serving_sct);
420 418
421 // Set and take ownership of the callback to invoke on primary config changes. 419 // Set and take ownership of the callback to invoke on primary config changes.
422 void AcquirePrimaryConfigChangedCb(PrimaryConfigChangedCallback* cb); 420 void AcquirePrimaryConfigChangedCb(
421 std::unique_ptr<PrimaryConfigChangedCallback> cb);
423 422
424 // Returns the number of configs this object owns. 423 // Returns the number of configs this object owns.
425 int NumberOfConfigs() const; 424 int NumberOfConfigs() const;
426 425
427 private: 426 private:
428 friend class test::QuicCryptoServerConfigPeer; 427 friend class test::QuicCryptoServerConfigPeer;
429 friend struct QuicCryptoProof; 428 friend struct QuicCryptoProof;
430 429
431 // Config represents a server config: a collection of preferences and 430 // Config represents a server config: a collection of preferences and
432 // Diffie-Hellman public values. 431 // Diffie-Hellman public values.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 // EvaluateClientHello checks |client_hello| for gross errors and determines 511 // EvaluateClientHello checks |client_hello| for gross errors and determines
513 // whether it can be shown to be fresh (i.e. not a replay). The results are 512 // whether it can be shown to be fresh (i.e. not a replay). The results are
514 // written to |info|. 513 // written to |info|.
515 void EvaluateClientHello( 514 void EvaluateClientHello(
516 const IPAddress& server_ip, 515 const IPAddress& server_ip,
517 QuicVersion version, 516 QuicVersion version,
518 const uint8_t* primary_orbit, 517 const uint8_t* primary_orbit,
519 scoped_refptr<Config> requested_config, 518 scoped_refptr<Config> requested_config,
520 scoped_refptr<Config> primary_config, 519 scoped_refptr<Config> primary_config,
521 QuicCryptoProof* crypto_proof, 520 QuicCryptoProof* crypto_proof,
522 ValidateClientHelloResultCallback::Result* client_hello_state, 521 std::unique_ptr<ValidateClientHelloResultCallback::Result>
523 ValidateClientHelloResultCallback* done_cb) const; 522 client_hello_state,
523 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const;
524 524
525 // Callback class for bridging between EvaluateClientHello and 525 // Callback class for bridging between EvaluateClientHello and
526 // EvaluateClientHelloAfterGetProof 526 // EvaluateClientHelloAfterGetProof
527 friend class EvaluateClientHelloCallback; 527 friend class EvaluateClientHelloCallback;
528 528
529 // Continuation of EvaluateClientHello after the call to 529 // Continuation of EvaluateClientHello after the call to
530 // ProofSource::GetProof. |found_error| indicates whether an error was 530 // ProofSource::GetProof. |found_error| indicates whether an error was
531 // detected in EvaluateClientHello, and |get_proof_failed| indicates whether 531 // detected in EvaluateClientHello, and |get_proof_failed| indicates whether
532 // GetProof failed. If GetProof was not run, then |get_proof_failed| will be 532 // GetProof failed. If GetProof was not run, then |get_proof_failed| will be
533 // set to false. 533 // set to false.
534 void EvaluateClientHelloAfterGetProof( 534 void EvaluateClientHelloAfterGetProof(
535 bool found_error, 535 bool found_error,
536 const IPAddress& server_ip, 536 const IPAddress& server_ip,
537 QuicVersion version, 537 QuicVersion version,
538 const uint8_t* primary_orbit, 538 const uint8_t* primary_orbit,
539 scoped_refptr<Config> requested_config, 539 scoped_refptr<Config> requested_config,
540 scoped_refptr<Config> primary_config, 540 scoped_refptr<Config> primary_config,
541 QuicCryptoProof* crypto_proof, 541 QuicCryptoProof* crypto_proof,
542 std::unique_ptr<ProofSource::Details> proof_source_details, 542 std::unique_ptr<ProofSource::Details> proof_source_details,
543 bool get_proof_failed, 543 bool get_proof_failed,
544 ValidateClientHelloResultCallback::Result* client_hello_state, 544 std::unique_ptr<ValidateClientHelloResultCallback::Result>
545 ValidateClientHelloResultCallback* done_cb) const; 545 client_hello_state,
546 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const;
546 547
547 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|. 548 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|.
548 void BuildRejection(QuicVersion version, 549 void BuildRejection(QuicVersion version,
549 QuicWallTime now, 550 QuicWallTime now,
550 const Config& config, 551 const Config& config,
551 const CryptoHandshakeMessage& client_hello, 552 const CryptoHandshakeMessage& client_hello,
552 const ClientHelloInfo& info, 553 const ClientHelloInfo& info,
553 const CachedNetworkParameters& cached_network_params, 554 const CachedNetworkParameters& cached_network_params,
554 bool use_stateless_rejects, 555 bool use_stateless_rejects,
555 QuicConnectionId server_designated_connection_id, 556 QuicConnectionId server_designated_connection_id,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 const QuicVersion version_; 683 const QuicVersion version_;
683 QuicCompressedCertsCache* compressed_certs_cache_; 684 QuicCompressedCertsCache* compressed_certs_cache_;
684 const CommonCertSets* common_cert_sets_; 685 const CommonCertSets* common_cert_sets_;
685 const std::string client_common_set_hashes_; 686 const std::string client_common_set_hashes_;
686 const std::string client_cached_cert_hashes_; 687 const std::string client_cached_cert_hashes_;
687 const bool sct_supported_by_client_; 688 const bool sct_supported_by_client_;
688 CryptoHandshakeMessage message_; 689 CryptoHandshakeMessage message_;
689 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb_; 690 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb_;
690 }; 691 };
691 692
692 // Invoked by BuildServerConfigUpdateMessageProofSourceCallback::RunImpl once 693 // Invoked by BuildServerConfigUpdateMessageProofSourceCallback::Run once
693 // the proof has been acquired. Finishes building the server config update 694 // the proof has been acquired. Finishes building the server config update
694 // message and invokes |cb|. 695 // message and invokes |cb|.
695 void FinishBuildServerConfigUpdateMessage( 696 void FinishBuildServerConfigUpdateMessage(
696 QuicVersion version, 697 QuicVersion version,
697 QuicCompressedCertsCache* compressed_certs_cache, 698 QuicCompressedCertsCache* compressed_certs_cache,
698 const CommonCertSets* common_cert_sets, 699 const CommonCertSets* common_cert_sets,
699 const std::string& client_common_set_hashes, 700 const std::string& client_common_set_hashes,
700 const std::string& client_cached_cert_hashes, 701 const std::string& client_cached_cert_hashes,
701 bool sct_supported_by_client, 702 bool sct_supported_by_client,
702 bool ok, 703 bool ok,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 std::string cert_sct; 791 std::string cert_sct;
791 // The server config that is used for this proof (and the rest of the 792 // The server config that is used for this proof (and the rest of the
792 // request). 793 // request).
793 scoped_refptr<QuicCryptoServerConfig::Config> config; 794 scoped_refptr<QuicCryptoServerConfig::Config> config;
794 std::string primary_scid; 795 std::string primary_scid;
795 }; 796 };
796 797
797 } // namespace net 798 } // namespace net
798 799
799 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ 800 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_
OLDNEW
« no previous file with comments | « net/quic/core/crypto/null_decrypter.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