Botan
1.11.15
|
#include <tls_heartbeats.h>
Public Types | |
enum | Type { REQUEST = 1, RESPONSE = 2 } |
Public Member Functions | |
std::vector< byte > | contents () const |
Heartbeat_Message (const std::vector< byte > &buf) | |
Heartbeat_Message (Type type, const byte payload[], size_t payload_len, const std::vector< byte > &padding) | |
bool | is_request () const |
const std::vector< byte > & | payload () const |
TLS Heartbeat message
Definition at line 20 of file tls_heartbeats.h.
Definition at line 23 of file tls_heartbeats.h.
Botan::TLS::Heartbeat_Message::Heartbeat_Message | ( | const std::vector< byte > & | buf | ) |
Definition at line 17 of file tls_heartbeats.cpp.
References Botan::TLS::TLS_Data_Reader::get_byte(), Botan::TLS::TLS_Data_Reader::get_range(), Botan::TLS::TLS_Data_Reader::get_remaining(), and Botan::TLS::Alert::ILLEGAL_PARAMETER.
{ TLS_Data_Reader reader("Heartbeat", buf); const byte type = reader.get_byte(); if(type != 1 && type != 2) throw TLS_Exception(Alert::ILLEGAL_PARAMETER, "Unknown heartbeat message type"); m_type = static_cast<Type>(type); m_payload = reader.get_range<byte>(2, 0, 16*1024); m_padding = reader.get_remaining(); if(m_padding.size() < 16) throw Decoding_Error("Invalid heartbeat padding"); }
Botan::TLS::Heartbeat_Message::Heartbeat_Message | ( | Type | type, |
const byte | payload[], | ||
size_t | payload_len, | ||
const std::vector< byte > & | padding | ||
) |
Definition at line 37 of file tls_heartbeats.cpp.
std::vector< byte > Botan::TLS::Heartbeat_Message::contents | ( | ) | const |
Definition at line 51 of file tls_heartbeats.cpp.
Referenced by Botan::TLS::Channel::heartbeat().
{ //std::vector<byte> send_buf(3 + m_payload.size() + 16); std::vector<byte> send_buf; send_buf.reserve(3 + m_payload.size() + m_padding.size()); send_buf.push_back(m_type); send_buf.push_back(get_byte<u16bit>(0, m_payload.size())); send_buf.push_back(get_byte<u16bit>(1, m_payload.size())); send_buf += m_payload; send_buf += m_padding; return send_buf; }
bool Botan::TLS::Heartbeat_Message::is_request | ( | ) | const [inline] |
Definition at line 29 of file tls_heartbeats.h.
References REQUEST.
Referenced by Botan::TLS::Channel::received_data().
{ return m_type == REQUEST; }
const std::vector<byte>& Botan::TLS::Heartbeat_Message::payload | ( | ) | const [inline] |
Definition at line 27 of file tls_heartbeats.h.
Referenced by Botan::TLS::Channel::received_data().
{ return m_payload; }