10#ifndef BOTAN_TLS_MESSAGES_13_H_
11#define BOTAN_TLS_MESSAGES_13_H_
13#include <botan/tls_extensions.h>
14#include <botan/tls_external_psk.h>
15#include <botan/tls_messages.h>
40 std::string_view hostname,
42 std::optional<Session_with_Handle>& session,
43 std::vector<ExternalPSK> psks);
45 static std::variant<Client_Hello_13, Client_Hello_12_Shim>
parse(std::span<const uint8_t> buf);
69#if defined(BOTAN_HAS_TLS_DOWNGRADE_SUPPORT)
89 static const struct Server_Hello_Tag {
92 static const struct Hello_Retry_Request_Tag {
95 static const struct Hello_Retry_Request_Creation_Tag {
103 explicit Server_Hello_13(std::unique_ptr<Server_Hello_Internal> data, Hello_Retry_Request_Tag tag);
109 std::optional<Named_Group> key_exchange_group,
116 explicit Server_Hello_13(std::unique_ptr<Server_Hello_Internal> data, Hello_Retry_Request_Creation_Tag tag);
120 bool hello_retry_request_allowed,
127 static std::variant<Hello_Retry_Request, Server_Hello_13, Server_Hello_12_Shim>
parse(
128 std::span<const uint8_t> buf);
160 bool requesting_client_auth);
166 std::vector<uint8_t> serialize()
const override;
172class Certificate_Request_13;
188 std::shared_ptr<const Public_Key>
public_key()
const;
205 std::unique_ptr<X509_Certificate> m_certificate;
206 std::shared_ptr<Public_Key> m_raw_public_key;
213 std::vector<X509_Certificate> cert_chain()
const;
215 bool has_certificate_chain()
const;
216 bool is_raw_public_key()
const;
218 size_t count()
const {
return m_entries.size(); }
220 bool empty()
const {
return m_entries.empty(); }
222 std::shared_ptr<const Public_Key> public_key()
const;
232 std::string_view hostname,
267 void validate_extensions(
const std::set<Extension_Code>& requested_extensions,
Callbacks& cb)
const;
277 std::string_view hostname,
278 bool use_ocsp)
const;
280 std::vector<uint8_t> serialize()
const override;
283 void setup_entries(std::vector<X509_Certificate> cert_chain,
286 void setup_entry(std::shared_ptr<Public_Key> raw_public_key,
Callbacks& callbacks);
288 void verify_certificate_chain(
Callbacks& callbacks,
291 std::string_view hostname,
296 std::vector<uint8_t> m_request_context;
297 std::vector<Certificate_Entry> m_entries;
320 std::vector<uint8_t> serialize()
const override;
322 const std::vector<uint8_t>&
context()
const {
return m_context; }
328 std::vector<uint8_t> m_context;
345 const std::vector<Signature_Scheme>& peer_allowed_schemes,
346 std::string_view hostname,
379 std::vector<uint8_t> serialize()
const override;
389 std::chrono::seconds
lifetime_hint()
const {
return m_ticket_lifetime_hint; }
395 std::optional<uint32_t> early_data_byte_limit()
const;
405 std::chrono::seconds m_ticket_lifetime_hint{};
406 uint32_t m_ticket_age_add;
407 Ticket_Nonce m_ticket_nonce;
408 Opaque_Session_Handle m_handle;
416 explicit Key_Update(
bool request_peer_update);
417 explicit Key_Update(std::span<const uint8_t> buf);
419 std::vector<uint8_t> serialize()
const override;
424 bool m_update_requested;
431template <
typename... AlternativeTs>
433 using type = std::variant<std::reference_wrapper<AlternativeTs>...>;
#define BOTAN_UNSTABLE_API
Certificate_Entry & operator=(const Certificate_Entry &other)=delete
const Extensions & extensions() const
Extensions & extensions()
Certificate_Entry(TLS_Data_Reader &reader, Connection_Side side, Certificate_Type cert_type)
Certificate_Entry & operator=(Certificate_Entry &&other) noexcept
Certificate_Entry(const Certificate_Entry &other)=delete
bool has_certificate() const
Certificate_Entry(Certificate_Entry &&other) noexcept
std::shared_ptr< const Public_Key > public_key() const
Handshake_Type type() const override
const std::vector< uint8_t > & request_context() const
std::vector< uint8_t > serialize() const override
Certificate_13(const Certificate_Request_13 &cert_request, std::string_view hostname, Credentials_Manager &credentials_manager, Callbacks &callbacks, Certificate_Type cert_type)
const std::vector< Signature_Scheme > & signature_schemes() const
const Extensions & extensions() const
const std::vector< uint8_t > & context() const
Handshake_Type type() const override
const std::vector< Signature_Scheme > & certificate_signature_schemes() const
Certificate_Request_13(std::span< const uint8_t > buf, Connection_Side side)
static std::optional< Certificate_Request_13 > maybe_create(const Client_Hello_13 &sni_hostname, Credentials_Manager &cred_mgr, Callbacks &callbacks, const Policy &policy)
std::vector< X509_DN > acceptable_CAs() const
bool verify(const Public_Key &public_key, Callbacks &callbacks, const Transcript_Hash &transcript_hash) const
Certificate_Verify_13(std::span< const uint8_t > buf, Connection_Side side)
Certificate_Verify(std::span< const uint8_t > buf)
void validate_updates(const Client_Hello_13 &new_ch)
std::optional< Protocol_Version > highest_supported_version(const Policy &policy) const
Client_Hello_13(const Policy &policy, Callbacks &cb, RandomNumberGenerator &rng, std::string_view hostname, std::vector< std::string > next_protocols, std::optional< Session_with_Handle > &session, std::vector< ExternalPSK > psks)
static std::variant< Client_Hello_13, Client_Hello_12_Shim > parse(std::span< const uint8_t > buf)
void retry(const Hello_Retry_Request &hrr, const Transcript_Hash_State &transcript_hash_state, Callbacks &cb, RandomNumberGenerator &rng)
std::vector< std::string > next_protocols() const
Client_Hello(const Client_Hello &)=delete
const Extensions & extensions() const
Encrypted_Extensions(std::span< const uint8_t > buf)
Handshake_Type type() const override
bool verify(Cipher_State *cipher_state, const Transcript_Hash &transcript_hash) const
Finished_13(Cipher_State *cipher_state, const Transcript_Hash &transcript_hash)
Finished(std::vector< uint8_t > buf)
Finished(std::vector< uint8_t > buf)
Handshake_Message()=default
friend class Server_Hello_13
Hello_Retry_Request(std::unique_ptr< Server_Hello_Internal > data)
Handshake_Type wire_type() const override
Handshake_Type type() const override
bool expects_reciprocation() const
Key_Update(bool request_peer_update)
Handshake_Type type() const override
Handshake_Type type() const override
std::chrono::seconds lifetime_hint() const
uint32_t ticket_age_add() const
const Ticket_Nonce & nonce() const
New_Session_Ticket_13(Ticket_Nonce nonce, const Session &session, const Session_Handle &handle, Callbacks &callbacks)
const Opaque_Session_Handle & handle() const
const Extensions & extensions() const
static std::variant< Hello_Retry_Request, Server_Hello_13, Server_Hello_12_Shim > parse(std::span< const uint8_t > buf)
static const struct Botan::TLS::Server_Hello_13::Hello_Retry_Request_Tag as_hello_retry_request
static const struct Botan::TLS::Server_Hello_13::Hello_Retry_Request_Creation_Tag as_new_hello_retry_request
Server_Hello_13(std::unique_ptr< Server_Hello_Internal > data, Server_Hello_Tag tag=as_server_hello)
std::optional< Protocol_Version > random_signals_downgrade() const
void basic_validation() const
static std::variant< Hello_Retry_Request, Server_Hello_13 > create(const Client_Hello_13 &ch, bool hello_retry_request_allowed, Session_Manager &session_mgr, Credentials_Manager &credentials_mgr, RandomNumberGenerator &rng, const Policy &policy, Callbacks &cb)
Protocol_Version selected_version() const final
static const struct Botan::TLS::Server_Hello_13::Server_Hello_Tag as_server_hello
Server_Hello(const Server_Hello &)=delete
Helper class to embody a session handle in all protocol versions.
typename as_wrapped_references< T >::type as_wrapped_references_t
detail::as_wrapped_references_t< Server_Handshake_13_Message > Server_Handshake_13_Message_Ref
std::variant< Server_Hello_13, Server_Hello_12_Shim, Hello_Retry_Request, Encrypted_Extensions, Certificate_13, Certificate_Request_13, Certificate_Verify_13, Finished_13 > Server_Handshake_13_Message
std::vector< uint8_t > Transcript_Hash
detail::as_wrapped_references_t< Handshake_Message_13 > Handshake_Message_13_Ref
std::variant< Key_Update > Client_Post_Handshake_13_Message
std::variant< Client_Hello_13, Client_Hello_12_Shim, Certificate_13, Certificate_Verify_13, Finished_13 > Client_Handshake_13_Message
std::variant< Client_Hello_13, Client_Hello_12_Shim, Server_Hello_13, Server_Hello_12_Shim, Hello_Retry_Request, Encrypted_Extensions, Certificate_13, Certificate_Request_13, Certificate_Verify_13, Finished_13 > Handshake_Message_13
Strong< std::vector< uint8_t >, struct Ticket_Nonce_ > Ticket_Nonce
Used to derive the ticket's PSK from the resumption_master_secret.
detail::as_wrapped_references_t< Client_Handshake_13_Message > Client_Handshake_13_Message_Ref
std::variant< New_Session_Ticket_13, Key_Update > Post_Handshake_Message_13
std::variant< New_Session_Ticket_13, Key_Update > Server_Post_Handshake_13_Message
Strong< std::vector< uint8_t >, struct Opaque_Session_Handle_ > Opaque_Session_Handle
holds an opaque session handle as used in TLS 1.3 that could be either a ticket for stateless resumpt...
std::variant< std::reference_wrapper< AlternativeTs >... > type