Botan 3.9.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 832 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 837 of file x509_ext.h.

838 :
839 m_asnum(asnum), m_rdi(rdi) {
840 if(!m_asnum.has_value() && !m_rdi.has_value()) {
841 throw Decoding_Error("One of asnum, rdi must be present");
842 }
843 }
const std::optional< ASIdentifierChoice > & asnum() const
Definition x509_ext.h:845
const std::optional< ASIdentifierChoice > & rdi() const
Definition x509_ext.h:847

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

845{ 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 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::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 1522 of file x509_ext.cpp.

1522 {
1523 const ASN1_Type next_tag = from.peek_next_object().type_tag();
1524 if(next_tag != ASN1_Type::Sequence) {
1525 throw Decoding_Error(fmt("Unexpected type for ASIdentifiers {}", static_cast<uint32_t>(next_tag)));
1526 }
1527
1528 BER_Decoder seq_dec = from.start_sequence();
1529
1530 const BER_Object elem_obj = seq_dec.get_next_object();
1531 const uint32_t elem_type_tag = static_cast<uint32_t>(elem_obj.type_tag());
1532
1533 // asnum, potentially followed by an rdi
1534 if(elem_type_tag == 0) {
1535 BER_Decoder as_obj_ber = BER_Decoder(elem_obj);
1536 ASIdentifierChoice asnum;
1537 as_obj_ber.decode(asnum);
1538 m_asnum = asnum;
1539
1540 const BER_Object rdi_obj = seq_dec.get_next_object();
1541 const ASN1_Type rdi_type_tag = rdi_obj.type_tag();
1542 if(static_cast<uint32_t>(rdi_type_tag) == 1) {
1543 BER_Decoder rdi_obj_ber = BER_Decoder(rdi_obj);
1544 ASIdentifierChoice rdi;
1545 rdi_obj_ber.decode(rdi);
1546 m_rdi = rdi;
1547 } else if(rdi_type_tag != ASN1_Type::NoObject) {
1548 throw Decoding_Error(fmt("Unexpected type for ASIdentifiers rdi: {}", static_cast<uint32_t>(rdi_type_tag)));
1549 }
1550 }
1551
1552 // just an rdi
1553 if(elem_type_tag == 1) {
1554 BER_Decoder rdi_obj_ber = BER_Decoder(elem_obj);
1555 ASIdentifierChoice rdi;
1556 rdi_obj_ber.decode(rdi);
1557 m_rdi = rdi;
1558 const BER_Object end = seq_dec.get_next_object();
1559 const ASN1_Type end_type_tag = end.type_tag();
1560 if(end_type_tag != ASN1_Type::NoObject) {
1561 throw Decoding_Error(
1562 fmt("Unexpected element with type {} in ASIdentifiers", static_cast<uint32_t>(end_type_tag)));
1563 }
1564 }
1565
1566 seq_dec.end_cons();
1567}
const BER_Object & peek_next_object()
Definition ber_dec.cpp:237
BER_Object get_next_object()
Definition ber_dec.cpp:248
BER_Decoder start_sequence()
Definition ber_dec.h:125
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::NoObject, Botan::BER_Decoder::peek_next_object(), rdi(), Botan::Sequence, Botan::BER_Decoder::start_sequence(), and Botan::BER_Object::type_tag().

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

1500 {
1501 into.start_sequence();
1502
1503 if(!m_asnum.has_value() && !m_rdi.has_value()) {
1504 throw Encoding_Error("One of asnum, rdi must be present");
1505 }
1506
1507 if(m_asnum.has_value()) {
1508 into.start_explicit(0);
1509 into.encode(m_asnum.value());
1510 into.end_explicit();
1511 }
1512
1513 if(m_rdi.has_value()) {
1514 into.start_explicit(1);
1515 into.encode(m_rdi.value());
1516 into.end_explicit();
1517 }
1518
1519 into.end_cons();
1520}

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

847{ return m_rdi; }

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

◆ ASBlocks

friend class ASBlocks
friend

Definition at line 850 of file x509_ext.h.

References ASBlocks, and ASIdentifiers().

Referenced by ASBlocks.


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