Botan 3.11.0
Crypto and TLS for C&
Botan::TLS::Certificate_Request_13 Class Referencefinal

#include <tls_messages_13.h>

Inheritance diagram for Botan::TLS::Certificate_Request_13:
Botan::TLS::Handshake_Message

Public Member Functions

std::vector< X509_DNacceptable_CAs () const
 Certificate_Request_13 (const std::vector< uint8_t > &buf, Connection_Side side)
const std::vector< Signature_Scheme > & certificate_signature_schemes () const
const std::vector< uint8_t > & context () const
const Extensionsextensions () const
std::vector< uint8_t > serialize () const override
const std::vector< Signature_Scheme > & signature_schemes () const
Handshake_Type type () const override
std::string type_string () const
virtual Handshake_Type wire_type () const

Static Public Member Functions

static std::optional< Certificate_Request_13maybe_create (const Client_Hello_13 &sni_hostname, Credentials_Manager &cred_mgr, Callbacks &callbacks, const Policy &policy)

Detailed Description

Definition at line 290 of file tls_messages_13.h.

Constructor & Destructor Documentation

◆ Certificate_Request_13()

Botan::TLS::Certificate_Request_13::Certificate_Request_13 ( const std::vector< uint8_t > & buf,
Connection_Side side )

Definition at line 25 of file msg_certificate_req_13.cpp.

25 {
26 TLS_Data_Reader reader("Certificate_Request_13", buf);
27
28 // RFC 8446 4.3.2
29 // A server which is authenticating with a certificate MAY optionally
30 // request a certificate from the client.
31 if(side != Connection_Side::Server) {
32 throw TLS_Exception(Alert::UnexpectedMessage, "Received a Certificate_Request message from a client");
33 }
34
35 m_context = reader.get_tls_length_value(1);
36 m_extensions.deserialize(reader, side, type());
37
38 // RFC 8446 4.3.2
39 // The "signature_algorithms" extension MUST be specified, and other
40 // extensions may optionally be included if defined for this message.
41 // Clients MUST ignore unrecognized extensions.
42
43 if(!m_extensions.has<Signature_Algorithms>()) {
44 throw TLS_Exception(Alert::MissingExtension,
45 "Certificate_Request message did not provide a signature_algorithms extension");
46 }
47
48 // RFC 8446 4.2.
49 // The table below indicates the messages where a given extension may
50 // appear [...]. If an implementation receives an extension which it
51 // recognizes and which is not specified for the message in which it
52 // appears, it MUST abort the handshake with an "illegal_parameter" alert.
53 //
54 // For Certificate Request said table states:
55 // "status_request", "signature_algorithms", "signed_certificate_timestamp",
56 // "certificate_authorities", "oid_filters", "signature_algorithms_cert",
57 const std::set<Extension_Code> allowed_extensions = {
60 // Extension_Code::SignedCertificateTimestamp, // NYI
62 // Extension_Code::OidFilters, // NYI
64 };
65
66 if(m_extensions.contains_implemented_extensions_other_than(allowed_extensions)) {
67 throw TLS_Exception(Alert::IllegalParameter, "Certificate Request contained an extension that is not allowed");
68 }
69}
Handshake_Type type() const override

References Botan::TLS::CertificateAuthorities, Botan::TLS::CertificateStatusRequest, Botan::TLS::CertSignatureAlgorithms, Botan::TLS::TLS_Data_Reader::get_tls_length_value(), Botan::TLS::Server, Botan::TLS::SignatureAlgorithms, and type().

Referenced by maybe_create().

Member Function Documentation

◆ acceptable_CAs()

std::vector< X509_DN > Botan::TLS::Certificate_Request_13::acceptable_CAs ( ) const

Definition at line 127 of file msg_certificate_req_13.cpp.

127 {
128 if(m_extensions.has<Certificate_Authorities>()) {
129 return m_extensions.get<Certificate_Authorities>()->distinguished_names();
130 }
131 return {};
132}

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

◆ certificate_signature_schemes()

