Botan 3.13.0
Crypto and TLS for C&
tls_connection_state_12.h
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#ifndef BOTAN_TLS_CONNECTION_STATE_12_H_
8#define BOTAN_TLS_CONNECTION_STATE_12_H_
9
10#include <botan/secmem.h>
11#include <botan/tls_session_id.h>
12#include <botan/tls_version.h>
13#include <botan/x509cert.h>
14
15#include <memory>
16#include <optional>
17#include <string>
18#include <vector>
19
20namespace Botan::TLS {
21
22class Handshake_IO;
24class Handshake_State;
25
26/**
27* Captures the state of a completed TLS 1.2 handshake that is needed
28* for the lifetime of an active connection.
29 */
31 public:
33
36
39
41
42 // DTLS variant: retains handshake IO for retransmission validation and
43 // reactive replay of the terminal flight when appropriate.
45 std::string application_protocol,
46 std::unique_ptr<Handshake_IO> io);
47
48 Protocol_Version version() const { return m_version; }
49
50 uint16_t ciphersuite_code() const { return m_ciphersuite_code; }
51
52 const std::string& application_protocol() const { return m_application_protocol; }
53
54 const std::vector<X509_Certificate>& peer_certs() const { return m_peer_certs; }
55
56 const std::vector<uint8_t>& client_random() const { return m_client_random; }
57
58 const std::optional<std::string>& psk_identity() const { return m_psk_identity; }
59
60 const std::vector<uint8_t>& server_random() const { return m_server_random; }
61
62 const Session_ID& session_id() const { return m_session_id; }
63
64 const secure_vector<uint8_t>& master_secret() const { return m_master_secret; }
65
66 const std::string& prf_algo() const { return m_prf_algo; }
67
68 bool client_supports_secure_renegotiation() const { return m_client_supports_secure_renegotiation; }
69
70 bool server_supports_secure_renegotiation() const { return m_server_supports_secure_renegotiation; }
71
72 const std::vector<uint8_t>& client_finished_verify_data() const { return m_client_finished_verify_data; }
73
74 const std::vector<uint8_t>& server_finished_verify_data() const { return m_server_finished_verify_data; }
75
76 bool supports_extended_master_secret() const { return m_supports_extended_master_secret; }
77
78 /**
79 * For DTLS: the handshake IO from the completed handshake, needed to
80 * validate retransmissions and, for the terminal-flight sender, replay
81 * the final flight. Null for stream TLS.
82 */
83 Datagram_Handshake_IO* dtls_handshake_io() { return m_dtls_handshake_io.get(); }
84
85 private:
86 Protocol_Version m_version;
87 uint16_t m_ciphersuite_code = 0;
88 std::string m_application_protocol;
89 std::vector<X509_Certificate> m_peer_certs;
90 std::vector<uint8_t> m_client_random;
91 std::optional<std::string> m_psk_identity;
92 std::vector<uint8_t> m_server_random;
93 Session_ID m_session_id;
94 secure_vector<uint8_t> m_master_secret;
95 std::string m_prf_algo;
96 bool m_client_supports_secure_renegotiation = false;
97 bool m_server_supports_secure_renegotiation = false;
98 std::vector<uint8_t> m_client_finished_verify_data;
99 std::vector<uint8_t> m_server_finished_verify_data;
100 bool m_supports_extended_master_secret = false;
101 std::unique_ptr<Datagram_Handshake_IO> m_dtls_handshake_io;
102};
103
104} // namespace Botan::TLS
105
106#endif
const std::vector< uint8_t > & client_random() const
const std::vector< uint8_t > & server_random() const
Active_Connection_State_12(Active_Connection_State_12 &&) noexcept
const std::optional< std::string > & psk_identity() const
const std::string & application_protocol() const
const std::vector< uint8_t > & client_finished_verify_data() const
const secure_vector< uint8_t > & master_secret() const
const std::vector< uint8_t > & server_finished_verify_data() const
const std::vector< X509_Certificate > & peer_certs() const
Strong< std::vector< uint8_t >, struct Session_ID_ > Session_ID
holds a TLS 1.2 session ID for stateful resumption
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128