11#include <botan/tls_client.h>
13#include <botan/tls_messages.h>
14#include <botan/internal/stl_util.h>
15#include <botan/internal/tls_handshake_state.h>
17#include <botan/internal/tls_client_impl_12.h>
18#if defined(BOTAN_HAS_TLS_13)
19 #include <botan/internal/tls_client_impl_13.h>
31 const std::shared_ptr<Session_Manager>& session_manager,
32 const std::shared_ptr<Credentials_Manager>& creds,
33 const std::shared_ptr<const Policy>& policy,
34 const std::shared_ptr<RandomNumberGenerator>& rng,
37 const std::vector<std::string>& next_protocols,
40 "Policy does not allow to offer requested protocol version");
42#if defined(BOTAN_HAS_TLS_13)
43 if(offer_version == Protocol_Version::TLS_V13) {
44 m_impl = std::make_unique<Client_Impl_13>(
45 callbacks, session_manager, creds, policy, rng, std::move(info), next_protocols);
47 if(m_impl->expects_downgrade()) {
48 m_impl->set_io_buffer_size(io_buf_sz);
51 if(m_impl->is_downgrading()) {
61 m_impl = std::make_unique<Client_Impl_12>(callbacks,
74size_t Client::downgrade() {
77 auto info = m_impl->extract_downgrade_info();
78 m_impl = std::make_unique<Client_Impl_12>(*info);
80 if(!info->peer_transcript.empty()) {
82 return m_impl->from_peer(info->peer_transcript);
91 auto read = m_impl->from_peer(data);
93 if(m_impl->is_downgrading()) {
101 return m_impl->is_handshake_complete();
105 return m_impl->is_active();
109 return m_impl->is_closed();
113 return m_impl->is_closed_for_reading();
117 return m_impl->is_closed_for_writing();
121 return m_impl->peer_cert_chain();
125 return m_impl->peer_raw_public_key();
129 return m_impl->external_psk_identity();
133 return m_impl->key_material_export(label, context, length);
137 m_impl->renegotiate(force_full_renegotiation);
141 m_impl->update_traffic_keys(request_peer_update);
145 return m_impl->secure_renegotiation_supported();
149 m_impl->to_peer(data);
153 m_impl->send_alert(alert);
157 m_impl->send_warning_alert(type);
161 m_impl->send_fatal_alert(type);
169 return m_impl->timeout_check();
173 return m_impl->application_protocol();
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_ARG_CHECK(expr, msg)
bool is_closed_for_reading() const override
bool is_handshake_complete() const override
void renegotiate(bool force_full_renegotiation=false) override
std::string application_protocol() const override
std::shared_ptr< const Public_Key > peer_raw_public_key() const override
Client(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, Server_Information server_info=Server_Information(), Protocol_Version offer_version=Protocol_Version::latest_tls_version(), const std::vector< std::string > &next_protocols={}, size_t reserved_io_buffer_size=TLS::Client::IO_BUF_DEFAULT_SIZE)
bool secure_renegotiation_supported() const override
bool is_active() const override
SymmetricKey key_material_export(std::string_view label, std::string_view context, size_t length) const override
bool is_closed_for_writing() const override
void send_fatal_alert(Alert::Type type) override
bool timeout_check() override
void send_warning_alert(Alert::Type type) override
void to_peer(std::span< const uint8_t > data) override
std::vector< X509_Certificate > peer_cert_chain() const override
bool is_closed() const override
void update_traffic_keys(bool request_peer_update=false) override
std::optional< std::string > external_psk_identity() const override
void send_alert(const Alert &alert) override
size_t from_peer(std::span< const uint8_t > data) override
bool is_datagram_protocol() const