Botan 3.12.0
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 848 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 853 of file x509_ext.h.

854 :
855 m_asnum(asnum), m_rdi(rdi) {
856 if(!m_asnum.has_value() && !m_rdi.has_value()) {
857 throw Decoding_Error("One of asnum, rdi must be present");
858 }
859 }
const std::optional< ASIdentifierChoice > & asnum() const
Definition x509_ext.h:861
const std::optional< ASIdentifierChoice > & rdi() const
Definition x509_ext.h:863

References asnum(), and rdi().

Referenced by ASBlocks.

Member Function Documentation

◆ asnum()

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

Definition at line 861 of file x509_ext.h.

861{ return m_asnum; }

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

◆ 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::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 1683 of file x509_ext.cpp.

1683 {
1684 const ASN1_Type next_tag = from.peek_next_object().type_tag();
1685 if(next_tag != ASN1_Type::Sequence) {
1686 throw Decoding_Error(fmt("Unexpected type for ASIdentifiers {}", static_cast<uint32_t>(next_tag)));
1687 }
1688
1689 BER_Decoder seq_dec = from.start_sequence();
1690
1691 const BER_Object elem_obj = seq_dec.get_next_object();
1692 const uint32_t elem_type_tag = static_cast<uint32_t>(elem_obj.type_tag());
1693
1694 // asnum, potentially followed by an rdi
1695 if(elem_type_tag == 0) {
1696 BER_Decoder as_obj_ber = BER_Decoder(elem_obj, seq_dec.limits());
1697 ASIdentifierChoice asnum;
1698 as_obj_ber.decode(asnum).verify_end();
1699 m_asnum = asnum;
1700
1701 const BER_Object rdi_obj = seq_dec.get_next_object();
1702 const ASN1_Type rdi_type_tag = rdi_obj.type_tag();
1703 if(static_cast<uint32_t>(rdi_type_tag) == 1) {
1704 BER_Decoder rdi_obj_ber = BER_Decoder(rdi_obj, seq_dec.limits());
1705 ASIdentifierChoice rdi;
1706 rdi_obj_ber.decode(rdi).verify_end();
1707 m_rdi = rdi;
1708 } else if(rdi_type_tag != ASN1_Type::NoObject) {
1709 throw Decoding_Error(fmt("Unexpected type for ASIdentifiers rdi: {}", static_cast<uint32_t>(rdi_type_tag)));
1710 }
1711 }
1712
1713 // just an rdi
1714 if(elem_type_tag == 1) {
1715 BER_Decoder rdi_obj_ber = BER_Decoder(elem_obj, seq_dec.limits());
1716 ASIdentifierChoice rdi;
1717 rdi_obj_ber.decode(rdi).verify_end();
1718 m_rdi = rdi;
1719 const BER_Object end = seq_dec.get_next_object();
1720 const ASN1_Type end_type_tag = end.type_tag();
1721 if(end_type_tag != ASN1_Type::NoObject) {
1722 throw Decoding_Error(
1723 fmt("Unexpected element with type {} in ASIdentifiers", static_cast<uint32_t>(end_type_tag)));
1724 }
1725 }
1726
1727 seq_dec.end_cons();
1728
1729 if(!m_asnum.has_value() && !m_rdi.has_value()) {
1730 throw Decoding_Error("Invalid encoding for ASIdentifiers");
1731 }
1732}
const BER_Object & peek_next_object()
Definition ber_dec.cpp:415
BER_Object get_next_object()
Definition ber_dec.cpp:426
BER_Decoder start_sequence()
Definition ber_dec.h:160
ASN1_Type type_tag() const
Definition asn1_obj.h:142
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53
ASN1_Type
Definition asn1_obj.h:43

References asnum(), Botan::BER_Decoder::decode(), Botan::BER_Decoder::end_cons(), Botan::fmt(), Botan::BER_Decoder::get_next_object(), 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 1661 of file x509_ext.cpp.

1661 {
1662 into.start_sequence();
1663
1664 if(!m_asnum.has_value() && !m_rdi.has_value()) {
1665 throw Encoding_Error("One of asnum, rdi must be present");
1666 }
1667
1668 if(m_asnum.has_value()) {
1669 into.start_explicit(0);
1670 into.encode(m_asnum.value());
1671 into.end_explicit();
1672 }
1673
1674 if(m_rdi.has_value()) {
1675 into.start_explicit(1);
1676 into.encode(m_rdi.value());
1677 into.end_explicit();
1678 }
1679
1680 into.end_cons();
1681}

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 863 of file x509_ext.h.

863{ return m_rdi; }

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

◆ ASBlocks

friend class ASBlocks
friend

Definition at line 866 of file x509_ext.h.

References ASBlocks, and ASIdentifiers().

Referenced by ASBlocks.


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