Botan 3.11.1
Crypto and TLS for C&
Botan::TLS::Handshake_State_13< whoami, Outbound_Message_T, Inbound_Message_T, Inbound_Post_Handshake_Message_T > Class Template Reference

#include <tls_handshake_state_13.h>

Inheritance diagram for Botan::TLS::Handshake_State_13< whoami, Outbound_Message_T, Inbound_Message_T, Inbound_Post_Handshake_Message_T >:
Botan::TLS::Internal::Handshake_State_13_Base

Public Member Functions

const Certificate_Request_13certificate_request () const
const Certificate_13client_certificate () const
const Certificate_Verify_13client_certificate_verify () const
const Finished_13client_finished () const
Client_Hello_13client_hello ()
const Client_Hello_13client_hello () const
void confirm_peer_finished_verified ()
const Encrypted_Extensionsencrypted_extensions () const
bool handshake_finished () const
 Handshake_State_13 ()
bool has_certificate_request () const
bool has_client_certificate_msg () const
bool has_client_finished () const
bool has_client_hello () const
bool has_hello_retry_request () const
bool has_server_certificate_msg () const
bool has_server_finished () const
bool has_server_hello () const
const Hello_Retry_Requesthello_retry_request () const
decltype(auto) received (Handshake_Message_13 message)
decltype(auto) received (Post_Handshake_Message_13 message)
template<typename MsgT>
requires (std::is_constructible_v<Outbound_Message_T, MsgT>)
std::reference_wrapper< MsgT > sending (MsgT msg)
template<typename... MsgTs>
requires (is_generalizable_to<Outbound_Message_T>(message))
decltype(auto) sending (std::variant< MsgTs... > message)
const Certificate_13server_certificate () const
const Certificate_Verify_13server_certificate_verify () const
const Finished_13server_finished () const
const Server_Hello_13server_hello () const

Protected Member Functions

Certificate_13store (Certificate_13 certificate, bool from_peer)
Certificate_Request_13store (Certificate_Request_13 certificate_request, bool from_peer)
Certificate_Verify_13store (Certificate_Verify_13 certificate_verify, bool from_peer)
Client_Hello_12_Shimstore (Client_Hello_12_Shim client_hello, bool from_peer)
Client_Hello_13store (Client_Hello_13 client_hello, bool from_peer)
Encrypted_Extensionsstore (Encrypted_Extensions encrypted_extensions, bool from_peer)
Finished_13store (Finished_13 finished, bool from_peer)
Hello_Retry_Requeststore (Hello_Retry_Request hello_retry_request, bool from_peer)
Server_Hello_12_Shimstore (Server_Hello_12_Shim server_hello, bool from_peer)
Server_Hello_13store (Server_Hello_13 server_hello, bool from_peer)

Detailed Description

template<Connection_Side whoami, typename Outbound_Message_T, typename Inbound_Message_T, typename Inbound_Post_Handshake_Message_T>
class Botan::TLS::Handshake_State_13< whoami, Outbound_Message_T, Inbound_Message_T, Inbound_Post_Handshake_Message_T >

Place to store TLS handshake messages

This class is used to keep all handshake messages that have been received from and sent to the peer as part of the TLS 1.3 handshake. Getters are provided for all message types. Specializations for the client and server side provide specific setters in the form of sent and received that only allow those types of handshake messages that are sensible for the respective connection side.

The handshake state machine as described in RFC 8446 Appendix A is NOT validated here.

Definition at line 140 of file tls_handshake_state_13.h.

Constructor & Destructor Documentation

◆ Handshake_State_13()

template<Connection_Side whoami, typename Outbound_Message_T, typename Inbound_Message_T, typename Inbound_Post_Handshake_Message_T>
Botan::TLS::Handshake_State_13< whoami, Outbound_Message_T, Inbound_Message_T, Inbound_Post_Handshake_Message_T >::Handshake_State_13 ( )
inline

Member Function Documentation

◆ certificate_request()

const Certificate_Request_13 & Botan::TLS::Internal::Handshake_State_13_Base::certificate_request ( ) const
inlineinherited

Definition at line 61 of file tls_handshake_state_13.h.

61{ return get(m_certificate_request); }

Referenced by store().

◆ client_certificate()

const Certificate_13 & Botan::TLS::Internal::Handshake_State_13_Base::client_certificate ( ) const
inlineinherited

