Botan 3.5.0
Crypto and TLS for C&
Botan::TLS::Certificate_Authorities Class Referencefinal

#include <tls_extensions.h>

Inheritance diagram for Botan::TLS::Certificate_Authorities:
Botan::TLS::Extension

Public Member Functions

 Certificate_Authorities (std::vector< X509_DN > acceptable_DNs)
 
 Certificate_Authorities (TLS_Data_Reader &reader, uint16_t extension_size)
 
const std::vector< X509_DN > & distinguished_names () const
 
bool empty () const override
 
virtual bool is_implemented () const
 
std::vector< uint8_t > serialize (Connection_Side whoami) const override
 
Extension_Code type () const override
 

Static Public Member Functions

static Extension_Code static_type ()
 

Detailed Description

Certificate Authorities Extension from RFC 8446 4.2.4

Definition at line 639 of file tls_extensions.h.

Constructor & Destructor Documentation

◆ Certificate_Authorities() [1/2]

Botan::TLS::Certificate_Authorities::Certificate_Authorities ( TLS_Data_Reader & reader,
uint16_t extension_size )

Definition at line 908 of file tls_extensions.cpp.

908 {
909 if(extension_size < 2) {
910 throw Decoding_Error("Empty certificate_authorities extension is illegal");
911 }
912
913 const uint16_t purported_size = reader.get_uint16_t();
914
915 if(reader.remaining_bytes() != purported_size) {
916 throw Decoding_Error("Inconsistent length in certificate_authorities extension");
917 }
918
919 while(reader.has_remaining()) {
920 std::vector<uint8_t> name_bits = reader.get_tls_length_value(2);
921
922 BER_Decoder decoder(name_bits.data(), name_bits.size());
923 m_distinguished_names.emplace_back();
924 decoder.decode(m_distinguished_names.back());
925 }
926}

References Botan::BER_Decoder::decode(), Botan::TLS::TLS_Data_Reader::get_tls_length_value(), Botan::TLS::TLS_Data_Reader::get_uint16_t(), Botan::TLS::TLS_Data_Reader::has_remaining(), and Botan::TLS::TLS_Data_Reader::remaining_bytes().

◆ Certificate_Authorities() [2/2]

Botan::TLS::Certificate_Authorities::Certificate_Authorities ( std::vector< X509_DN > acceptable_DNs)
explicit

Definition at line 928 of file tls_extensions.cpp.

928 :
929 m_distinguished_names(std::move(acceptable_DNs)) {}

Member Function Documentation

◆ distinguished_names()

const std::vector< X509_DN > & Botan::TLS::Certificate_Authorities::distinguished_names ( ) const
inline

Definition at line 649 of file tls_extensions.h.

649{ return m_distinguished_names; }

◆ empty()

bool Botan::TLS::Certificate_Authorities::empty ( ) const
inlineoverridevirtual
Returns
if we should encode this extension or not

Implements Botan::TLS::Extension.

Definition at line 647 of file tls_extensions.h.

647{ return m_distinguished_names.empty(); }

◆ is_implemented()

virtual bool Botan::TLS::Extension::is_implemented ( ) const
inlinevirtualinherited
Returns
true if this extension is known and implemented by Botan

Reimplemented in Botan::TLS::Unknown_Extension.

Definition at line 116 of file tls_extensions.h.

116{ return true; }

◆ serialize()

std::vector< uint8_t > Botan::TLS::Certificate_Authorities::serialize ( Connection_Side whoami) const
overridevirtual
Returns
serialized binary for the extension

Implements Botan::TLS::Extension.

Definition at line 892 of file tls_extensions.cpp.

892 {
893 std::vector<uint8_t> out;
894 std::vector<uint8_t> dn_list;
895
896 for(const auto& dn : m_distinguished_names) {
897 std::vector<uint8_t> encoded_dn;
898 auto encoder = DER_Encoder(encoded_dn);
899 dn.encode_into(encoder);
900 append_tls_length_value(dn_list, encoded_dn, 2);
901 }
902
903 append_tls_length_value(out, dn_list, 2);
904
905 return out;
906}
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:180

References Botan::TLS::append_tls_length_value().

◆ static_type()

static Extension_Code Botan::TLS::Certificate_Authorities::static_type ( )
inlinestatic

Definition at line 641 of file tls_extensions.h.

◆ type()

Extension_Code Botan::TLS::Certificate_Authorities::type ( ) const
inlineoverridevirtual
Returns
code number of the extension

Implements Botan::TLS::Extension.

Definition at line 643 of file tls_extensions.h.

643{ return static_type(); }
static Extension_Code static_type()

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