Botan 3.12.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 // RFC 5246 7.4.4: supported_signature_algorithms<2..2^16-2>
66 if(m_schemes.empty()) {
67 throw Internal_Error("Policy returned no acceptable signature schemes for CertificateRequest");
68 }
69 hash.update(io.send(*this));
70}

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

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

125 {
126 return m_names;
127}

◆ acceptable_cert_types()

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

Definition at line 121 of file msg_certificate_req_12.cpp.

121 {
122 return m_cert_key_types;
123}

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

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

129 {
130 return m_schemes;
131}

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: