11#include <botan/tls_server.h>
13#include <botan/tls_magic.h>
14#include <botan/tls_messages.h>
15#include <botan/internal/stl_util.h>
16#include <botan/internal/tls_handshake_state.h>
18#include <botan/internal/tls_server_impl_12.h>
19#if defined(BOTAN_HAS_TLS_13)
20 #include <botan/internal/tls_server_impl_13.h>
29 const std::shared_ptr<Session_Manager>& session_manager,
30 const std::shared_ptr<Credentials_Manager>& creds,
31 const std::shared_ptr<const Policy>& policy,
32 const std::shared_ptr<RandomNumberGenerator>& rng,
35 const auto max_version = policy->latest_supported_version(is_datagram);
37 if(!max_version.is_pre_tls_13()) {
38#if defined(BOTAN_HAS_TLS_13)
39 m_impl = std::make_unique<Server_Impl_13>(callbacks, session_manager, creds, policy, rng);
41 if(m_impl->expects_downgrade()) {
42 m_impl->set_io_buffer_size(io_buf_sz);
48 m_impl = std::make_unique<Server_Impl_12>(callbacks, session_manager, creds, policy, rng, is_datagram, io_buf_sz);
55 auto read = m_impl->from_peer(data);
57 if(m_impl->is_downgrading()) {
58 auto info = m_impl->extract_downgrade_info();
59 m_impl = std::make_unique<Server_Impl_12>(*info);
62 read = m_impl->from_peer(info->peer_transcript);
69 return m_impl->is_handshake_complete();
73 return m_impl->is_active();
77 return m_impl->is_closed();
81 return m_impl->is_closed_for_reading();
85 return m_impl->is_closed_for_writing();
89 return m_impl->peer_cert_chain();
93 return m_impl->peer_raw_public_key();
97 return m_impl->external_psk_identity();
101 return m_impl->key_material_export(label, context, length);
105 m_impl->renegotiate(force_full_renegotiation);
109 return m_impl->new_session_ticket_supported();
113 return m_impl->send_new_session_tickets(tickets);
117 m_impl->update_traffic_keys(request_peer_update);
121 return m_impl->secure_renegotiation_supported();
125 m_impl->to_peer(data);
129 m_impl->send_alert(alert);
133 m_impl->send_warning_alert(type);
137 m_impl->send_fatal_alert(type);
145 return m_impl->timeout_check();
149 return m_impl->application_protocol();
void update_traffic_keys(bool request_peer_update=false) override
SymmetricKey key_material_export(std::string_view label, std::string_view context, size_t length) const override
bool timeout_check() override
bool secure_renegotiation_supported() const override
void send_fatal_alert(Alert::Type type) override
bool is_closed() const override
bool is_closed_for_writing() const override
std::string application_protocol() const override
size_t send_new_session_tickets(size_t tickets=1)
Server(const std::shared_ptr< Callbacks > &callbacks, const std::shared_ptr< Session_Manager > &session_manager, const std::shared_ptr< Credentials_Manager > &creds, const std::shared_ptr< const Policy > &policy, const std::shared_ptr< RandomNumberGenerator > &rng, bool is_datagram=false, size_t reserved_io_buffer_size=TLS::Channel::IO_BUF_DEFAULT_SIZE)
bool is_handshake_complete() const override
void renegotiate(bool force_full_renegotiation=false) override
std::optional< std::string > external_psk_identity() const override
std::shared_ptr< const Public_Key > peer_raw_public_key() const override
void send_alert(const Alert &alert) override
void send_warning_alert(Alert::Type type) override
bool new_session_ticket_supported() const
std::vector< X509_Certificate > peer_cert_chain() const override
void to_peer(std::span< const uint8_t > data) override
bool is_active() const override
size_t from_peer(std::span< const uint8_t > data) override
bool is_closed_for_reading() const override