Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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:

## Public Member Functions
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

## Detailed Description

DTLS Hello Verify Request

Definition at line 47 of file tls_messages.h.

## Constructor & Destructor Documentation

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

Definition at line 15 of file msg_hello_verify.cpp.

References Botan::TLS::Protocol_Version::DTLS_V10, and Botan::TLS::Protocol_Version::DTLS_V12.

16 {
17 if(buf.size() < 3)
18 throw Decoding_Error("Hello verify request too small");
19
20 Protocol_Version version(buf[0], buf[1]);
21
22 if(version != Protocol_Version::DTLS_V10 &&
23 version != Protocol_Version::DTLS_V12)
24 {
25 throw Decoding_Error("Unknown version from server in hello verify request");
26 }
27
28 if(static_cast<size_t>(buf[2]) + 3 != buf.size())
29 throw Decoding_Error("Bad length in hello verify request");
30
31 m_cookie.assign(buf.begin() + 3, buf.end());
32 }
Botan::TLS::Protocol_Version::DTLS_V12
Definition: tls_version.h:30
Botan::TLS::Protocol_Version::DTLS_V10
Definition: tls_version.h:29

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 34 of file msg_hello_verify.cpp.

References Botan::MessageAuthenticationCode::create(), and Botan::unlock().

37 {
38 std::unique_ptr<MessageAuthenticationCode> hmac(MessageAuthenticationCode::create("HMAC(SHA-256)"));
39 hmac->set_key(secret_key);
40
41 hmac->update_be(client_hello_bits.size());
42 hmac->update(client_hello_bits);
43 hmac->update_be(client_identity.size());
44 hmac->update(client_identity);
45
46 m_cookie = unlock(hmac->final());
47 }
Botan::MessageAuthenticationCode::create
static std::unique_ptr< MessageAuthenticationCode > create(const std::string &algo_spec, const std::string &provider="")
Definition: mac.cpp:43
Botan::unlock
std::vector< T > unlock(const secure_vector< T > &in)
Definition: secmem.h:125

## Member Function Documentation

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

Definition at line 53 of file tls_messages.h.

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

53 { return m_cookie; }

std::vector< uint8_t > Botan::TLS::Hello_Verify_Request::serialize | ( |  | ) | const
| override virtual

Returns
  DER representation of this message

Implements Botan::TLS::Handshake_Message.

Definition at line 49 of file msg_hello_verify.cpp.

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

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

Handshake_Type Botan::TLS::Hello_Verify_Request::type | ( |  | ) | const
| inline override virtual

Returns
  the message type

Implements Botan::TLS::Handshake_Message.

Definition at line 51 of file tls_messages.h.

References Botan::TLS::HELLO_VERIFY_REQUEST.

51 { return HELLO_VERIFY_REQUEST; }
Botan::TLS::HELLO_VERIFY_REQUEST
Definition: tls_magic.h:42

std::string Botan::TLS::Handshake_Message::type_string | ( |  | ) | const
| inherited

Returns
  string representation of this message type

Definition at line 17 of file tls_handshake_state.cpp.

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

18 {
19 return handshake_type_to_string(type());
20 }
Botan::TLS::Handshake_Message::type
virtual Handshake_Type type() const =0
Botan::TLS::handshake_type_to_string
const char * handshake_type_to_string(Handshake_Type type)
Definition: tls_handshake_state.cpp:22

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

- src/lib/tls/tls_messages.h
- src/lib/tls/msg_hello_verify.cpp