Botan 3.6.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
 
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_12store (Client_Hello_12 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_12store (Server_Hello_12 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 134 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

Definition at line 136 of file tls_handshake_state_13.h.

Member Function Documentation

◆ certificate_request()

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

Definition at line 56 of file tls_handshake_state_13.h.

56{ return get(m_certificate_request); }

Referenced by Botan::TLS::Internal::Handshake_State_13_Base::store().

◆ client_certificate()

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

Definition at line 60 of file tls_handshake_state_13.h.

60{ 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 64 of file tls_handshake_state_13.h.

64{ 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 68 of file tls_handshake_state_13.h.

68{ return get(m_client_finished); }

◆ client_hello() [1/2]

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

◆ client_hello() [2/2]

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

Definition at line 48 of file tls_handshake_state_13.h.

48{ return get(m_client_hello); }

◆ encrypted_extensions()

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

Definition at line 54 of file tls_handshake_state_13.h.

54{ return get(m_encrypted_extensions); }

Referenced by Botan::TLS::Client_Impl_13::application_protocol(), and Botan::TLS::Internal::Handshake_State_13_Base::store().

◆ handshake_finished()

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

◆ has_certificate_request()

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

Definition at line 37 of file tls_handshake_state_13.h.

37{ 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 33 of file tls_handshake_state_13.h.

33{ 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 41 of file tls_handshake_state_13.h.

41{ return m_client_finished.has_value(); }

◆ has_client_hello()

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

Definition at line 27 of file tls_handshake_state_13.h.

27{ 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 35 of file tls_handshake_state_13.h.

35{ return m_hello_retry_request.has_value(); }

Referenced by Botan::TLS::Internal::Handshake_State_13_Base::store().

◆ has_server_certificate_msg()

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

Definition at line 31 of file tls_handshake_state_13.h.

31{ return m_server_certificate.has_value(); }

Referenced by Botan::TLS::Client_Impl_13::peer_cert_chain(), and Botan::TLS::Client_Impl_13::peer_raw_public_key().

◆ has_server_finished()

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

Definition at line 39 of file tls_handshake_state_13.h.

39{ return m_server_finished.has_value(); }

◆ has_server_hello()

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

Definition at line 29 of file tls_handshake_state_13.h.

29{ 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 52 of file tls_handshake_state_13.h.

52{ return get(m_hello_retry_request); }

Referenced by Botan::TLS::Internal::Handshake_State_13_Base::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 154 of file tls_handshake_state_13.h.

154 {
155 return std::visit(
156 [&](auto msg) -> as_wrapped_references_t<Inbound_Message_T> {
157 if constexpr(std::is_constructible_v<Inbound_Message_T, decltype(msg)>) {
158 return std::reference_wrapper<decltype(msg)>(store(std::move(msg), true));
159 } else {
160 throw TLS_Exception(AlertType::UnexpectedMessage, "received an illegal handshake message");
161 }
162 },
163 std::move(message));
164 }
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 166 of file tls_handshake_state_13.h.

166 {
167 return std::visit(
168 [](auto msg) -> Inbound_Post_Handshake_Message_T {
169 if constexpr(std::is_constructible_v<Inbound_Post_Handshake_Message_T, decltype(msg)>) {
170 return msg;
171 } else {
172 throw TLS_Exception(AlertType::UnexpectedMessage, "received an unexpected post-handshake message");
173 }
174 },
175 std::move(message));
176 }

◆ 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 139 of file tls_handshake_state_13.h.

141 {
142 return std::reference_wrapper<decltype(msg)>(store(std::move(msg), false));
143 }

Referenced by Botan::TLS::Client_Impl_13::Client_Impl_13().

◆ 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 146 of file tls_handshake_state_13.h.

148 {
149 return std::visit(
150 [&](auto msg) -> as_wrapped_references_t<std::variant<MsgTs...>> { return sending(std::move(msg)); },
151 std::move(message));
152 }
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 58 of file tls_handshake_state_13.h.

58{ return get(m_server_certificate); }

Referenced by Botan::TLS::Client_Impl_13::peer_cert_chain(), and Botan::TLS::Client_Impl_13::peer_raw_public_key().

◆ server_certificate_verify()

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

Definition at line 62 of file tls_handshake_state_13.h.

62{ 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 66 of file tls_handshake_state_13.h.

66{ return get(m_server_finished); }

◆ server_hello()

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

◆ store() [1/10]

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

Definition at line 54 of file tls_handshake_state_13.cpp.

54 {
55 auto& target = ((m_side == Connection_Side::Client) == from_peer) ? m_server_certificate : m_client_certificate;
56 target = std::move(certificate);
57 return target.value();
58}

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 49 of file tls_handshake_state_13.cpp.

49 {
50 m_certificate_request = std::move(certificate_request);
51 return m_certificate_request.value();
52}
const Certificate_Request_13 & certificate_request() const

References Botan::TLS::Internal::Handshake_State_13_Base::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 60 of file tls_handshake_state_13.cpp.

60 {
61 auto& target =
62 ((m_side == Connection_Side::Client) == from_peer) ? m_server_certificate_verify : m_client_certificate_verify;
63 target = std::move(certificate_verify);
64 return target.value();
65}

References Botan::TLS::Client.

◆ store() [4/10]

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

Definition at line 24 of file tls_handshake_state_13.cpp.

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

References Botan::TLS::Internal::Handshake_State_13_Base::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 13 of file tls_handshake_state_13.cpp.

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

References BOTAN_STATE_CHECK, Botan::TLS::Internal::Handshake_State_13_Base::client_hello(), and Botan::TLS::Internal::Handshake_State_13_Base::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 44 of file tls_handshake_state_13.cpp.

44 {
45 m_encrypted_extensions = std::move(encrypted_extensions);
46 return m_encrypted_extensions.value();
47}
const Encrypted_Extensions & encrypted_extensions() const

References Botan::TLS::Internal::Handshake_State_13_Base::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 67 of file tls_handshake_state_13.cpp.

67 {
68 auto& target = ((m_side == Connection_Side::Client) == from_peer) ? m_server_finished : m_client_finished;
69 target = std::move(finished);
70 return target.value();
71}

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 39 of file tls_handshake_state_13.cpp.

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

References Botan::TLS::Internal::Handshake_State_13_Base::hello_retry_request().

◆ store() [9/10]

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

Definition at line 34 of file tls_handshake_state_13.cpp.

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

References Botan::TLS::Internal::Handshake_State_13_Base::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 29 of file tls_handshake_state_13.cpp.

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

References Botan::TLS::Internal::Handshake_State_13_Base::server_hello().


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