Botan 3.13.0
Crypto and TLS for C&
Botan::TLS::Certificate_Status_Request Class Referencefinal

#include <tls_extensions.h>

Inheritance diagram for Botan::TLS::Certificate_Status_Request:
Botan::TLS::Extension

Public Member Functions

 Certificate_Status_Request ()
 Certificate_Status_Request (std::vector< uint8_t > ocsp_responder_ids, std::vector< std::vector< uint8_t > > ocsp_key_ids)
 Certificate_Status_Request (std::vector< uint8_t > response)
 Certificate_Status_Request (TLS_Data_Reader &reader, uint16_t extension_size, Handshake_Type message_type, Connection_Side from)
bool empty () const override
const std::vector< uint8_t > & get_ocsp_response () const
const std::vector< uint8_t > & get_request_extensions () const
const std::vector< uint8_t > & get_responder_id_list () const
virtual bool is_implemented () const
std::vector< uint8_t > serialize (Connection_Side whoami) const override
Extension_Code type () const override
 ~Certificate_Status_Request () override

Static Public Member Functions

static Extension_Code static_type ()

Detailed Description

Certificate Status Request (RFC 6066)

Definition at line 359 of file tls_extensions.h.

Constructor & Destructor Documentation

◆ Certificate_Status_Request() [1/4]

Botan::TLS::Certificate_Status_Request::Certificate_Status_Request ( )

Definition at line 165 of file tls_extensions_cert_status_req.cpp.

165 :
166 m_impl(std::make_unique<Certificate_Status_Request_Internal>(RFC6066_Empty_Certificate_Status_Request())) {}

Referenced by get_request_extensions().

◆ Certificate_Status_Request() [2/4]

Botan::TLS::Certificate_Status_Request::Certificate_Status_Request ( std::vector< uint8_t > ocsp_responder_ids,
std::vector< std::vector< uint8_t > > ocsp_key_ids )

Definition at line 168 of file tls_extensions_cert_status_req.cpp.

169 :
170 m_impl(std::make_unique<Certificate_Status_Request_Internal>(
171 RFC6066_Certificate_Status_Request(std::move(ocsp_responder_ids), std::move(ocsp_key_ids)))) {}

◆ Certificate_Status_Request() [3/4]

Botan::TLS::Certificate_Status_Request::Certificate_Status_Request ( std::vector< uint8_t > response)
explicit

Definition at line 173 of file tls_extensions_cert_status_req.cpp.

173 :
174 m_impl(std::make_unique<Certificate_Status_Request_Internal>(Certificate_Status(std::move(response)))) {}

◆ Certificate_Status_Request() [4/4]

Botan::TLS::Certificate_Status_Request::Certificate_Status_Request ( TLS_Data_Reader & reader,
uint16_t extension_size,
Handshake_Type message_type,
Connection_Side from )

Definition at line 101 of file tls_extensions_cert_status_req.cpp.

104 {
105 // This parser needs to take TLS 1.2 and TLS 1.3 into account. The
106 // extension's content and structure is dependent on the context it
107 // was sent in (i.e. the enclosing handshake message). Below is a list
108 // of handshake messages this can appear in.
109 //
110 // TLS 1.2
111 // * Client Hello
112 // * Server Hello
113 //
114 // TLS 1.3
115 // * Client Hello
116 // * Certificate Request
117 // * Certificate (Entry)
118
119 // RFC 6066 8.
120 // In order to indicate their desire to receive certificate status
121 // information, clients MAY include an extension of type "status_request"
122 // in the (extended) client hello.
123 if(message_type == Handshake_Type::ClientHello) {
124 m_impl = std::make_unique<Certificate_Status_Request_Internal>(
125 RFC6066_Certificate_Status_Request(reader, extension_size));
126 }
127
128 // RFC 6066 8.
129 // If a server returns a "CertificateStatus" message, then the server MUST
130 // have included an extension of type "status_request" with empty
131 // "extension_data" in the extended server hello.
132 //
133 // RFC 8446 4.4.2.1
134 // A server MAY request that a client present an OCSP response with its
135 // certificate by sending an empty "status_request" extension in its
136 // CertificateRequest message.
137 else if(message_type == Handshake_Type::ServerHello || message_type == Handshake_Type::CertificateRequest) {
138 m_impl = std::make_unique<Certificate_Status_Request_Internal>(
139 RFC6066_Empty_Certificate_Status_Request(extension_size));
140 }
141
142 // RFC 8446 4.4.2.1
143 // In TLS 1.3, the server's OCSP information is carried in an extension
144 // in the CertificateEntry [in a Certificate handshake message] [...].
145 // Specifically, the body of the "status_request" extension from the
146 // server MUST be a CertificateStatus structure as defined in [RFC6066]
147 // [...].
148 //
149 // RFC 8446 4.4.2.1
150 // If the client opts to send an OCSP response, the body of its
151 // "status_request" extension MUST be a CertificateStatus structure as
152 // defined in [RFC6066].
153 else if(message_type == Handshake_Type::Certificate) {
154 m_impl = std::make_unique<Certificate_Status_Request_Internal>(
155 Certificate_Status(reader.get_fixed<uint8_t>(extension_size), from));
156 }
157
158 // all other contexts are not allowed for this extension
159 else {
160 throw TLS_Exception(Alert::UnsupportedExtension,
161 "Server sent a Certificate_Status_Request extension in an unsupported context");
162 }
163}