Definition at line 65 of file tls_handshake_state_13.h.

65{ return get(m_client_certificate); }

◆ client_certificate_verify()

const Certificate_Verify_13 & Botan::TLS::Internal::Handshake_State_13_Base::client_certificate_verify ( ) const
inlineinherited

Definition at line 69 of file tls_handshake_state_13.h.

69{ return get(m_client_certificate_verify); }

◆ client_finished()

const Finished_13 & Botan::TLS::Internal::Handshake_State_13_Base::client_finished ( ) const
inlineinherited

Definition at line 73 of file tls_handshake_state_13.h.

73{ return get(m_client_finished); }

◆ client_hello() [1/2]

Client_Hello_13 & Botan::TLS::Internal::Handshake_State_13_Base::client_hello ( )
inlineinherited

Definition at line 51 of file tls_handshake_state_13.h.

51{ return get(m_client_hello); }

Referenced by store(), and store().

◆ client_hello() [2/2]

const Client_Hello_13 & Botan::TLS::Internal::Handshake_State_13_Base::client_hello ( ) const
inlineinherited

Definition at line 53 of file tls_handshake_state_13.h.

53{ return get(m_client_hello); }

◆ confirm_peer_finished_verified()

void Botan::TLS::Internal::Handshake_State_13_Base::confirm_peer_finished_verified ( )
inlineinherited

Once the implementation has successfully verified the peer's Finished message, the handshake is considered complete and successful.

Definition at line 48 of file tls_handshake_state_13.h.

48{ m_peer_finished_verified = true; }

◆ encrypted_extensions()

const Encrypted_Extensions & Botan::TLS::Internal::Handshake_State_13_Base::encrypted_extensions ( ) const
inlineinherited

Definition at line 59 of file tls_handshake_state_13.h.

59{ return get(m_encrypted_extensions); }

Referenced by store().

◆ handshake_finished()

bool Botan::TLS::Internal::Handshake_State_13_Base::handshake_finished ( ) const
inlineinherited

Definition at line 40 of file tls_handshake_state_13.h.

References has_client_finished(), and has_server_finished().

◆ has_certificate_request()

bool Botan::TLS::Internal::Handshake_State_13_Base::has_certificate_request ( ) const
inlineinherited

Definition at line 34 of file tls_handshake_state_13.h.

34{ return m_certificate_request.has_value(); }

◆ has_client_certificate_msg()

bool Botan::TLS::Internal::Handshake_State_13_Base::has_client_certificate_msg ( ) const
inlineinherited

Definition at line 30 of file tls_handshake_state_13.h.

30{ return m_client_certificate.has_value(); }

◆ has_client_finished()

bool Botan::TLS::Internal::Handshake_State_13_Base::has_client_finished ( ) const
inlineinherited

Definition at line 38 of file tls_handshake_state_13.h.

38{ return m_client_finished.has_value(); }

Referenced by handshake_finished().

◆ has_client_hello()

bool Botan::TLS::Internal::Handshake_State_13_Base::has_client_hello ( ) const
inlineinherited

Definition at line 24 of file tls_handshake_state_13.h.

24{ return m_client_hello.has_value(); }

◆ has_hello_retry_request()

bool Botan::TLS::Internal::Handshake_State_13_Base::has_hello_retry_request ( ) const
inlineinherited

Definition at line 32 of file tls_handshake_state_13.h.

32{ return m_hello_retry_request.has_value(); }

Referenced by store().

◆ has_server_certificate_msg()

bool Botan::TLS::Internal::Handshake_State_13_Base::has_server_certificate_msg ( ) const
inlineinherited

Definition at line 28 of file tls_handshake_state_13.h.

28{ return m_server_certificate.has_value(); }

◆ has_server_finished()

bool Botan::TLS::Internal::Handshake_State_13_Base::has_server_finished ( ) const
inlineinherited

Definition at line 36 of file tls_handshake_state_13.h.

36{ return m_server_finished.has_value(); }

Referenced by handshake_finished().

◆ has_server_hello()

bool Botan::TLS::Internal::Handshake_State_13_Base::has_server_hello ( ) const
inlineinherited

Definition at line 26 of file tls_handshake_state_13.h.

26{ return m_server_hello.has_value(); }

◆ hello_retry_request()

const Hello_Retry_Request & Botan::TLS::Internal::Handshake_State_13_Base::hello_retry_request ( ) const
inlineinherited

