Bence Béky | bac0405 | 2022-04-07 15:44:29 -0400 | [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 | |
| 8 | #include "quiche/quic/core/crypto/transport_parameters.h" |
| 9 | #include "quiche/quic/core/quic_types.h" |
| 10 | #include "quiche/quic/core/quic_versions.h" |
| 11 | |
| 12 | namespace quic { |
| 13 | |
| 14 | class QuicDecrypter; |
| 15 | class QuicEncrypter; |
| 16 | |
| 17 | // Pure virtual class to get notified when particular handshake events occurred. |
| 18 | class QUIC_EXPORT_PRIVATE HandshakerDelegateInterface { |
| 19 | public: |
| 20 | virtual ~HandshakerDelegateInterface() {} |
| 21 | |
| 22 | // Called when new decryption key of |level| is available. Returns true if |
| 23 | // decrypter is set successfully, otherwise, returns false. |
| 24 | virtual bool OnNewDecryptionKeyAvailable( |
| 25 | EncryptionLevel level, std::unique_ptr<QuicDecrypter> decrypter, |
| 26 | bool set_alternative_decrypter, bool latch_once_used) = 0; |
| 27 | |
| 28 | // Called when new encryption key of |level| is available. |
| 29 | virtual void OnNewEncryptionKeyAvailable( |
| 30 | EncryptionLevel level, std::unique_ptr<QuicEncrypter> encrypter) = 0; |
| 31 | |
| 32 | // Called to set default encryption level to |level|. Only used in QUIC |
| 33 | // crypto. |
| 34 | virtual void SetDefaultEncryptionLevel(EncryptionLevel level) = 0; |
| 35 | |
| 36 | // Called when both 1-RTT read and write keys are available. Only used in TLS |
| 37 | // handshake. |
| 38 | virtual void OnTlsHandshakeComplete() = 0; |
| 39 | |
| 40 | // Called to discard old decryption keys to stop processing packets of |
| 41 | // encryption |level|. |
| 42 | virtual void DiscardOldDecryptionKey(EncryptionLevel level) = 0; |
| 43 | |
| 44 | // Called to discard old encryption keys (and neuter obsolete data). |
| 45 | // TODO(fayang): consider to combine this with DiscardOldDecryptionKey. |
| 46 | virtual void DiscardOldEncryptionKey(EncryptionLevel level) = 0; |
| 47 | |
| 48 | // Called to neuter ENCRYPTION_INITIAL data (without discarding initial keys). |
| 49 | virtual void NeuterUnencryptedData() = 0; |
| 50 | |
| 51 | // Called to neuter data of HANDSHAKE_DATA packet number space. Only used in |
| 52 | // QUIC crypto. This is called 1) when a client switches to forward secure |
| 53 | // encryption level and 2) a server successfully processes a forward secure |
| 54 | // packet. |
| 55 | virtual void NeuterHandshakeData() = 0; |
| 56 | |
| 57 | // Called when 0-RTT data is rejected by the server. This is only called in |
| 58 | // TLS handshakes and only called on clients. |
| 59 | virtual void OnZeroRttRejected(int reason) = 0; |
| 60 | |
| 61 | // Fills in |params| with values from the delegate's QuicConfig. |
| 62 | // Returns whether the operation succeeded. |
| 63 | virtual bool FillTransportParameters(TransportParameters* params) = 0; |
| 64 | |
| 65 | // Read |params| and apply the values to the delegate's QuicConfig. |
| 66 | // On failure, returns a QuicErrorCode and saves a detailed error in |
| 67 | // |error_details|. |
| 68 | virtual QuicErrorCode ProcessTransportParameters( |
| 69 | const TransportParameters& params, bool is_resumption, |
| 70 | std::string* error_details) = 0; |
| 71 | |
| 72 | // Called at the end of an handshake operation callback. |
| 73 | virtual void OnHandshakeCallbackDone() = 0; |
| 74 | |
| 75 | // Whether a packet flusher is currently attached. |
| 76 | virtual bool PacketFlusherAttached() const = 0; |
| 77 | |
| 78 | // Get the QUIC version currently in use. tls_handshaker needs this to pass |
| 79 | // to crypto_utils to apply version-dependent HKDF labels. |
| 80 | virtual ParsedQuicVersion parsed_version() const = 0; |
| 81 | }; |
| 82 | |
| 83 | } // namespace quic |
| 84 | |
| 85 | #endif // QUICHE_QUIC_CORE_HANDSHAKER_DELEGATE_INTERFACE_H_ |