References Botan::TLS::Certificate, Botan::TLS::CertificateRequest, Botan::TLS::ClientHello, Botan::TLS::TLS_Data_Reader::get_fixed(), and Botan::TLS::ServerHello.

◆ ~Certificate_Status_Request()

Botan::TLS::Certificate_Status_Request::~Certificate_Status_Request ( )
overridedefault

Member Function Documentation

◆ empty()

bool Botan::TLS::Certificate_Status_Request::empty ( ) const
inlineoverridevirtual

Predicate if a TLS extension should be included or not

Returns
true if this extension should be encoded, otherwise false

Implements Botan::TLS::Extension.

Definition at line 367 of file tls_extensions.h.

367{ return false; }

◆ get_ocsp_response()

const std::vector< uint8_t > & Botan::TLS::Certificate_Status_Request::get_ocsp_response ( ) const

Definition at line 178 of file tls_extensions_cert_status_req.cpp.

178 {
179 BOTAN_ASSERT_NONNULL(m_impl);
180 BOTAN_STATE_CHECK(std::holds_alternative<Certificate_Status>(m_impl->content));
181 return std::get<Certificate_Status>(m_impl->content).response();
182}
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:114

References BOTAN_ASSERT_NONNULL, and BOTAN_STATE_CHECK.

Referenced by get_request_extensions().

◆ get_request_extensions()

const std::vector< uint8_t > & Botan::TLS::Certificate_Status_Request::get_request_extensions ( ) const

◆ get_responder_id_list()

const std::vector< uint8_t > & Botan::TLS::Certificate_Status_Request::get_responder_id_list ( ) const

◆ is_implemented()

virtual bool Botan::TLS::Extension::is_implemented ( ) const
inlinevirtualinherited

Predicate if the extension is known/implemented

Note
this exists primarily to support unknown extension handling and doesn't need to be overridden even in the custom extension case.
Returns
true if this extension is known

Reimplemented in Botan::TLS::Unknown_Extension.

Definition at line 113 of file tls_extensions.h.

113{ return true; }

◆ serialize()

std::vector< uint8_t > Botan::TLS::Certificate_Status_Request::serialize ( Connection_Side whoami) const
overridevirtual

Serialize a TLS extension

Parameters
whoamiwhich peer we are acting as in the protocol
Returns
serialized binary for the extension

Implements Botan::TLS::Extension.

Definition at line 184 of file tls_extensions_cert_status_req.cpp.

184 {
185 BOTAN_ASSERT_NONNULL(m_impl);
186 return std::visit([](const auto& c) { return c.serialize(); }, m_impl->content);
187}

References BOTAN_ASSERT_NONNULL.

◆ static_type()

Extension_Code Botan::TLS::Certificate_Status_Request::static_type ( )
inlinestatic

◆ type()

Extension_Code Botan::TLS::Certificate_Status_Request::type ( ) const
inlineoverridevirtual

Return TLS extension code

Returns
code number of the extension

Implements Botan::TLS::Extension.

Definition at line 363 of file tls_extensions.h.

363{ return static_type(); }

References static_type().


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