Definition at line 57 of file tls_handshake_state_13.h.

57{ return get(m_hello_retry_request); }

Referenced by store().

◆ received() [1/2]

template<Connection_Side whoami, typename Outbound_Message_T, typename Inbound_Message_T, typename Inbound_Post_Handshake_Message_T>
decltype(auto) Botan::TLS::Handshake_State_13< whoami, Outbound_Message_T, Inbound_Message_T, Inbound_Post_Handshake_Message_T >::received ( Handshake_Message_13 message)
inline

Definition at line 162 of file tls_handshake_state_13.h.

162 {
163 return std::visit(
165 if constexpr(std::is_constructible_v<Inbound_Message_T, decltype(msg)>) {
167 } else {
168 throw TLS_Exception(AlertType::UnexpectedMessage, "received an illegal handshake message");
169 }
170 },
172 }
Client_Hello_13 & store(Client_Hello_13 client_hello, bool from_peer)

◆ received() [2/2]

template<Connection_Side whoami, typename Outbound_Message_T, typename Inbound_Message_T, typename Inbound_Post_Handshake_Message_T>
decltype(auto) Botan::TLS::Handshake_State_13< whoami, Outbound_Message_T, Inbound_Message_T, Inbound_Post_Handshake_Message_T >::received ( Post_Handshake_Message_13 message)
inline

Definition at line 174 of file tls_handshake_state_13.h.

174 {
175 return std::visit(
178 return msg;
179 } else {
180 throw TLS_Exception(AlertType::UnexpectedMessage, "received an unexpected post-handshake message");
181 }
182 },
184 }

◆ sending() [1/2]

template<Connection_Side whoami, typename Outbound_Message_T, typename Inbound_Message_T, typename Inbound_Post_Handshake_Message_T>
template<typename MsgT>
requires (std::is_constructible_v<Outbound_Message_T, MsgT>)
std::reference_wrapper< MsgT > Botan::TLS::Handshake_State_13< whoami, Outbound_Message_T, Inbound_Message_T, Inbound_Post_Handshake_Message_T >::sending ( MsgT msg)
inline

Definition at line 145 of file tls_handshake_state_13.h.

147 {
149 }

◆ sending() [2/2]

template<Connection_Side whoami, typename Outbound_Message_T, typename Inbound_Message_T, typename Inbound_Post_Handshake_Message_T>
template<typename... MsgTs>
requires (is_generalizable_to<Outbound_Message_T>(message))
decltype(auto) Botan::TLS::Handshake_State_13< whoami, Outbound_Message_T, Inbound_Message_T, Inbound_Post_Handshake_Message_T >::sending ( std::variant< MsgTs... > message)
inline

Definition at line 152 of file tls_handshake_state_13.h.

154 {
155 return std::visit(
157 return sending(std::move(msg));
158 },
160 }
std::reference_wrapper< MsgT > sending(MsgT msg)

◆ server_certificate()

const Certificate_13 & Botan::TLS::Internal::Handshake_State_13_Base::server_certificate ( ) const
inlineinherited

Definition at line 63 of file tls_handshake_state_13.h.

63{ return get(m_server_certificate); }

◆ server_certificate_verify()

const Certificate_Verify_13 & Botan::TLS::Internal::Handshake_State_13_Base::server_certificate_verify ( ) const
inlineinherited

Definition at line 67 of file tls_handshake_state_13.h.

67{ return get(m_server_certificate_verify); }

◆ server_finished()

const Finished_13 & Botan::TLS::Internal::Handshake_State_13_Base::server_finished ( ) const
inlineinherited

Definition at line 71 of file tls_handshake_state_13.h.

71{ return get(m_server_finished); }

◆ server_hello()

const Server_Hello_13 & Botan::TLS::Internal::Handshake_State_13_Base::server_hello ( ) const
inlineinherited

Definition at line 55 of file tls_handshake_state_13.h.

55{ return get(m_server_hello); }

Referenced by store(), and store().

◆ store() [1/10]

Certificate_13 & Botan::TLS::Internal::Handshake_State_13_Base::store ( Certificate_13 certificate,
bool from_peer )
protectedinherited

Definition at line 58 of file tls_handshake_state_13.cpp.

58 {
59 auto& target = ((m_side == Connection_Side::Client) == from_peer) ? m_server_certificate : m_client_certificate;
60 target = std::move(certificate);
61 return target.value();
62}

