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>
39 std::string_view hostname,
41 std::optional<Session_with_Handle>& session,
42 std::vector<ExternalPSK> psks);
44 static std::variant<Client_Hello_13, Client_Hello_12_Shim>
parse(
const std::vector<uint8_t>& buf);
82 static const struct Server_Hello_Tag {
85 static const struct Hello_Retry_Request_Tag {
88 static const struct Hello_Retry_Request_Creation_Tag {
96 explicit Server_Hello_13(std::unique_ptr<Server_Hello_Internal> data, Hello_Retry_Request_Tag tag);
102 std::optional<Named_Group> key_exchange_group,
109 explicit Server_Hello_13(std::unique_ptr<Server_Hello_Internal> data, Hello_Retry_Request_Creation_Tag tag);
113 bool hello_retry_request_allowed,
120 static std::variant<Hello_Retry_Request, Server_Hello_13, Server_Hello_12_Shim>
parse(
121 const std::vector<uint8_t>& buf);
155 std::vector<uint8_t> serialize()
const override;
161class Certificate_Request_13;
177 std::shared_ptr<const Public_Key>
public_key()
const;
194 std::unique_ptr<X509_Certificate> m_certificate;
195 std::shared_ptr<Public_Key> m_raw_public_key;
202 std::vector<X509_Certificate> cert_chain()
const;
204 bool has_certificate_chain()
const;
205 bool is_raw_public_key()
const;
207 size_t count()
const {
return m_entries.size(); }
209 bool empty()
const {
return m_entries.empty(); }
211 std::shared_ptr<const Public_Key> public_key()
const;
221 std::string_view hostname,
256 void validate_extensions(
const std::set<Extension_Code>& requested_extensions,
Callbacks& cb)
const;
266 std::string_view hostname,
267 bool use_ocsp)
const;
269 std::vector<uint8_t> serialize()
const override;
272 void setup_entries(std::vector<X509_Certificate> cert_chain,
275 void setup_entry(std::shared_ptr<Public_Key> raw_public_key,
Callbacks& callbacks);
277 void verify_certificate_chain(
Callbacks& callbacks,
280 std::string_view hostname,
285 std::vector<uint8_t> m_request_context;
286 std::vector<Certificate_Entry> m_entries;
309 std::vector<uint8_t> serialize()
const override;
311 const std::vector<uint8_t>&
context()
const {
return m_context; }
317 std::vector<uint8_t> m_context;
334 const std::vector<Signature_Scheme>& peer_allowed_schemes,
335 std::string_view hostname,
368 std::vector<uint8_t> serialize()
const override;
378 std::chrono::seconds
lifetime_hint()
const {
return m_ticket_lifetime_hint; }
384 std::optional<uint32_t> early_data_byte_limit()
const;
394 std::chrono::seconds m_ticket_lifetime_hint{};
395 uint32_t m_ticket_age_add;
396 Ticket_Nonce m_ticket_nonce;
397 Opaque_Session_Handle m_handle;
405 explicit Key_Update(
bool request_peer_update);
406 explicit Key_Update(
const std::vector<uint8_t>& buf);
408 std::vector<uint8_t> serialize()
const override;
413 bool m_update_requested;
420template <
typename... AlternativeTs>
422 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
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
Certificate_Request_13(const std::vector< uint8_t > &buf, Connection_Side side)
bool verify(const Public_Key &public_key, Callbacks &callbacks, const Transcript_Hash &transcript_hash) const
Certificate_Verify_13(const std::vector< uint8_t > &buf, Connection_Side side)
Certificate_Verify(const std::vector< uint8_t > &buf)
void validate_updates(const Client_Hello_13 &new_ch)
static std::variant< Client_Hello_13, Client_Hello_12_Shim > parse(const std::vector< uint8_t > &buf)
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, const std::vector< std::string > &next_protocols, std::optional< Session_with_Handle > &session, std::vector< ExternalPSK > psks)
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
Handshake_Type type() const override
Encrypted_Extensions(const std::vector< uint8_t > &buf)
Finished(const std::vector< uint8_t > &buf)
bool verify(Cipher_State *cipher_state, const Transcript_Hash &transcript_hash) const
Finished_13(Cipher_State *cipher_state, const Transcript_Hash &transcript_hash)
Finished(const 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(const std::vector< 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
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
detail::as_wrapped_references_t< Server_Handshake_13_Message > Server_Handshake_13_Message_Ref
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
Strong< std::vector< uint8_t >, struct Ticket_Nonce_ > Ticket_Nonce
Used to derive the ticket's PSK from the resumption_master_secret.
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
detail::as_wrapped_references_t< Client_Handshake_13_Message > Client_Handshake_13_Message_Ref
std::variant< Client_Hello_13, Client_Hello_12_Shim, Certificate_13, Certificate_Verify_13, Finished_13 > Client_Handshake_13_Message
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