Botan 3.14.1
Crypto and TLS for C&
Botan::TLS::Certificate_Request_12 Class Referencefinal

#include <tls_messages_12.h>

Inheritance diagram for Botan::TLS::Certificate_Request_12:
Botan::TLS::Handshake_Message

Public Member Functions

const std::vector< X509_DN > & acceptable_CAs () const
const std::vector< std::string > & acceptable_cert_types () const
 Certificate_Request_12 (Certificate_Request_12 &&)=delete
 Certificate_Request_12 (const Certificate_Request_12 &)=delete
 Certificate_Request_12 (Handshake_IO &io, Handshake_Hash &hash, const Policy &policy, std::vector< X509_DN > allowed_cas)
 Certificate_Request_12 (std::span< const uint8_t > buf)
Certificate_Request_12 & operator= (Certificate_Request_12 &&other)=delete
Certificate_Request_12 & operator= (const Certificate_Request_12 &other)=delete
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
 ~Certificate_Request_12 () override

Detailed Description

Certificate Request Message (TLS 1.2)

Definition at line 246 of file tls_messages_12.h.

Constructor & Destructor Documentation

◆ Certificate_Request_12() [1/4]

Botan::TLS::Certificate_Request_12::Certificate_Request_12 ( Handshake_IO & io,
Handshake_Hash & hash,
const Policy & policy,
std::vector< X509_DN > ca_certs )

Create a new Certificate Request message

Definition at line 59 of file msg_certificate_req_12.cpp.

62 :
63 m_names(std::move(ca_certs)), m_cert_key_types({"RSA", "ECDSA"}) {
64 for(const auto scheme : policy.acceptable_signature_schemes()) {
65 if(scheme.is_compatible_with(Protocol_Version::TLS_V12)) {
66 m_schemes.push_back(scheme);
67 }
68 }
69 // RFC 5246 7.4.4: supported_signature_algorithms<2..2^16-2>
70 if(m_schemes.empty()) {
71 throw Internal_Error("Policy returned no acceptable signature schemes for CertificateRequest");
72 }
73 hash.update(io.send(*this));
74}

Referenced by Certificate_Request_12(), Certificate_Request_12(), operator=(), and operator=().

◆ Certificate_Request_12() [2/4]

Botan::TLS::Certificate_Request_12::Certificate_Request_12 ( std::span< const uint8_t > buf)
explicit

Deserialize a Certificate Request message

Definition at line 79 of file msg_certificate_req_12.cpp.

79 {
80 if(buf.size() < 4) {
81 throw Decoding_Error("Certificate_Req: Bad certificate request");
82 }
83
84 TLS_Data_Reader reader("CertificateRequest", buf);
85
86 const auto cert_type_codes = reader.get_range_vector<uint8_t>(1, 1, 255);
87
88 for(const auto cert_type_code : cert_type_codes) {
89 const std::string cert_type_name = cert_type_code_to_name(cert_type_code);
90
91 if(cert_type_name.empty()) { // something we don't know
92 continue;
93 }
94
95 m_cert_key_types.emplace_back(cert_type_name);
96 }
97
98 const std::vector<uint8_t> algs = reader.get_range_vector<uint8_t>(2, 2, 65534);
99
100 if(algs.size() % 2 != 0) {
101 throw Decoding_Error("Bad length for signature IDs in certificate request");
102 }
103
104 for(size_t i = 0; i != algs.size(); i += 2) {
105 m_schemes.emplace_back(make_uint16(algs[i], algs[i + 1]));
106 }
107
108 const uint16_t purported_size = reader.get_uint16_t();
109
110 if(reader.remaining_bytes() != purported_size) {
111 throw Decoding_Error("Inconsistent length in certificate request");
112 }
113
114 while(reader.has_remaining()) {
115 // RFC 5246 7.4.4: opaque DistinguishedName<1..2^16-1>
116 std::vector<uint8_t> name_bits = reader.get_range_vector<uint8_t>(2, 1, 65535);
117
118 BER_Decoder decoder(name_bits, BER_Decoder::Limits::DER());
119 X509_DN name;
120 decoder.decode(name).verify_end();
121 m_names.emplace_back(name);
122 }
123}
static Limits DER()
Definition ber_dec.h:44
const char * name
Definition ffi_tls.h:59
constexpr uint16_t make_uint16(uint8_t i0, uint8_t i1)
Definition loadstor.h:92

