blob: bfc87610fd4ffeea4b83c311e8fe333b18502dc1 [file] [log] [blame]
fayangd58736d2019-11-27 13:35:31 -08001// 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
dschinazi2c4d8332020-05-27 17:23:32 -07008#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h"
fayangd58736d2019-11-27 13:35:31 -08009#include "net/third_party/quiche/src/quic/core/quic_types.h"
10
11namespace quic {
12
13class QuicDecrypter;
14class QuicEncrypter;
15
16// Pure virtual class to get notified when particular handshake events occurred.
17class QUIC_EXPORT_PRIVATE HandshakerDelegateInterface {
18 public:
19 virtual ~HandshakerDelegateInterface() {}
20
fayangd2866522020-02-12 11:15:27 -080021 // Called when new decryption key of |level| is available. Returns true if
22 // decrypter is set successfully, otherwise, returns false.
23 virtual bool OnNewDecryptionKeyAvailable(
fayang3f7bcbe2020-02-10 11:08:47 -080024 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;
fayangd58736d2019-11-27 13:35:31 -080033
fayangd18bfb92020-03-19 17:24:21 -070034 // Called to set default encryption level to |level|. Only used in QUIC
35 // crypto.
fayangd58736d2019-11-27 13:35:31 -080036 virtual void SetDefaultEncryptionLevel(EncryptionLevel level) = 0;
37
fayangd18bfb92020-03-19 17:24:21 -070038 // Called when both 1-RTT read and write keys are available. Only used in TLS
39 // handshake.
40 virtual void OnOneRttKeysAvailable() = 0;
41
fayangd58736d2019-11-27 13:35:31 -080042 // 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
fayang01062942020-01-22 07:23:23 -080053 // 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
fayangd58736d2019-11-27 13:35:31 -080055 // encryption level and 2) a server successfully processes a forward secure
fayang01062942020-01-22 07:23:23 -080056 // packet.
fayangd58736d2019-11-27 13:35:31 -080057 virtual void NeuterHandshakeData() = 0;
nharperd25cd652020-05-20 13:10:26 -070058
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;
dschinazi2c4d8332020-05-27 17:23:32 -070062
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;
fayangd58736d2019-11-27 13:35:31 -080074};
75
76} // namespace quic
77
78#endif // QUICHE_QUIC_CORE_HANDSHAKER_DELEGATE_INTERFACE_H_