fayang | d58736d | 2019-11-27 13:35:31 -0800 | [diff] [blame] | 1 | // Copyright (c) 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef QUICHE_QUIC_CORE_HANDSHAKER_DELEGATE_INTERFACE_H_ |
| 6 | #define QUICHE_QUIC_CORE_HANDSHAKER_DELEGATE_INTERFACE_H_ |
| 7 | |
dschinazi | 2c4d833 | 2020-05-27 17:23:32 -0700 | [diff] [blame] | 8 | #include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" |
fayang | d58736d | 2019-11-27 13:35:31 -0800 | [diff] [blame] | 9 | #include "net/third_party/quiche/src/quic/core/quic_types.h" |
| 10 | |
| 11 | namespace quic { |
| 12 | |
| 13 | class QuicDecrypter; |
| 14 | class QuicEncrypter; |
| 15 | |
| 16 | // Pure virtual class to get notified when particular handshake events occurred. |
| 17 | class QUIC_EXPORT_PRIVATE HandshakerDelegateInterface { |
| 18 | public: |
| 19 | virtual ~HandshakerDelegateInterface() {} |
| 20 | |
fayang | d286652 | 2020-02-12 11:15:27 -0800 | [diff] [blame] | 21 | // Called when new decryption key of |level| is available. Returns true if |
| 22 | // decrypter is set successfully, otherwise, returns false. |
| 23 | virtual bool OnNewDecryptionKeyAvailable( |
fayang | 3f7bcbe | 2020-02-10 11:08:47 -0800 | [diff] [blame] | 24 | EncryptionLevel level, |
| 25 | std::unique_ptr<QuicDecrypter> decrypter, |
| 26 | bool set_alternative_decrypter, |
| 27 | bool latch_once_used) = 0; |
| 28 | |
| 29 | // Called when new encryption key of |level| is available. |
| 30 | virtual void OnNewEncryptionKeyAvailable( |
| 31 | EncryptionLevel level, |
| 32 | std::unique_ptr<QuicEncrypter> encrypter) = 0; |
fayang | d58736d | 2019-11-27 13:35:31 -0800 | [diff] [blame] | 33 | |
fayang | d18bfb9 | 2020-03-19 17:24:21 -0700 | [diff] [blame] | 34 | // Called to set default encryption level to |level|. Only used in QUIC |
| 35 | // crypto. |
fayang | d58736d | 2019-11-27 13:35:31 -0800 | [diff] [blame] | 36 | virtual void SetDefaultEncryptionLevel(EncryptionLevel level) = 0; |
| 37 | |
fayang | d18bfb9 | 2020-03-19 17:24:21 -0700 | [diff] [blame] | 38 | // Called when both 1-RTT read and write keys are available. Only used in TLS |
| 39 | // handshake. |
| 40 | virtual void OnOneRttKeysAvailable() = 0; |
| 41 | |
fayang | d58736d | 2019-11-27 13:35:31 -0800 | [diff] [blame] | 42 | // Called to discard old decryption keys to stop processing packets of |
| 43 | // encryption |level|. |
| 44 | virtual void DiscardOldDecryptionKey(EncryptionLevel level) = 0; |
| 45 | |
| 46 | // Called to discard old encryption keys (and neuter obsolete data). |
| 47 | // TODO(fayang): consider to combine this with DiscardOldDecryptionKey. |
| 48 | virtual void DiscardOldEncryptionKey(EncryptionLevel level) = 0; |
| 49 | |
| 50 | // Called to neuter ENCRYPTION_INITIAL data (without discarding initial keys). |
| 51 | virtual void NeuterUnencryptedData() = 0; |
| 52 | |
fayang | 0106294 | 2020-01-22 07:23:23 -0800 | [diff] [blame] | 53 | // Called to neuter data of HANDSHAKE_DATA packet number space. Only used in |
| 54 | // QUIC crypto. This is called 1) when a client switches to forward secure |
fayang | d58736d | 2019-11-27 13:35:31 -0800 | [diff] [blame] | 55 | // encryption level and 2) a server successfully processes a forward secure |
fayang | 0106294 | 2020-01-22 07:23:23 -0800 | [diff] [blame] | 56 | // packet. |
fayang | d58736d | 2019-11-27 13:35:31 -0800 | [diff] [blame] | 57 | virtual void NeuterHandshakeData() = 0; |
nharper | d25cd65 | 2020-05-20 13:10:26 -0700 | [diff] [blame] | 58 | |
| 59 | // Called when 0-RTT data is rejected by the server. This is only called in |
| 60 | // TLS handshakes and only called on clients. |
| 61 | virtual void OnZeroRttRejected() = 0; |
dschinazi | 2c4d833 | 2020-05-27 17:23:32 -0700 | [diff] [blame] | 62 | |
| 63 | // Fills in |params| with values from the delegate's QuicConfig. |
| 64 | // Returns whether the operation succeeded. |
| 65 | virtual bool FillTransportParameters(TransportParameters* params) = 0; |
| 66 | |
| 67 | // Read |params| and apply the values to the delegate's QuicConfig. |
| 68 | // On failure, returns a QuicErrorCode and saves a detailed error in |
| 69 | // |error_details|. |
| 70 | virtual QuicErrorCode ProcessTransportParameters( |
| 71 | const TransportParameters& params, |
| 72 | bool is_resumption, |
| 73 | std::string* error_details) = 0; |
fayang | d58736d | 2019-11-27 13:35:31 -0800 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | } // namespace quic |
| 77 | |
| 78 | #endif // QUICHE_QUIC_CORE_HANDSHAKER_DELEGATE_INTERFACE_H_ |