Botan 3.3.0
Crypto and TLS for C&
Public Member Functions | Friends | List of all members
Botan::BER_Object Class Referencefinal

#include <asn1_obj.h>

Public Member Functions

void assert_is_a (ASN1_Type type_tag, ASN1_Class class_tag, std::string_view descr="object") const
 
 BER_Object ()
 
 BER_Object (BER_Object &&other)=default
 
 BER_Object (const BER_Object &other)=default
 
const uint8_t * bits () const
 
ASN1_Class class_tag () const
 
ASN1_Class get_class () const
 
bool is_a (ASN1_Type type_tag, ASN1_Class class_tag) const
 
bool is_a (int type_tag, ASN1_Class class_tag) const
 
bool is_set () const
 
size_t length () const
 
BER_Objectoperator= (BER_Object &&other)=default
 
BER_Objectoperator= (const BER_Object &other)=default
 
uint32_t tagging () const
 
ASN1_Type type () const
 
ASN1_Type type_tag () const
 

Friends

class BER_Decoder
 

Detailed Description

BER Encoded Object

Definition at line 126 of file asn1_obj.h.

Constructor & Destructor Documentation

◆ BER_Object() [1/3]

Botan::BER_Object::BER_Object ( )
inline

Definition at line 128 of file asn1_obj.h.

References Botan::NoObject, and Botan::Universal.

◆ BER_Object() [2/3]

Botan::BER_Object::BER_Object ( const BER_Object & other)
default

◆ BER_Object() [3/3]

Botan::BER_Object::BER_Object ( BER_Object && other)
default

Member Function Documentation

◆ assert_is_a()

void Botan::BER_Object::assert_is_a ( ASN1_Type type_tag,
ASN1_Class class_tag,
std::string_view descr = "object" ) const

Definition at line 29 of file asn1_obj.cpp.

29 {
30 if(this->is_a(expected_type_tag, expected_class_tag) == false) {
31 std::stringstream msg;
32
33 msg << "Tag mismatch when decoding " << descr << " got ";
34
35 if(m_class_tag == ASN1_Class::NoObject && m_type_tag == ASN1_Type::NoObject) {
36 msg << "EOF";
37 } else {
38 if(m_class_tag == ASN1_Class::Universal || m_class_tag == ASN1_Class::Constructed) {
39 msg << asn1_tag_to_string(m_type_tag);
40 } else {
41 msg << std::to_string(static_cast<uint32_t>(m_type_tag));
42 }
43
44 msg << "/" << asn1_class_to_string(m_class_tag);
45 }
46
47 msg << " expected ";
48
49 if(expected_class_tag == ASN1_Class::Universal || expected_class_tag == ASN1_Class::Constructed) {
50 msg << asn1_tag_to_string(expected_type_tag);
51 } else {
52 msg << std::to_string(static_cast<uint32_t>(expected_type_tag));
53 }
54
55 msg << "/" << asn1_class_to_string(expected_class_tag);
56
57 throw BER_Decoding_Error(msg.str());
58 }
59}
bool is_a(ASN1_Type type_tag, ASN1_Class class_tag) const
Definition asn1_obj.cpp:61
std::string asn1_tag_to_string(ASN1_Type type)
Definition asn1_obj.cpp:93
std::string asn1_class_to_string(ASN1_Class type)
Definition asn1_obj.cpp:74

References Botan::asn1_class_to_string(), Botan::asn1_tag_to_string(), Botan::Constructed, is_a(), Botan::NoObject, and Botan::Universal.

Referenced by Botan::BER_Decoder::decode(), Botan::BER_Decoder::decode(), Botan::BER_Decoder::decode_null(), Botan::BER_Decoder::get_next_value(), and Botan::BER_Decoder::start_cons().

◆ bits()

const uint8_t * Botan::BER_Object::bits ( ) const
inline

◆ class_tag()

ASN1_Class Botan::BER_Object::class_tag ( ) const
inline

Definition at line 144 of file asn1_obj.h.

144{ return m_class_tag; }

◆ get_class()

ASN1_Class Botan::BER_Object::get_class ( ) const
inline

Definition at line 148 of file asn1_obj.h.

148{ return m_class_tag; }

Referenced by Botan::AlternativeName::decode_from().

◆ is_a() [1/2]

bool Botan::BER_Object::is_a ( ASN1_Type type_tag,
ASN1_Class class_tag ) const

Definition at line 61 of file asn1_obj.cpp.

61 {
62 return (m_type_tag == expected_type_tag && m_class_tag == expected_class_tag);
63}

Referenced by assert_is_a(), Botan::AlternativeName::decode_from(), Botan::GeneralName::decode_from(), Botan::BER_Decoder::decode_optional(), Botan::BER_Decoder::decode_optional_implicit(), Botan::BER_Decoder::decode_optional_string(), and is_a().

◆ is_a() [2/2]

bool Botan::BER_Object::is_a ( int type_tag,
ASN1_Class class_tag ) const

Definition at line 65 of file asn1_obj.cpp.

65 {
66 return is_a(ASN1_Type(expected_type_tag), expected_class_tag);
67}
ASN1_Type
Definition asn1_obj.h:43

References is_a().

◆ is_set()

bool Botan::BER_Object::is_set ( ) const
inline

◆ length()

size_t Botan::BER_Object::length ( ) const
inline

◆ operator=() [1/2]

BER_Object & Botan::BER_Object::operator= ( BER_Object && other)
default

◆ operator=() [2/2]

BER_Object & Botan::BER_Object::operator= ( const BER_Object & other)
default

◆ tagging()

uint32_t Botan::BER_Object::tagging ( ) const
inline

Definition at line 140 of file asn1_obj.h.

140{ return type_tag() | class_tag(); }
ASN1_Type type_tag() const
Definition asn1_obj.h:142
ASN1_Class class_tag() const
Definition asn1_obj.h:144

Referenced by Botan::OID::decode_from(), and Botan::BER_Decoder::get_next_object().

◆ type()

ASN1_Type Botan::BER_Object::type ( ) const
inline

Definition at line 146 of file asn1_obj.h.

146{ return m_type_tag; }

Referenced by Botan::ASN1_Time::decode_from(), Botan::ASN1_String::decode_from(), and Botan::AlternativeName::decode_from().

◆ type_tag()

ASN1_Type Botan::BER_Object::type_tag ( ) const
inline

Definition at line 142 of file asn1_obj.h.

142{ return m_type_tag; }

Friends And Related Symbol Documentation

◆ BER_Decoder

friend class BER_Decoder
friend

Definition at line 165 of file asn1_obj.h.


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