const std::vector< Signature_Scheme > & Botan::TLS::Certificate_Request_13::certificate_signature_schemes ( ) const

Definition at line 142 of file msg_certificate_req_13.cpp.

142 {
143 // RFC 8446 4.2.3
144 // If no "signature_algorithms_cert" extension is present, then the
145 // "signature_algorithms" extension also applies to signatures appearing
146 // in certificates.
147 if(auto* sig_schemes_cert = m_extensions.get<Signature_Algorithms_Cert>()) {
148 return sig_schemes_cert->supported_schemes();
149 } else {
150 return signature_schemes();
151 }
152}
const std::vector< Signature_Scheme > & signature_schemes() const

References signature_schemes().

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

◆ context()

const std::vector< uint8_t > & Botan::TLS::Certificate_Request_13::context ( ) const
inline

Definition at line 311 of file tls_messages_13.h.

311{ return m_context; }

◆ extensions()

const Extensions & Botan::TLS::Certificate_Request_13::extensions ( ) const
inline

Definition at line 307 of file tls_messages_13.h.

307{ return m_extensions; }

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

◆ maybe_create()

std::optional< Certificate_Request_13 > Botan::TLS::Certificate_Request_13::maybe_create ( const Client_Hello_13 & sni_hostname,
Credentials_Manager & cred_mgr,
Callbacks & callbacks,
const Policy & policy )
static

Creates a Certificate_Request message if it is required by the configuration

Returns
std::nullopt if configuration does not require client authentication

Definition at line 108 of file msg_certificate_req_13.cpp.

111 {
112 const auto trusted_CAs = cred_mgr.trusted_certificate_authorities("tls-server", client_hello.sni_hostname());
113
114 std::vector<X509_DN> client_auth_CAs;
115 for(auto* const store : trusted_CAs) {
116 const auto subjects = store->all_subjects();
117 client_auth_CAs.insert(client_auth_CAs.end(), subjects.begin(), subjects.end());
118 }
119
120 if(client_auth_CAs.empty() && !policy.request_client_certificate_authentication()) {
121 return std::nullopt;
122 }
123
124 return Certificate_Request_13(client_auth_CAs, policy, callbacks);
125}
Certificate_Request_13(const std::vector< uint8_t > &buf, Connection_Side side)

References Certificate_Request_13(), Botan::TLS::Policy::request_client_certificate_authentication(), Botan::TLS::Client_Hello::sni_hostname(), and Botan::Credentials_Manager::trusted_certificate_authorities().

◆ serialize()

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

Implements Botan::TLS::Handshake_Message.

Definition at line 154 of file msg_certificate_req_13.cpp.

154 {
155 std::vector<uint8_t> buf;
156 append_tls_length_value(buf, m_context, 1);
157 buf += m_extensions.serialize(Connection_Side::Server);
158 return buf;
159}
void append_tls_length_value(std::vector< uint8_t, Alloc > &buf, const T *vals, size_t vals_size, size_t tag_size)
Definition tls_reader.h:177

References Botan::TLS::append_tls_length_value(), and Botan::TLS::Server.

◆ signature_schemes()

const std::vector< Signature_Scheme > & Botan::TLS::Certificate_Request_13::signature_schemes ( ) const

Definition at line 134 of file msg_certificate_req_13.cpp.

134 {
135 // RFC 8446 4.3.2
136 // The "signature_algorithms" extension MUST be specified
137 BOTAN_ASSERT_NOMSG(m_extensions.has<Signature_Algorithms>());
138
139 return m_extensions.get<Signature_Algorithms>()->supported_schemes();
140}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:75

References BOTAN_ASSERT_NOMSG.

Referenced by Botan::TLS::Certificate_13::Certificate_13(), and certificate_signature_schemes().

◆ type()

Handshake_Type Botan::TLS::Certificate_Request_13::type ( ) const
overridevirtual
Returns
the message type

Implements Botan::TLS::Handshake_Message.

Definition at line 21 of file msg_certificate_req_13.cpp.

References Botan::TLS::CertificateRequest.

Referenced by Certificate_Request_13().

◆ 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: