Botan 3.5.0
Crypto and TLS for C&
Botan::Cert_Extension::TNAuthList::Entry Class Referencefinal

#include <x509_ext.h>

Inheritance diagram for Botan::Cert_Extension::TNAuthList::Entry:
Botan::ASN1_Object

Classes

struct  TelephoneNumberRangeData
 

Public Types

using DataContainer = std::variant<ASN1_String, RangeContainer>
 
using RangeContainer = std::vector<TelephoneNumberRangeData>
 
enum  Type { ServiceProviderCode = 0 , TelephoneNumberRange = 1 , TelephoneNumber = 2 }
 

Public Member Functions

std::vector< uint8_t > BER_encode () const
 
void decode_from (class BER_Decoder &from) override
 
void encode_into (DER_Encoder &) const override
 
const std::string & service_provider_code () const
 
const std::string & telephone_number () const
 
const RangeContainertelephone_number_range () const
 
Type type () const
 

Detailed Description

Definition at line 511 of file x509_ext.h.

Member Typedef Documentation

◆ DataContainer

◆ RangeContainer

Member Enumeration Documentation

◆ Type

Enumerator
ServiceProviderCode 
TelephoneNumberRange 
TelephoneNumber 

Definition at line 515 of file x509_ext.h.

Member Function Documentation

◆ BER_encode()

std::vector< uint8_t > Botan::ASN1_Object::BER_encode ( ) const
inherited

Return the encoding of this object. This is a convenience method when just one object needs to be serialized. Use DER_Encoder for complicated encodings.

Definition at line 19 of file asn1_obj.cpp.

19 {
20 std::vector<uint8_t> output;
21 DER_Encoder der(output);
22 this->encode_into(der);
23 return output;
24}
virtual void encode_into(DER_Encoder &to) const =0

References Botan::ASN1_Object::encode_into().

Referenced by Botan::PSS_Params::decode_from(), Botan::Certificate_Store_In_SQL::find_all_certs(), Botan::Certificate_Store_In_SQL::find_cert(), Botan::X509_Certificate::fingerprint(), Botan::Certificate_Store_In_SQL::insert_cert(), Botan::X509_Object::PEM_encode(), and Botan::Certificate_Store_In_SQL::revoke_cert().

◆ decode_from()

void Botan::Cert_Extension::TNAuthList::Entry::decode_from ( class BER_Decoder & from)
overridevirtual

Decode whatever this object is from from

Parameters
fromthe BER_Decoder that will be read from

Implements Botan::ASN1_Object.

Definition at line 791 of file x509_ext.cpp.

791 {
792 BER_Object obj = ber.get_next_object();
793
794 const uint32_t type_tag = static_cast<Type>(obj.type_tag());
795
796 if(type_tag == ServiceProviderCode) {
797 m_type = ServiceProviderCode;
798 ASN1_String spc_string;
799 BER_Decoder(obj).decode(spc_string);
800 m_data = std::move(spc_string);
801 } else if(type_tag == TelephoneNumberRange) {
802 m_type = TelephoneNumberRange;
803 m_data = RangeContainer();
804 auto& range_items = std::get<RangeContainer>(m_data);
805 BER_Decoder list = BER_Decoder(obj).start_sequence();
806 while(list.more_items()) {
807 TelephoneNumberRangeData entry;
808
809 list.decode(entry.start);
810 if(!is_valid_telephone_number(entry.start)) {
811 throw Decoding_Error(fmt("Invalid TelephoneNumberRange start {}", entry.start.value()));
812 }
813
814 list.decode(entry.count);
815 if(entry.count < 2) {
816 throw Decoding_Error(fmt("Invalid TelephoneNumberRange count {}", entry.count));
817 }
818
819 range_items.emplace_back(std::move(entry));
820 }
821 list.end_cons();
822
823 if(range_items.empty()) {
824 throw Decoding_Error("TelephoneNumberRange is empty");
825 }
826 } else if(type_tag == TelephoneNumber) {
827 m_type = TelephoneNumber;
828 ASN1_String one_string;
829 BER_Decoder(obj).decode(one_string);
830 if(!is_valid_telephone_number(one_string)) {
831 throw Decoding_Error(fmt("Invalid TelephoneNumber {}", one_string.value()));
832 }
833 m_data = std::move(one_string);
834 } else {
835 throw Decoding_Error(fmt("Unexpected TNEntry type code {}", type_tag));
836 };
837}
std::vector< TelephoneNumberRangeData > RangeContainer
Definition x509_ext.h:522
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53

References Botan::Cert_Extension::TNAuthList::Entry::TelephoneNumberRangeData::count, Botan::BER_Decoder::decode(), Botan::BER_Decoder::end_cons(), Botan::fmt(), Botan::BER_Decoder::get_next_object(), Botan::BER_Decoder::more_items(), Botan::Cert_Extension::TNAuthList::Entry::TelephoneNumberRangeData::start, Botan::BER_Decoder::start_sequence(), Botan::BER_Object::type_tag(), and Botan::ASN1_String::value().

◆ encode_into()

void Botan::Cert_Extension::TNAuthList::Entry::encode_into ( DER_Encoder & to) const
overridevirtual

Encode whatever this object is into to

Parameters
tothe DER_Encoder that will be written to

Implements Botan::ASN1_Object.

Definition at line 787 of file x509_ext.cpp.

787 {
788 throw Not_Implemented("TNAuthList extension entry serialization is not supported");
789}

◆ service_provider_code()

const std::string & Botan::Cert_Extension::TNAuthList::Entry::service_provider_code ( ) const
inline

Definition at line 530 of file x509_ext.h.

530 {
532 return std::get<ASN1_String>(m_data).value();
533 }
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:41

References BOTAN_STATE_CHECK.

◆ telephone_number()

const std::string & Botan::Cert_Extension::TNAuthList::Entry::telephone_number ( ) const
inline

Definition at line 540 of file x509_ext.h.

540 {
542 return std::get<ASN1_String>(m_data).value();
543 }

References BOTAN_STATE_CHECK.

◆ telephone_number_range()

const RangeContainer & Botan::Cert_Extension::TNAuthList::Entry::telephone_number_range ( ) const
inline

Definition at line 535 of file x509_ext.h.

535 {
537 return std::get<RangeContainer>(m_data);
538 }

References BOTAN_STATE_CHECK.

◆ type()

Type Botan::Cert_Extension::TNAuthList::Entry::type ( ) const
inline

Definition at line 528 of file x509_ext.h.

528{ return m_type; }

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