Botan 3.9.0
Crypto and TLS for C&
Botan::Cert_Extension::ASBlocks::ASIdOrRange Class Referencefinal

#include <x509_ext.h>

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

Public Member Functions

 ASIdOrRange ()=default
 ASIdOrRange (asnum_t id)
 ASIdOrRange (asnum_t min, asnum_t max)
std::vector< uint8_t > BER_encode () const
void decode_from (BER_Decoder &from) override
void encode_into (DER_Encoder &to) const override
asnum_t max () const
asnum_t min () const

Detailed Description

Definition at line 793 of file x509_ext.h.

Constructor & Destructor Documentation

◆ ASIdOrRange() [1/3]

Botan::Cert_Extension::ASBlocks::ASIdOrRange::ASIdOrRange ( )
default

◆ ASIdOrRange() [2/3]

Botan::Cert_Extension::ASBlocks::ASIdOrRange::ASIdOrRange ( asnum_t id)
inlineexplicit

Definition at line 804 of file x509_ext.h.

804: m_min(id), m_max(id) {}

◆ ASIdOrRange() [3/3]

Botan::Cert_Extension::ASBlocks::ASIdOrRange::ASIdOrRange ( asnum_t min,
asnum_t max )
inline

Definition at line 806 of file x509_ext.h.

806 : m_min(min), m_max(max) {
807 if(max < min) {
808 throw Decoding_Error("AS range numbers must be sorted");
809 }
810 }

References max(), and min().

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 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::ASBlocks::ASIdOrRange::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 1607 of file x509_ext.cpp.

1607 {
1608 const ASN1_Type next_tag = from.peek_next_object().type_tag();
1609
1610 size_t min = 0;
1611 size_t max = 0;
1612
1613 if(next_tag == ASN1_Type::Integer) {
1614 from.decode(min);
1616 m_max = m_min;
1617 } else if(next_tag == ASN1_Type::Sequence) {
1618 from.start_sequence().decode(min).decode(max).end_cons();
1621 } else {
1622 throw Decoding_Error(fmt("Unexpected type for ASIdOrRange {}", static_cast<uint32_t>(next_tag)));
1623 }
1624}
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53
constexpr RT checked_cast_to(AT i)
Definition int_utils.h:74
ASN1_Type
Definition asn1_obj.h:43

References Botan::checked_cast_to(), Botan::BER_Decoder::decode(), Botan::BER_Decoder::end_cons(), Botan::fmt(), Botan::Integer, max(), min(), Botan::BER_Decoder::peek_next_object(), Botan::Sequence, Botan::BER_Decoder::start_sequence(), and Botan::BER_Object::type_tag().

◆ encode_into()

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

1596 {
1597 if(m_min == m_max) {
1598 into.encode(static_cast<size_t>(m_min));
1599 } else {
1600 if(m_min >= m_max) {
1601 throw Encoding_Error("AS range numbers must be sorted");
1602 }
1603 into.start_sequence().encode(static_cast<size_t>(m_min)).encode(static_cast<size_t>(m_max)).end_cons();
1604 }
1605}

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

◆ max()

asnum_t Botan::Cert_Extension::ASBlocks::ASIdOrRange::max ( ) const
inline

Definition at line 800 of file x509_ext.h.

800{ return m_max; }

Referenced by ASIdOrRange(), and decode_from().

◆ min()

asnum_t Botan::Cert_Extension::ASBlocks::ASIdOrRange::min ( ) const
inline

Definition at line 798 of file x509_ext.h.

798{ return m_min; }

Referenced by ASIdOrRange(), and decode_from().


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