9#ifndef BOTAN_TLS_CHANNEL_IMPL_12_H_
10#define BOTAN_TLS_CHANNEL_IMPL_12_H_
12#include <botan/tls_alert.h>
13#include <botan/tls_callbacks.h>
14#include <botan/tls_session.h>
15#include <botan/tls_session_manager.h>
16#include <botan/internal/tls_channel_impl.h>
25class X509_Certificate;
29class Connection_Cipher_State;
30class Connection_Sequence_Numbers;
32class Handshake_Message;
42 typedef std::function<void(
const uint8_t[],
size_t)>
output_fn;
43 typedef std::function<void(
const uint8_t[],
size_t)>
data_cb;
64 const std::shared_ptr<RandomNumberGenerator>&
rng,
65 const std::shared_ptr<const Policy>&
policy,
76 size_t from_peer(std::span<const uint8_t> data)
override;
77 void to_peer(std::span<const uint8_t> data)
override;
134 void renegotiate(
bool force_full_renegotiation =
false)
override;
162 const std::vector<uint8_t>& contents,
163 bool epoch0_restart) = 0;
199 void send_record(
Record_Type record_type,
const std::vector<uint8_t>& record);
201 void send_record_under_epoch(uint16_t epoch,
Record_Type record_type,
const std::vector<uint8_t>& record);
203 void send_record_array(uint16_t epoch,
Record_Type record_type,
const uint8_t input[],
size_t length);
212 std::shared_ptr<Connection_Cipher_State> read_cipher_state_epoch(uint16_t epoch)
const;
214 std::shared_ptr<Connection_Cipher_State> write_cipher_state_epoch(uint16_t epoch)
const;
216 const Handshake_State* active_state()
const {
return m_active_state.get(); }
218 const Handshake_State* pending_state()
const {
return m_pending_state.get(); }
222 uint64_t record_sequence,
224 Protocol_Version record_version,
225 bool epoch0_restart);
231 const bool m_is_server;
232 const bool m_is_datagram;
235 std::shared_ptr<Callbacks> m_callbacks;
238 std::shared_ptr<Session_Manager> m_session_manager;
239 std::shared_ptr<const Policy> m_policy;
240 std::shared_ptr<RandomNumberGenerator> m_rng;
243 std::unique_ptr<Connection_Sequence_Numbers> m_sequence_numbers;
246 std::unique_ptr<Handshake_State> m_active_state;
247 std::unique_ptr<Handshake_State> m_pending_state;
250 std::map<uint16_t, std::shared_ptr<Connection_Cipher_State>> m_write_cipher_states;
251 std::map<uint16_t, std::shared_ptr<Connection_Cipher_State>> m_read_cipher_states;
258 bool m_has_been_closed;
RandomNumberGenerator & rng()
virtual std::vector< X509_Certificate > get_peer_cert_chain(const Handshake_State &state) const =0
bool is_closed() const override
void change_cipher_spec_reader(Connection_Side side)
Channel_Impl_12 & operator=(const Channel_Impl_12 &)=delete
void inspect_handshake_message(const Handshake_Message &msg)
void update_traffic_keys(bool request_peer_update=false) override
Handshake_State & create_handshake_state(Protocol_Version version)
std::vector< uint8_t > secure_renegotiation_data_for_server_hello() const
~Channel_Impl_12() override
bool is_handshake_complete() const override
Callbacks & callbacks() const
std::function< bool(const Session &)> handshake_cb
std::shared_ptr< const Public_Key > peer_raw_public_key() const override
std::function< void(const uint8_t[], size_t)> output_fn
size_t from_peer(std::span< const uint8_t > data) override
bool is_closed_for_reading() const override
void secure_renegotiation_check(const Client_Hello_12 *client_hello)
bool timeout_check() override
bool is_active() const override
Session_Manager & session_manager()
std::function< void(const Handshake_Message &)> handshake_msg_cb
Channel_Impl_12(const Channel_Impl_12 &)=delete
const Policy & policy() const
void send_alert(const Alert &alert) override
virtual void initiate_handshake(Handshake_State &state, bool force_full_renegotiation)=0
std::vector< X509_Certificate > peer_cert_chain() const override
void to_peer(std::span< const uint8_t > data) override
bool is_closed_for_writing() const override
std::function< void(const uint8_t[], size_t)> data_cb
void change_cipher_spec_writer(Connection_Side side)
std::vector< uint8_t > secure_renegotiation_data_for_client_hello() const
virtual std::unique_ptr< Handshake_State > new_handshake_state(std::unique_ptr< class Handshake_IO > io)=0
Channel_Impl_12(const std::shared_ptr< Callbacks > &callbacks, const std::shared_ptr< Session_Manager > &session_manager, const std::shared_ptr< RandomNumberGenerator > &rng, const std::shared_ptr< const Policy > &policy, bool is_server, bool is_datagram, size_t io_buf_sz=TLS::Channel::IO_BUF_DEFAULT_SIZE)
std::function< void(Alert, const uint8_t[], size_t)> alert_cb
SymmetricKey key_material_export(std::string_view label, std::string_view context, size_t length) const override
std::optional< std::string > external_psk_identity() const override
void reset_active_association_state()
virtual void process_handshake_msg(const Handshake_State *active_state, Handshake_State &pending_state, Handshake_Type type, const std::vector< uint8_t > &contents, bool epoch0_restart)=0
bool secure_renegotiation_supported() const override
void renegotiate(bool force_full_renegotiation=false) override
static constexpr size_t IO_BUF_DEFAULT_SIZE
std::vector< T, secure_allocator< T > > secure_vector