Botan 3.0.0-alpha0
Crypto and TLS for C&
Public Member Functions | List of all members
Botan::TLS::Hello_Verify_Request Class Referencefinal

#include <tls_messages.h>

Inheritance diagram for Botan::TLS::Hello_Verify_Request:
Botan::TLS::Handshake_Message

Public Member Functions

const std::vector< uint8_t > & cookie () const
 
 Hello_Verify_Request (const std::vector< uint8_t > &buf)
 
 Hello_Verify_Request (const std::vector< uint8_t > &client_hello_bits, const std::string &client_identity, const SymmetricKey &secret_key)
 
std::vector< uint8_t > serialize () const override
 
Handshake_Type type () const override
 
std::string type_string () const
 
virtual Handshake_Type wire_type () const
 

Detailed Description

DTLS Hello Verify Request

Definition at line 56 of file tls_messages.h.

Constructor & Destructor Documentation

◆ Hello_Verify_Request() [1/2]

Botan::TLS::Hello_Verify_Request::Hello_Verify_Request ( const std::vector< uint8_t > &  buf)
explicit

Definition at line 13 of file msg_hello_verify.cpp.

14 {
15 if(buf.size() < 3)
16 throw Decoding_Error("Hello verify request too small");
17
18 Protocol_Version version(buf[0], buf[1]);
19
20 if(!version.is_datagram_protocol())
21 {
22 throw Decoding_Error("Unknown version from server in hello verify request");
23 }
24
25 if(static_cast<size_t>(buf[2]) + 3 != buf.size())
26 throw Decoding_Error("Bad length in hello verify request");
27
28 m_cookie.assign(buf.begin() + 3, buf.end());
29 }

References Botan::TLS::Protocol_Version::is_datagram_protocol().

◆ Hello_Verify_Request() [2/2]

Botan::TLS::Hello_Verify_Request::Hello_Verify_Request ( const std::vector< uint8_t > &  client_hello_bits,
const std::string &  client_identity,
const SymmetricKey secret_key 
)

Definition at line 31 of file msg_hello_verify.cpp.

34 {
35 std::unique_ptr<MessageAuthenticationCode> hmac = MessageAuthenticationCode::create_or_throw("HMAC(SHA-256)");
36 hmac->set_key(secret_key);
37
38 hmac->update_be(static_cast<uint64_t>(client_hello_bits.size()));
39 hmac->update(client_hello_bits);
40 hmac->update_be(static_cast<uint64_t>(client_identity.size()));
41 hmac->update(client_identity);
42
43 m_cookie.resize(hmac->output_length());
44 hmac->final(m_cookie.data());
45 }
static std::unique_ptr< MessageAuthenticationCode > create_or_throw(const std::string &algo_spec, const std::string &provider="")
Definition: mac.cpp:134

References Botan::MessageAuthenticationCode::create_or_throw().

Member Function Documentation

◆ cookie()

const std::vector< uint8_t > & Botan::TLS::Hello_Verify_Request::cookie ( ) const
inline

Definition at line 62 of file tls_messages.h.

62{ return m_cookie; }

Referenced by Botan::TLS::Client_Hello_12::update_hello_cookie().

◆ serialize()

std::vector< uint8_t > Botan::TLS::Hello_Verify_Request::serialize ( ) const
overridevirtual
Returns
DER representation of this message

Implements Botan::TLS::Handshake_Message.

Definition at line 47 of file msg_hello_verify.cpp.

48 {
49 /* DTLS 1.2 server implementations SHOULD use DTLS version 1.0
50 regardless of the version of TLS that is expected to be
51 negotiated (RFC 6347, section 4.2.1)
52 */
53
54 Protocol_Version format_version(254, 255); // DTLS 1.0
55
56 std::vector<uint8_t> bits;
57 bits.push_back(format_version.major_version());
58 bits.push_back(format_version.minor_version());
59 bits.push_back(static_cast<uint8_t>(m_cookie.size()));
60 bits += m_cookie;
61 return bits;
62 }

References Botan::TLS::Protocol_Version::major_version(), and Botan::TLS::Protocol_Version::minor_version().

◆ type()

Handshake_Type Botan::TLS::Hello_Verify_Request::type ( ) const
inlineoverridevirtual
Returns
the message type

Implements Botan::TLS::Handshake_Message.

Definition at line 60 of file tls_messages.h.

60{ return HELLO_VERIFY_REQUEST; }
@ HELLO_VERIFY_REQUEST
Definition: tls_magic.h:67

References Botan::TLS::HELLO_VERIFY_REQUEST.

◆ type_string()

std::string Botan::TLS::Handshake_Message::type_string ( ) const
inherited
Returns
string representation of this message type

Definition at line 18 of file tls_handshake_state.cpp.

19 {
21 }
virtual Handshake_Type type() const =0
const char * handshake_type_to_string(Handshake_Type type)

References Botan::TLS::handshake_type_to_string(), and Botan::TLS::Handshake_Message::type().

◆ wire_type()

virtual Handshake_Type Botan::TLS::Handshake_Message::wire_type ( ) const
inlinevirtualinherited
Returns
the wire representation of the message's type

Definition at line 42 of file tls_handshake_msg.h.

43 {
44 // Usually equal to the Handshake_Type enum value,
45 // with the exception of TLS 1.3 Hello Retry Request.
46 return type();
47 }

References type.

Referenced by Botan::TLS::Stream_Handshake_IO::send().


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