Botan 3.10.0
Crypto and TLS for C&
Botan::TLS::Certificate_Status Class Referencefinal

#include <tls_messages.h>

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

Public Member Functions

 Certificate_Status (const std::vector< uint8_t > &buf, Connection_Side from)
 Certificate_Status (Handshake_IO &io, Handshake_Hash &hash, const OCSP::Response &response)
 Certificate_Status (Handshake_IO &io, Handshake_Hash &hash, std::vector< uint8_t > raw_response_bytes)
 Certificate_Status (std::vector< uint8_t > raw_response_bytes)
const std::vector< uint8_t > & response () const
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

Certificate Status (RFC 6066)

Definition at line 670 of file tls_messages.h.

Constructor & Destructor Documentation

◆ Certificate_Status() [1/4]

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

Definition at line 17 of file msg_cert_status.cpp.

17 {
18 if(buf.size() < 5) {
19 throw Decoding_Error("Invalid Certificate_Status message: too small");
20 }
21
22 if(buf[0] != 1) { // not OCSP
23 throw Decoding_Error("Unexpected Certificate_Status message: unexpected response type");
24 }
25
26 size_t len = make_uint32(0, buf[1], buf[2], buf[3]);
27
28 // Verify the redundant length field...
29 if(buf.size() != len + 4) {
30 throw Decoding_Error("Invalid Certificate_Status: invalid length field");
31 }
32
33 m_response.assign(buf.begin() + 4, buf.end());
34}
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 Certificate_Status().

◆ Certificate_Status() [2/4]

Botan::TLS::Certificate_Status::Certificate_Status ( Handshake_IO & io,
Handshake_Hash & hash,
const OCSP::Response & response )

Definition at line 36 of file msg_cert_status.cpp.

36 :
37 m_response(ocsp.raw_bits()) {
38 hash.update(io.send(*this));
39}

References Botan::TLS::Handshake_IO::send(), and Botan::TLS::Handshake_Hash::update().

◆ Certificate_Status() [3/4]

Botan::TLS::Certificate_Status::Certificate_Status ( Handshake_IO & io,
Handshake_Hash & hash,
std::vector< uint8_t > raw_response_bytes )

Definition at line 41 of file msg_cert_status.cpp.

43 :
44 Certificate_Status(std::move(raw_response_bytes)) {
45 hash.update(io.send(*this));
46}
Certificate_Status(const std::vector< uint8_t > &buf, Connection_Side from)

References Certificate_Status(), Botan::TLS::Handshake_IO::send(), and Botan::TLS::Handshake_Hash::update().

◆ Certificate_Status() [4/4]

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

Definition at line 48 of file msg_cert_status.cpp.

48 :
49 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 676 of file tls_messages.h.

676{ return m_response; }

◆ serialize()

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

Implements Botan::TLS::Handshake_Message.

Definition at line 51 of file msg_cert_status.cpp.

51 {
52 if(m_response.size() > 0xFFFFFF) { // unlikely
53 throw Encoding_Error("OCSP response too long to encode in TLS");
54 }
55
56 const uint32_t response_len = static_cast<uint32_t>(m_response.size());
57
58 std::vector<uint8_t> buf;
59 buf.reserve(1 + 3 + m_response.size());
60 buf.push_back(1); // type OCSP
61 for(size_t i = 1; i < 4; ++i) {
62 buf.push_back(get_byte_var(i, response_len));
63 }
64
65 buf += m_response;
66 return buf;
67}
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
inlineoverridevirtual
Returns
the message type

Implements Botan::TLS::Handshake_Message.

Definition at line 672 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 18 of file tls_handshake_state.cpp.

18 {
20}
virtual Handshake_Type type() const =0
const char * handshake_type_to_string(Handshake_Type type)

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: