Botan 3.12.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 : uint8_t { 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 &to) 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 541 of file x509_ext.h.

Member Typedef Documentation

◆ DataContainer

◆ RangeContainer

Member Enumeration Documentation

◆ Type

Enumerator
ServiceProviderCode 
TelephoneNumberRange 
TelephoneNumber 

Definition at line 545 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 20 of file asn1_obj.cpp.

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

References encode_into().

Referenced by 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(), Botan::PSS_Params::PSS_Params(), 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 955 of file x509_ext.cpp.

955 {
956 const BER_Object obj = ber.get_next_object();
957
958 if(obj.get_class() != (ASN1_Class::ContextSpecific | ASN1_Class::Constructed)) {
959 throw Decoding_Error(fmt("Unexpected TNEntry class tag {}", static_cast<uint32_t>(obj.get_class())));
960 }
961
962 const uint32_t type_tag = static_cast<uint32_t>(obj.type_tag());
963
964 if(type_tag == ServiceProviderCode) {
965 m_type = ServiceProviderCode;
966 ASN1_String spc_string;
967 BER_Decoder(obj, ber.limits()).decode(spc_string);
968 m_data = std::move(spc_string);
969 } else if(type_tag == TelephoneNumberRange) {
970 m_type = TelephoneNumberRange;
971 m_data = RangeContainer();
972 auto& range_items = std::get<RangeContainer>(m_data);
973 BER_Decoder outer(obj, ber.limits());
974 BER_Decoder list = outer.start_sequence();
975 while(list.more_items()) {
977
978 list.decode(entry.start);
979 if(!is_valid_telephone_number(entry.start)) {
980 throw Decoding_Error(fmt("Invalid TelephoneNumberRange start {}", entry.start.value()));
981 }
982
983 list.decode(entry.count);
984 if(entry.count < 2) {
985 throw Decoding_Error(fmt("Invalid TelephoneNumberRange count {}", entry.count));
986 }
987
988 range_items.emplace_back(std::move(entry));
989 }
990 list.end_cons();
991
992 if(range_items.empty()) {
993 throw Decoding_Error("TelephoneNumberRange is empty");
994 }
995 } else if(type_tag == TelephoneNumber) {
996 m_type = TelephoneNumber;
997 ASN1_String one_string;
998 BER_Decoder(obj, ber.limits()).decode(one_string);
999 if(!is_valid_telephone_number(one_string)) {
1000 throw Decoding_Error(fmt("Invalid TelephoneNumber {}", one_string.value()));
1001 }
1002 m_data = std::move(one_string);
1003 } else {
1004 throw Decoding_Error(fmt("Unexpected TNEntry type code {}", type_tag));
1005 };
1006}
std::vector< TelephoneNumberRangeData > RangeContainer
Definition x509_ext.h:556
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53

References Botan::Constructed, Botan::ContextSpecific, Botan::Cert_Extension::TNAuthList::Entry::TelephoneNumberRangeData::count, Botan::BER_Decoder::decode(), Botan::BER_Decoder::end_cons(), Botan::fmt(), Botan::BER_Object::get_class(), Botan::BER_Decoder::get_next_object(), Botan::BER_Decoder::limits(), Botan::BER_Decoder::more_items(), ServiceProviderCode, Botan::Cert_Extension::TNAuthList::Entry::TelephoneNumberRangeData::start, Botan::BER_Decoder::start_sequence(), TelephoneNumber, TelephoneNumberRange, 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 951 of file x509_ext.cpp.

951 {
952 throw Not_Implemented("TNAuthList extension entry serialization is not supported");
953}

◆ service_provider_code()

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

Definition at line 1020 of file x509_ext.cpp.

1020 {
1022 return std::get<ASN1_String>(m_data).value();
1023}
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49

References BOTAN_STATE_CHECK, ServiceProviderCode, and type().

◆ telephone_number()

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

Definition at line 1030 of file x509_ext.cpp.

1030 {
1032 return std::get<ASN1_String>(m_data).value();
1033}

References BOTAN_STATE_CHECK, TelephoneNumber, and type().

◆ telephone_number_range()

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

Definition at line 1025 of file x509_ext.cpp.

1025 {
1027 return std::get<RangeContainer>(m_data);
1028}

References BOTAN_STATE_CHECK, TelephoneNumberRange, and type().

◆ type()

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

Definition at line 562 of file x509_ext.h.

562{ return m_type; }

Referenced by service_provider_code(), telephone_number(), and telephone_number_range().


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