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

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

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

Powered by Google App Engine
This is Rietveld 408576698