Botan 3.3.0
Crypto and TLS for C&
Public Member Functions | List of all members
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 20 of file msg_cert_status.cpp.

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

References Botan::make_uint32().

◆ Certificate_Status() [2/4]

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

Definition at line 39 of file msg_cert_status.cpp.

39 :
40 m_response(ocsp.raw_bits()) {
41 hash.update(io.send(*this));
42}

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 44 of file msg_cert_status.cpp.

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

References 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)

Definition at line 51 of file msg_cert_status.cpp.

51 :
52 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 54 of file msg_cert_status.cpp.

54 {
55 if(m_response.size() > 0xFFFFFF) { // unlikely
56 throw Encoding_Error("OCSP response too long to encode in TLS");
57 }
58
59 const uint32_t response_len = static_cast<uint32_t>(m_response.size());
60
61 std::vector<uint8_t> buf;
62 buf.reserve(1 + 3 + m_response.size());
63 buf.push_back(1); // type OCSP
64 for(size_t i = 1; i < 4; ++i) {
65 buf.push_back(get_byte_var(i, response_len));
66 }
67
68 buf += m_response;
69 return buf;
70}
constexpr uint8_t get_byte_var(size_t byte_num, T input)
Definition loadstor.h:27

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.

◆ type_string()

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

Definition at line 19 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

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 }

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


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