Botan 3.11.0
Crypto and TLS for C&
Botan::TLS::Certificate_Status Class Reference

#include <tls_messages.h>

Inheritance diagram for Botan::TLS::Certificate_Status:
Botan::TLS::Handshake_Message Botan::TLS::Certificate_Status_12

Public Member Functions

 Certificate_Status (const std::vector< uint8_t > &buf, Connection_Side from)
 Certificate_Status (std::vector< uint8_t > raw_response_bytes)
const std::vector< uint8_t > & response () const
std::vector< uint8_t > serialize () const final
Handshake_Type type () const final
std::string type_string () const
virtual Handshake_Type wire_type () const

Detailed Description

Certificate Status (RFC 6066)

Definition at line 233 of file tls_messages.h.

Constructor & Destructor Documentation

◆ Certificate_Status() [1/2]

Botan::TLS::Certificate_Status::Certificate_Status ( const std::vector< uint8_t > & buf,
Connection_Side from )
explicit

Definition at line 14 of file msg_cert_status.cpp.

14 {
15 if(buf.size() < 5) {
16 throw Decoding_Error("Invalid Certificate_Status message: too small");
17 }
18
19 if(buf[0] != 1) { // not OCSP
20 throw Decoding_Error("Unexpected Certificate_Status message: unexpected response type");
21 }
22
23 const size_t len = make_uint32(0, buf[1], buf[2], buf[3]);
24
25 // Verify the redundant length field...
26 if(buf.size() != len + 4) {
27 throw Decoding_Error("Invalid Certificate_Status: invalid length field");
28 }
29
30 m_response.assign(buf.begin() + 4, buf.end());
31}
constexpr uint32_t make_uint32(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3)
Definition loadstor.h:104

References Botan::make_uint32().

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

◆ Certificate_Status() [2/2]

Botan::TLS::Certificate_Status::Certificate_Status ( std::vector< uint8_t > raw_response_bytes)
explicit

Definition at line 33 of file msg_cert_status.cpp.

33 :
34 m_response(std::move(raw_response_bytes)) {}

Member Function Documentation

◆ response()

const std::vector< uint8_t > & Botan::TLS::Certificate_Status::response ( ) const
inline

Definition at line 239 of file tls_messages.h.

239{ return m_response; }

◆ serialize()

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

Implements Botan::TLS::Handshake_Message.

Definition at line 36 of file msg_cert_status.cpp.

36 {
37 if(m_response.size() > 0xFFFFFF) { // unlikely
38 throw Encoding_Error("OCSP response too long to encode in TLS");
39 }
40
41 const uint32_t response_len = static_cast<uint32_t>(m_response.size());
42
43 std::vector<uint8_t> buf;
44 buf.reserve(1 + 3 + m_response.size());
45 buf.push_back(1); // type OCSP
46 for(size_t i = 1; i < 4; ++i) {
47 buf.push_back(get_byte_var(i, response_len));
48 }
49
50 buf.insert(buf.end(), m_response.begin(), m_response.end());
51 return buf;
52}
constexpr uint8_t get_byte_var(size_t byte_num, T input)
Definition loadstor.h:69

References Botan::get_byte_var().

◆ type()

Handshake_Type Botan::TLS::Certificate_Status::type ( ) const
inlinefinalvirtual
Returns
the message type

Implements Botan::TLS::Handshake_Message.

Definition at line 235 of file tls_messages.h.

References Botan::TLS::CertificateStatus.

◆ type_string()

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

Definition at line 21 of file tls_handshake_state.cpp.

21 {
23}
virtual Handshake_Type type() const =0
const char * handshake_type_to_string(Handshake_Type type)
Definition tls_magic.cpp:15

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

◆ wire_type()

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

Reimplemented in Botan::TLS::Hello_Retry_Request.

Definition at line 39 of file tls_handshake_msg.h.

39 {
40 // Usually equal to the Handshake_Type enum value,
41 // with the exception of TLS 1.3 Hello Retry Request.
42 return type();
43 }

References type().

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


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