References Botan::BER_Decoder::Limits::DER(), Botan::TLS::TLS_Data_Reader::get_range_vector(), Botan::TLS::TLS_Data_Reader::get_uint16_t(), Botan::TLS::TLS_Data_Reader::has_remaining(), Botan::make_uint16(), name, and Botan::TLS::TLS_Data_Reader::remaining_bytes().

◆ ~Certificate_Request_12()

Botan::TLS::Certificate_Request_12::~Certificate_Request_12 ( )
overridedefault

◆ Certificate_Request_12() [3/4]

Botan::TLS::Certificate_Request_12::Certificate_Request_12 ( const Certificate_Request_12 & )
delete

◆ Certificate_Request_12() [4/4]

Botan::TLS::Certificate_Request_12::Certificate_Request_12 ( Certificate_Request_12 && )
delete

Member Function Documentation

◆ acceptable_CAs()

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

Definition at line 129 of file msg_certificate_req_12.cpp.

129 {
130 return m_names;
131}

◆ acceptable_cert_types()

const std::vector< std::string > & Botan::TLS::Certificate_Request_12::acceptable_cert_types ( ) const

Definition at line 125 of file msg_certificate_req_12.cpp.

125 {
126 return m_cert_key_types;
127}

◆ operator=() [1/2]

Certificate_Request_12 & Botan::TLS::Certificate_Request_12::operator= ( Certificate_Request_12 && other)
delete

◆ operator=() [2/2]

Certificate_Request_12 & Botan::TLS::Certificate_Request_12::operator= ( const Certificate_Request_12 & other)
delete

◆ serialize()

std::vector< uint8_t > Botan::TLS::Certificate_Request_12::serialize ( ) const
overridevirtual

Serialize a Certificate Request message

Implements Botan::TLS::Handshake_Message.

Definition at line 140 of file msg_certificate_req_12.cpp.

140 {
141 std::vector<uint8_t> buf;
142
143 std::vector<uint8_t> cert_types;
144
145 cert_types.reserve(m_cert_key_types.size());
146 for(const auto& cert_key_type : m_cert_key_types) {
147 cert_types.push_back(cert_type_name_to_code(cert_key_type));
148 }
149
150 append_tls_length_value(buf, cert_types, 1);
151
152 // RFC 5246 7.4.4: supported_signature_algorithms<2..2^16-2>
153 buf += Signature_Algorithms(m_schemes).serialize(Connection_Side::Server);
154
155 std::vector<uint8_t> encoded_names;
156
157 for(const auto& name : m_names) {
158 DER_Encoder encoder;
159 encoder.encode(name);
160
161 append_tls_length_value(encoded_names, encoder.get_contents(), 2);
162 }
163
164 append_tls_length_value(buf, encoded_names, 2);
165
166 return buf;
167}
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:182

References Botan::TLS::append_tls_length_value(), Botan::DER_Encoder::encode(), Botan::DER_Encoder::get_contents(), name, Botan::TLS::Signature_Algorithms::serialize(), and Botan::TLS::Server.

Referenced by operator=().

◆ signature_schemes()

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

Definition at line 133 of file msg_certificate_req_12.cpp.

133 {
134 return m_schemes;
135}

Referenced by Botan::TLS::Handshake_State::choose_sig_format(), and Botan::TLS::Handshake_State::parse_sig_format().

◆ type()

Handshake_Type Botan::TLS::Certificate_Request_12::type ( ) const
overridevirtual

Return the TLS handshake type code

Returns
the message type

Implements Botan::TLS::Handshake_Message.

Definition at line 26 of file msg_certificate_req_12.cpp.

References Botan::TLS::CertificateRequest.

◆ type_string()

std::string Botan::TLS::Handshake_Message::type_string ( ) const
inherited

Return a free-form string describing this message type

Returns
string representation of this message type

Definition at line 22 of file tls_handshake_state.cpp.

22 {
24}
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

Return the wire encoding of the message type code

Note
This is usually equal to type with the exception of a TLS 1.3 Helloy Retry Request.
Returns
the wire representation of the message's type

Reimplemented in Botan::TLS::Hello_Retry_Request.

Definition at line 47 of file tls_handshake_msg.h.

47{ return type(); }

References type().

Referenced by Botan::TLS::Stream_Handshake_IO::send(), and Botan::TLS::Handshake_Layer::update_transcript_for_psk_binder_calc().


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