References Botan::TLS::Client.

◆ store() [2/10]

Certificate_Request_13 & Botan::TLS::Internal::Handshake_State_13_Base::store ( Certificate_Request_13 certificate_request,
bool from_peer )
protectedinherited

Definition at line 52 of file tls_handshake_state_13.cpp.

53 {
54 m_certificate_request = std::move(certificate_request);
55 return m_certificate_request.value();
56}
const Certificate_Request_13 & certificate_request() const

References certificate_request().

◆ store() [3/10]

Certificate_Verify_13 & Botan::TLS::Internal::Handshake_State_13_Base::store ( Certificate_Verify_13 certificate_verify,
bool from_peer )
protectedinherited

Definition at line 64 of file tls_handshake_state_13.cpp.

64 {
65 auto& target =
66 ((m_side == Connection_Side::Client) == from_peer) ? m_server_certificate_verify : m_client_certificate_verify;
67 target = std::move(certificate_verify);
68 return target.value();
69}

References Botan::TLS::Client.

◆ store() [4/10]

Client_Hello_12_Shim & Botan::TLS::Internal::Handshake_State_13_Base::store ( Client_Hello_12_Shim client_hello,
bool from_peer )
protectedinherited

Definition at line 26 of file tls_handshake_state_13.cpp.

26 {
27 m_client_hello_12 = std::move(client_hello);
28 return m_client_hello_12.value();
29}

References client_hello().

◆ store() [5/10]

Client_Hello_13 & Botan::TLS::Internal::Handshake_State_13_Base::store ( Client_Hello_13 client_hello,
bool from_peer )
protectedinherited

Definition at line 15 of file tls_handshake_state_13.cpp.

15 {
16 if(m_client_hello) {
17 // Make sure that the updated Client Hello is compatible to the initial one.
19 m_client_hello->validate_updates(client_hello);
20 }
21
22 m_client_hello = std::move(client_hello);
23 return m_client_hello.value();
24}
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49

References BOTAN_STATE_CHECK, client_hello(), and has_hello_retry_request().

◆ store() [6/10]

Encrypted_Extensions & Botan::TLS::Internal::Handshake_State_13_Base::store ( Encrypted_Extensions encrypted_extensions,
bool from_peer )
protectedinherited

Definition at line 46 of file tls_handshake_state_13.cpp.

47 {
48 m_encrypted_extensions = std::move(encrypted_extensions);
49 return m_encrypted_extensions.value();
50}
const Encrypted_Extensions & encrypted_extensions() const

References encrypted_extensions().

◆ store() [7/10]

Finished_13 & Botan::TLS::Internal::Handshake_State_13_Base::store ( Finished_13 finished,
bool from_peer )
protectedinherited

Definition at line 71 of file tls_handshake_state_13.cpp.

71 {
72 auto& target = ((m_side == Connection_Side::Client) == from_peer) ? m_server_finished : m_client_finished;
73 target = std::move(finished);
74 return target.value();
75}

References Botan::TLS::Client.

◆ store() [8/10]

Hello_Retry_Request & Botan::TLS::Internal::Handshake_State_13_Base::store ( Hello_Retry_Request hello_retry_request,
bool from_peer )
protectedinherited

Definition at line 41 of file tls_handshake_state_13.cpp.

41 {
42 m_hello_retry_request = std::move(hello_retry_request);
43 return m_hello_retry_request.value();
44}
const Hello_Retry_Request & hello_retry_request() const

References hello_retry_request().

◆ store() [9/10]

Server_Hello_12_Shim & Botan::TLS::Internal::Handshake_State_13_Base::store ( Server_Hello_12_Shim server_hello,
bool from_peer )
protectedinherited

Definition at line 36 of file tls_handshake_state_13.cpp.

36 {
37 m_server_hello_12 = std::move(server_hello);
38 return m_server_hello_12.value();
39}

References server_hello().

◆ store() [10/10]

Server_Hello_13 & Botan::TLS::Internal::Handshake_State_13_Base::store ( Server_Hello_13 server_hello,
bool from_peer )
protectedinherited

Definition at line 31 of file tls_handshake_state_13.cpp.

31 {
32 m_server_hello = std::move(server_hello);
33 return m_server_hello.value();
34}

References server_hello().


The documentation for this class was generated from the following file: