Botan 3.11.0
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 (const std::vector< uint8_t > &buf)
 Certificate_Request_12 (Handshake_IO &io, Handshake_Hash &hash, const Policy &policy, const std::vector< X509_DN > &allowed_cas)
Certificate_Request_12operator= (Certificate_Request_12 &&other)=delete
Certificate_Request_12operator= (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 232 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,
const 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(ca_certs), m_cert_key_types({"RSA", "ECDSA"}) {
64 m_schemes = policy.acceptable_signature_schemes();
65 hash.update(io.send(*this));
66}

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

◆ Certificate_Request_12() [2/4]

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

Deserialize a Certificate Request message

Definition at line 71 of file msg_certificate_req_12.cpp.

71 {
72 if(buf.size() < 4) {
73 throw Decoding_Error("Certificate_Req: Bad certificate request");
74 }
75
76 TLS_Data_Reader reader("CertificateRequest", buf);
77
78 const auto cert_type_codes = reader.get_range_vector<uint8_t>(1, 1, 255);
79
80 for(const auto cert_type_code : cert_type_codes) {
81 const std::string cert_type_name = cert_type_code_to_name(cert_type_code);
82
83 if(cert_type_name.empty()) { // something we don't know
84 continue;
85 }
86
87 m_cert_key_types.emplace_back(cert_type_name);
88 }
89
90 const std::vector<uint8_t> algs = reader.get_range_vector<uint8_t>(2, 2, 65534);
91
92 if(algs.size() % 2 != 0) {
93 throw Decoding_Error("Bad length for signature IDs in certificate request");
94 }
95
96 for(size_t i = 0; i != algs.size(); i += 2) {
97 m_schemes.emplace_back(make_uint16(algs[i], algs[i + 1]));
98 }
99
100 const uint16_t purported_size = reader.get_uint16_t();
101
102 if(reader.remaining_bytes() != purported_size) {
103 throw Decoding_Error("Inconsistent length in certificate request");
104 }
105
106 while(reader.has_remaining()) {
107 std::vector<uint8_t> name_bits = reader.get_range_vector<uint8_t>(2, 0, 65535);
108
109 BER_Decoder decoder(name_bits.data(), name_bits.size());
110 X509_DN name;
111 decoder.decode(name);
112 m_names.emplace_back(name);
113 }
114}
constexpr uint16_t make_uint16(uint8_t i0, uint8_t i1)
Definition loadstor.h:92

References 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(), 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 120 of file msg_certificate_req_12.cpp.

120 {
121 return m_names;
122}

◆ acceptable_cert_types()

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

Definition at line 116 of file msg_certificate_req_12.cpp.

116 {
117 return m_cert_key_types;
118}

◆ 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 131 of file msg_certificate_req_12.cpp.

131 {
132 std::vector<uint8_t> buf;
133
134 std::vector<uint8_t> cert_types;
135
136 cert_types.reserve(m_cert_key_types.size());
137 for(const auto& cert_key_type : m_cert_key_types) {
138 cert_types.push_back(cert_type_name_to_code(cert_key_type));
139 }
140
141 append_tls_length_value(buf, cert_types, 1);
142
143 if(!m_schemes.empty()) {
144 buf += Signature_Algorithms(m_schemes).serialize(Connection_Side::Server);
145 }
146
147 std::vector<uint8_t> encoded_names;
148
149 for(const auto& name : m_names) {
150 DER_Encoder encoder;
151 encoder.encode(name);
152
153 append_tls_length_value(encoded_names, encoder.get_contents(), 2);
154 }
155
156 append_tls_length_value(buf, encoded_names, 2);
157
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(), Botan::DER_Encoder::encode(), Botan::DER_Encoder::get_contents(), 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 124 of file msg_certificate_req_12.cpp.

124 {
125 return m_schemes;
126}

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