Botan 3.13.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 1182 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 1187 of file x509_ext.h.

1188 :
1189 m_asnum(asnum), m_rdi(rdi) {
1190 if(!m_asnum.has_value() && !m_rdi.has_value()) {
1191 throw Decoding_Error("One of asnum, rdi must be present");
1192 }
1193 }
const std::optional< ASIdentifierChoice > & asnum() const
Definition x509_ext.h:1195
const std::optional< ASIdentifierChoice > & rdi() const
Definition x509_ext.h:1197

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

2332 {
2333 const ASN1_Type next_tag = from.peek_next_object().type_tag();
2334 if(next_tag != ASN1_Type::Sequence) {
2335 throw Decoding_Error(fmt("Unexpected type for ASIdentifiers {}", static_cast<uint32_t>(next_tag)));
2336 }
2337
2338 BER_Decoder seq_dec = from.start_sequence();
2339
2340 const BER_Object elem_obj = seq_dec.get_next_object();
2341 const uint32_t elem_type_tag = static_cast<uint32_t>(elem_obj.type_tag());
2342
2343 // asnum, potentially followed by an rdi
2344 if(elem_type_tag == 0) {
2345 BER_Decoder as_obj_ber = BER_Decoder(elem_obj, seq_dec.limits());
2346 ASIdentifierChoice asnum;
2347 as_obj_ber.decode(asnum).verify_end();
2348 m_asnum = asnum;
2349
2350 const BER_Object rdi_obj = seq_dec.get_next_object();
2351 const ASN1_Type rdi_type_tag = rdi_obj.type_tag();
2352 if(static_cast<uint32_t>(rdi_type_tag) == 1) {
2353 BER_Decoder rdi_obj_ber = BER_Decoder(rdi_obj, seq_dec.limits());
2354 ASIdentifierChoice rdi;
2355 rdi_obj_ber.decode(rdi).verify_end();
2356 m_rdi = rdi;
2357 } else if(rdi_type_tag != ASN1_Type::NoObject) {
2358 throw Decoding_Error(fmt("Unexpected type for ASIdentifiers rdi: {}", static_cast<uint32_t>(rdi_type_tag)));
2359 }
2360 }
2361
2362 // just an rdi
2363 if(elem_type_tag == 1) {
2364 BER_Decoder rdi_obj_ber = BER_Decoder(elem_obj, seq_dec.limits());
2365 ASIdentifierChoice rdi;
2366 rdi_obj_ber.decode(rdi).verify_end();
2367 m_rdi = rdi;
2368 const BER_Object end = seq_dec.get_next_object();
2369 const ASN1_Type end_type_tag = end.type_tag();
2370 if(end_type_tag != ASN1_Type::NoObject) {
2371 throw Decoding_Error(
2372 fmt("Unexpected element with type {} in ASIdentifiers", static_cast<uint32_t>(end_type_tag)));
2373 }
2374 }
2375
2376 seq_dec.end_cons();
2377
2378 if(!m_asnum.has_value() && !m_rdi.has_value()) {
2379 throw Decoding_Error("Invalid encoding for ASIdentifiers");
2380 }
2381}
const BER_Object & peek_next_object()
Definition ber_dec.cpp:505
BER_Object get_next_object()
Definition ber_dec.cpp:516
BER_Decoder start_sequence()
Definition ber_dec.h:275
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::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 2310 of file x509_ext.cpp.

2310 {
2311 into.start_sequence();
2312
2313 if(!m_asnum.has_value() && !m_rdi.has_value()) {
2314 throw Encoding_Error("One of asnum, rdi must be present");
2315 }
2316
2317 if(m_asnum.has_value()) {
2318 into.start_explicit(0);
2319 into.encode(m_asnum.value());
2320 into.end_explicit();
2321 }
2322
2323 if(m_rdi.has_value()) {
2324 into.start_explicit(1);
2325 into.encode(m_rdi.value());
2326 into.end_explicit();
2327 }
2328
2329 into.end_cons();
2330}

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

1197{ return m_rdi; }

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

◆ ASBlocks

friend class ASBlocks
friend

Definition at line 1200 of file x509_ext.h.

References ASBlocks, and ASIdentifiers().

Referenced by ASBlocks.


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