Botan 3.12.0
Crypto and TLS for C&
tls_connection_state_13.cpp
Go to the documentation of this file.
1/*
2* (C) 2026 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#include <botan/internal/tls_connection_state_13.h>
8
9#include <botan/tls_extensions.h>
10#include <botan/internal/tls_handshake_state_13.h>
11
12namespace Botan::TLS {
13
14namespace {
15
16std::string extract_alpn(const Internal::Handshake_State_13_Base& state) {
17 const auto& eee = state.encrypted_extensions().extensions();
18 if(const auto* alpn = eee.get<Application_Layer_Protocol_Notification>()) {
19 return alpn->single_protocol();
20 }
21 return {};
22}
23
24} // namespace
25
29
30Active_Connection_State_13::Active_Connection_State_13(const Internal::Handshake_State_13_Base& state,
31 std::vector<X509_Certificate> peer_certs,
32 std::shared_ptr<const Public_Key> peer_raw_public_key,
33 std::optional<std::string> psk_identity,
34 std::string sni_hostname,
36 m_version(state.server_hello().selected_version()),
37 m_ciphersuite_code(state.server_hello().ciphersuite()),
38 m_application_protocol(extract_alpn(state)),
39 m_peer_certs(std::move(peer_certs)),
40 m_client_random(state.client_hello().random()),
41 m_psk_identity(std::move(psk_identity)),
42 m_peer_raw_public_key(std::move(peer_raw_public_key)),
43 m_sni_hostname(std::move(sni_hostname)),
44 m_peer_supports_psk_dhe_ke(peer_supports_psk_dhe_ke) {}
45
46} // namespace Botan::TLS
const std::optional< std::string > & psk_identity() const
Active_Connection_State_13(const Internal::Handshake_State_13_Base &state, std::vector< X509_Certificate > peer_certs, std::shared_ptr< const Public_Key > peer_raw_public_key, std::optional< std::string > psk_identity, std::string sni_hostname, bool peer_supports_psk_dhe_ke)
const std::vector< X509_Certificate > & peer_certs() const
const std::shared_ptr< const Public_Key > & peer_raw_public_key() const