Botan 2.19.5 Crypto and TLS for C&

Public Member Functions | List of all members
Botan::TLS::Certificate_Req Class Referencefinal

`#include <tls_messages.h>`

Inheritance diagram for Botan::TLS::Certificate_Req:

## Public Member Functions
const std::vector< X509_DN > & | acceptable_CAs () const
const std::vector< std::string > & | acceptable_cert_types () const
| Certificate_Req (const std::vector< uint8_t > &buf, Protocol_Version version)
| Certificate_Req (Handshake_IO &io, Handshake_Hash &hash, const Policy &policy, const std::vector< X509_DN > &allowed_cas, Protocol_Version version)
const std::vector< Signature_Scheme > & | signature_schemes () const
Handshake_Type | type () const override
std::string | type_string () const

## Detailed Description

Certificate Request Message

Definition at line 425 of file tls_messages.h.

## Constructor & Destructor Documentation

## ◆ Certificate_Req() [1/2]

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

Create a new Certificate Request message

Definition at line 54 of file msg_cert_req.cpp.

58 :
59 m_names(ca_certs),
60 m_cert_key_types({ "RSA", "ECDSA", "DSA" })
61 {
62 if(version.supports_negotiable_signature_algorithms())
63 {
64 m_schemes = policy.allowed_signature_schemes();
65 }
66
67 hash.update(io.send(*this));
68 }
hash
MechanismType hash
Definition: p11_mechanism.cpp:64

## ◆ Certificate_Req() [2/2]

Botan::TLS::Certificate_Req::Certificate_Req | ( | const std::vector< uint8_t > & | buf,
|  | Protocol_Version | version
| ) |  |

Deserialize a Certificate Request message

Definition at line 73 of file msg_cert_req.cpp.

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

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(), name, Botan::TLS::TLS_Data_Reader::remaining_bytes(), and Botan::TLS::Protocol_Version::supports_negotiable_signature_algorithms().

## Member Function Documentation

## ◆ acceptable_CAs()

const std::vector< X509_DN > & Botan::TLS::Certificate_Req::acceptable_CAs | ( |  | ) | const
| inline

Definition at line 433 of file tls_messages.h.

433{ return m_names; }

## ◆ acceptable_cert_types()

const std::vector< std::string > & Botan::TLS::Certificate_Req::acceptable_cert_types | ( |  | ) | const
| inline

Definition at line 430 of file tls_messages.h.

431 { return m_cert_key_types; }

## ◆ signature_schemes()

const std::vector< Signature_Scheme > & Botan::TLS::Certificate_Req::signature_schemes | ( |  | ) | const
| inline

Definition at line 435 of file tls_messages.h.

436 {
437 return m_schemes;
438 }

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

## ◆ type()

Handshake_Type Botan::TLS::Certificate_Req::type | ( |  | ) | const
| inline override virtual

Returns
  the message type

Implements Botan::TLS::Handshake_Message.

Definition at line 428 of file tls_messages.h.

428{ return CERTIFICATE_REQUEST; }
Botan::TLS::CERTIFICATE_REQUEST
@ CERTIFICATE_REQUEST
Definition: tls_magic.h:53

References Botan::TLS::CERTIFICATE_REQUEST.

## ◆ type_string()

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

Returns
  string representation of this message type

Definition at line 19 of file tls_handshake_state.cpp.

20 {
21 return handshake_type_to_string(type());
22 }
Botan::TLS::Handshake_Message::type
virtual Handshake_Type type() const =0
Botan::TLS::handshake_type_to_string
const char * handshake_type_to_string(Handshake_Type type)
Definition: tls_handshake_state.cpp:24

References Botan::TLS::handshake_type_to_string(), and Botan::TLS::Handshake_Message::type().

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

- src/lib/tls/tls_messages.h
- src/lib/tls/msg_cert_req.cpp