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

#include <x509_ext.h>

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

Public Member Functions

 ASIdentifierChoice ()=default
 ASIdentifierChoice (const std::optional< std::vector< ASIdOrRange > > &ranges)
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< std::vector< ASIdOrRange > > & ranges () const

Detailed Description

Definition at line 1352 of file x509_ext.h.

Constructor & Destructor Documentation

◆ ASIdentifierChoice() [1/2]

Botan::Cert_Extension::ASBlocks::ASIdentifierChoice::ASIdentifierChoice ( )
default

References ASIdentifierChoice(), and ranges().

Referenced by ASIdentifierChoice().

◆ ASIdentifierChoice() [2/2]

Botan::Cert_Extension::ASBlocks::ASIdentifierChoice::ASIdentifierChoice ( const std::optional< std::vector< ASIdOrRange > > & ranges)
explicit

Definition at line 2778 of file x509_ext.cpp.

2778 {
2779 m_as_ranges = sort_and_merge_ranges<ASIdOrRange>(ranges);
2780}
const std::optional< std::vector< ASIdOrRange > > & ranges() const
Definition x509_ext.h:1361

References ranges().

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 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::ASIdentifierChoice::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 2782 of file x509_ext.cpp.

2782 {
2783 const ASN1_Type next_tag = from.peek_next_object().type_tag();
2784
2785 if(next_tag == ASN1_Type::Null) {
2786 from.decode_null();
2787 m_as_ranges = std::nullopt;
2788 } else if(next_tag == ASN1_Type::Sequence) {
2789 std::vector<ASIdOrRange> as_ranges;
2790 from.decode_list(as_ranges);
2791
2792 /* RFC 3779 Section 3.2.3.4 -
2793 * "Any pair of items in the asIdsOrRanges SEQUENCE MUST NOT overlap.
2794 * Any contiguous series of AS identifiers MUST be combined into a
2795 * single range whenever possible. The AS identifiers in the
2796 * asIdsOrRanges element MUST be sorted by increasing numeric value."
2797 */
2798 if(!ranges_are_sorted_and_merged(as_ranges)) {
2799 throw Decoding_Error("ASIdentifierChoice entries must be sorted, non-overlapping and fully merged");
2800 }
2801 m_as_ranges = std::move(as_ranges);
2802 } else {
2803 throw Decoding_Error(fmt("Unexpected type for ASIdentifierChoice {}", static_cast<uint32_t>(next_tag)));
2804 }
2805}
const BER_Object & peek_next_object()
Definition ber_dec.cpp:510
BER_Decoder & decode_null()
Definition ber_dec.cpp:688
BER_Decoder & decode_list(std::vector< T > &vec, ASN1_Type type_tag=ASN1_Type::Sequence, ASN1_Class class_tag=ASN1_Class::Universal)
Definition ber_dec.h:895
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 Botan::BER_Decoder::decode_list(), Botan::BER_Decoder::decode_null(), Botan::fmt(), Botan::Null, Botan::BER_Decoder::peek_next_object(), Botan::Sequence, and Botan::BER_Object::type_tag().

◆ encode_into()

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

2770 {
2771 if(m_as_ranges.has_value()) {
2772 into.start_sequence().encode_list(m_as_ranges.value()).end_cons();
2773 } else {
2774 into.encode_null();
2775 }
2776}

References Botan::DER_Encoder::encode_list(), Botan::DER_Encoder::encode_null(), Botan::DER_Encoder::end_cons(), and Botan::DER_Encoder::start_sequence().

◆ ranges()

const std::optional< std::vector< ASIdOrRange > > & Botan::Cert_Extension::ASBlocks::ASIdentifierChoice::ranges ( ) const
inline

Definition at line 1361 of file x509_ext.h.

1361{ return m_as_ranges; }

Referenced by ASIdentifierChoice(), and ASIdentifierChoice().


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