Botan 3.14.1
Crypto and TLS for C&
Botan::Cert_Extension::ASBlocks::ASIdentifiers Class Referencefinal

#include <x509_ext.h>

Inheritance diagram for Botan::Cert_Extension::ASBlocks::ASIdentifiers:
Botan::ASN1_Object

Public Member Functions

 ASIdentifiers (const std::optional< ASIdentifierChoice > &asnum, const std::optional< ASIdentifierChoice > &rdi)
const std::optional< ASIdentifierChoice > & asnum () const
std::vector< uint8_t > BER_encode () const
void decode_from (BER_Decoder &from) override
void encode_into (DER_Encoder &to) const override
const std::optional< ASIdentifierChoice > & rdi () const

Friends

class ASBlocks

Detailed Description

Definition at line 1367 of file x509_ext.h.

Constructor & Destructor Documentation

◆ ASIdentifiers()

Botan::Cert_Extension::ASBlocks::ASIdentifiers::ASIdentifiers ( const std::optional< ASIdentifierChoice > & asnum,
const std::optional< ASIdentifierChoice > & rdi )
inlineexplicit

Definition at line 1372 of file x509_ext.h.

1373 :
1374 m_asnum(asnum), m_rdi(rdi) {
1375 if(!m_asnum.has_value() && !m_rdi.has_value()) {
1376 throw Decoding_Error("One of asnum, rdi must be present");
1377 }
1378 }
const std::optional< ASIdentifierChoice > & asnum() const
Definition x509_ext.h:1380
const std::optional< ASIdentifierChoice > & rdi() const
Definition x509_ext.h:1382

References asnum(), and rdi().

Referenced by ASBlocks.

Member Function Documentation

◆ asnum()

const std::optional< ASIdentifierChoice > & Botan::Cert_Extension::ASBlocks::ASIdentifiers::asnum ( ) const
inline

◆ 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 21 of file asn1_obj.cpp.

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

References encode_into().

Referenced by decode_from(), Botan::PKCS12::export_to(), 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::PSS_Params::PSS_Params().

◆ decode_from()

void Botan::Cert_Extension::ASBlocks::ASIdentifiers::decode_from ( 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 2714 of file x509_ext.cpp.

2714 {
2715 const ASN1_Type next_tag = from.peek_next_object().type_tag();
2716 if(next_tag != ASN1_Type::Sequence) {
2717 throw Decoding_Error(fmt("Unexpected type for ASIdentifiers {}", static_cast<uint32_t>(next_tag)));
2718 }
2719
2720 BER_Decoder seq_dec = from.start_sequence();
2721
2722 const BER_Object elem_obj = seq_dec.get_next_object();
2723
2724 // asnum, potentially followed by an rdi
2725 if(elem_obj.is_a(0, ASN1_Class::ExplicitContextSpecific)) {
2726 BER_Decoder as_obj_ber = BER_Decoder(elem_obj, seq_dec.limits());
2727 ASIdentifierChoice asnum;
2728 as_obj_ber.decode(asnum).verify_end();
2729 m_asnum = asnum;
2730
2731 const BER_Object rdi_obj = seq_dec.get_next_object();
2732 if(rdi_obj.is_a(1, ASN1_Class::ExplicitContextSpecific)) {
2733 BER_Decoder rdi_obj_ber = BER_Decoder(rdi_obj, seq_dec.limits());
2734 ASIdentifierChoice rdi;
2735 rdi_obj_ber.decode(rdi).verify_end();
2736 m_rdi = rdi;
2737 } else if(rdi_obj.type_tag() != ASN1_Type::NoObject) {
2738 throw Decoding_Error(
2739 fmt("Unexpected type for ASIdentifiers rdi: {}", static_cast<uint32_t>(rdi_obj.type_tag())));
2740 }
2741 } else if(elem_obj.is_a(1, ASN1_Class::ExplicitContextSpecific)) {
2742 // just an rdi
2743 BER_Decoder rdi_obj_ber = BER_Decoder(elem_obj, seq_dec.limits());
2744 ASIdentifierChoice rdi;
2745 rdi_obj_ber.decode(rdi).verify_end();
2746 m_rdi = rdi;
2747 const BER_Object end = seq_dec.get_next_object();
2748 if(end.type_tag() != ASN1_Type::NoObject) {
2749 throw Decoding_Error(
2750 fmt("Unexpected element with type {} in ASIdentifiers", static_cast<uint32_t>(end.type_tag())));
2751 }
2752 } else if(elem_obj.type_tag() == ASN1_Type::NoObject) {
2753 /* RFC 3779 Section 3.2.3.1 -
2754 * "The ASIdentifiers type is a SEQUENCE containing one or more forms of
2755 * autonomous system identifiers"
2756 */
2757 throw Decoding_Error("ASIdentifiers must contain an asnum or rdi element");
2758 } else {
2759 throw Decoding_Error(
2760 fmt("Unexpected element with type {} in ASIdentifiers", static_cast<uint32_t>(elem_obj.type_tag())));
2761 }
2762
2763 seq_dec.end_cons();
2764
2765 if(!m_asnum.has_value() && !m_rdi.has_value()) {
2766 throw Decoding_Error("Invalid encoding for ASIdentifiers");
2767 }
2768}
const BER_Object & peek_next_object()
Definition ber_dec.cpp:510
BER_Object get_next_object()
Definition ber_dec.cpp:521
BER_Decoder start_sequence()
Definition ber_dec.h:279
ASN1_Type type_tag() const
Definition asn1_obj.h:277
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53
ASN1_Type
Definition asn1_obj.h:47

References asnum(), Botan::BER_Decoder::decode(), Botan::BER_Decoder::end_cons(), Botan::ExplicitContextSpecific, Botan::fmt(), Botan::BER_Decoder::get_next_object(), Botan::BER_Object::is_a(), Botan::BER_Decoder::limits(), Botan::NoObject, Botan::BER_Decoder::peek_next_object(), rdi(), Botan::Sequence, Botan::BER_Decoder::start_sequence(), Botan::BER_Object::type_tag(), and Botan::BER_Decoder::verify_end().

◆ encode_into()

void Botan::Cert_Extension::ASBlocks::ASIdentifiers::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 2692 of file x509_ext.cpp.

2692 {
2693 into.start_sequence();
2694
2695 if(!m_asnum.has_value() && !m_rdi.has_value()) {
2696 throw Encoding_Error("One of asnum, rdi must be present");
2697 }
2698
2699 if(m_asnum.has_value()) {
2700 into.start_explicit(0);
2701 into.encode(m_asnum.value());
2702 into.end_explicit();
2703 }
2704
2705 if(m_rdi.has_value()) {
2706 into.start_explicit(1);
2707 into.encode(m_rdi.value());
2708 into.end_explicit();
2709 }
2710
2711 into.end_cons();
2712}

References Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::end_explicit(), Botan::DER_Encoder::start_explicit(), and Botan::DER_Encoder::start_sequence().

◆ rdi()

const std::optional< ASIdentifierChoice > & Botan::Cert_Extension::ASBlocks::ASIdentifiers::rdi ( ) const
inline

Definition at line 1382 of file x509_ext.h.

1382{ return m_rdi; }

Referenced by ASIdentifiers(), decode_from(), and Botan::Cert_Extension::ASBlocks::validate().

◆ ASBlocks

friend class ASBlocks
friend

Definition at line 1385 of file x509_ext.h.

References ASBlocks, and ASIdentifiers().

Referenced by ASBlocks.


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