Botan 3.0.0-alpha0
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, const std::string &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 128 of file asn1_obj.h.

Constructor & Destructor Documentation

◆ BER_Object() [1/3]

Botan::BER_Object::BER_Object ( )
inline

Definition at line 131 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,
const std::string &  descr = "object" 
) const

Definition at line 27 of file asn1_obj.cpp.

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

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_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 146 of file asn1_obj.h.

146{ return m_class_tag; }

◆ get_class()

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

Definition at line 149 of file asn1_obj.h.

149{ 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 71 of file asn1_obj.cpp.

72 {
73 return (m_type_tag == expected_type_tag && m_class_tag == expected_class_tag);
74 }

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 76 of file asn1_obj.cpp.

77 {
78 return is_a(ASN1_Type(expected_type_tag), expected_class_tag);
79 }
ASN1_Type
Definition: asn1_obj.h:39

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 143 of file asn1_obj.h.

143{ return type_tag() | class_tag(); }
ASN1_Type type_tag() const
Definition: asn1_obj.h:145
ASN1_Class class_tag() const
Definition: asn1_obj.h:146

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 148 of file asn1_obj.h.

148{ 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 145 of file asn1_obj.h.

145{ return m_type_tag; }

Friends And Related Function Documentation

◆ BER_Decoder

friend class BER_Decoder
friend

Definition at line 167 of file asn1_obj.h.


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