Botan  2.7.0
Crypto and TLS for C++11
Public Member Functions | Public Attributes | Friends | List of all members
Botan::BER_Object Class Referencefinal

#include <asn1_obj.h>

Public Member Functions

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

Public Attributes

BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES __pad0__: ASN1_Tag type_tag
 
BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES class_tag
 
secure_vector< uint8_t > value
 

Friends

class BER_Decoder
 

Detailed Description

BER Encoded Object

Definition at line 96 of file asn1_obj.h.

Constructor & Destructor Documentation

◆ BER_Object() [1/3]

Botan::BER_Object::BER_Object ( )
inline

Definition at line 99 of file asn1_obj.h.

99 : type_tag(NO_OBJECT), class_tag(UNIVERSAL) {}
BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES class_tag
Definition: asn1_obj.h:135

◆ 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_Tag  type_tag,
ASN1_Tag  class_tag,
const std::string &  descr = "object" 
) const

Definition at line 27 of file asn1_obj.cpp.

References Botan::asn1_class_to_string(), Botan::asn1_tag_to_string(), class_tag, Botan::CONSTRUCTED, is_a(), Botan::NO_OBJECT, Botan::ASN1::to_string(), 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().

29  {
30  if(this->is_a(type_tag_, class_tag_) == false)
31  {
32  std::stringstream msg;
33 
34  msg << "Tag mismatch when decoding " << descr << " got ";
35 
36  if(class_tag == NO_OBJECT && type_tag == NO_OBJECT)
37  {
38  msg << "EOF";
39  }
40  else
41  {
43  {
44  msg << asn1_tag_to_string(type_tag);
45  }
46  else
47  {
48  msg << std::to_string(type_tag);
49  }
50 
51  msg << "/" << asn1_class_to_string(class_tag);
52  }
53 
54  msg << " expected ";
55 
56  if(class_tag_ == UNIVERSAL || class_tag_ == CONSTRUCTED)
57  {
58  msg << asn1_tag_to_string(type_tag_);
59  }
60  else
61  {
62  msg << std::to_string(type_tag_);
63  }
64 
65  msg << "/" << asn1_class_to_string(class_tag_);
66 
67  throw BER_Decoding_Error(msg.str());
68  }
69  }
std::string asn1_tag_to_string(ASN1_Tag type)
Definition: asn1_obj.cpp:108
std::string asn1_class_to_string(ASN1_Tag type)
Definition: asn1_obj.cpp:87
bool is_a(ASN1_Tag type_tag, ASN1_Tag class_tag) const
Definition: asn1_obj.cpp:71
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:210
BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES class_tag
Definition: asn1_obj.h:135

◆ bits()

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

◆ get_class()

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

Definition at line 116 of file asn1_obj.h.

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

116 { return class_tag; }
BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES class_tag
Definition: asn1_obj.h:135

◆ is_a() [1/2]

bool Botan::BER_Object::is_a ( ASN1_Tag  type_tag,
ASN1_Tag  class_tag 
) const

Definition at line 71 of file asn1_obj.cpp.

References class_tag.

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().

72  {
73  return (type_tag == type_tag_ && class_tag == class_tag_);
74  }
BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES class_tag
Definition: asn1_obj.h:135

◆ is_a() [2/2]

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

Definition at line 76 of file asn1_obj.cpp.

References is_a().

77  {
78  return is_a(ASN1_Tag(type_tag_), class_tag_);
79  }
bool is_a(ASN1_Tag type_tag, ASN1_Tag class_tag) const
Definition: asn1_obj.cpp:71
ASN1_Tag
Definition: asn1_obj.h:22

◆ 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= ( const BER_Object other)
default

◆ operator=() [2/2]

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

◆ tagging()

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

Definition at line 113 of file asn1_obj.h.

References type.

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

113 { return ASN1_Tag(type() | get_class()); }
ASN1_Tag
Definition: asn1_obj.h:22
ASN1_Tag type() const
Definition: asn1_obj.h:115
ASN1_Tag get_class() const
Definition: asn1_obj.h:116

◆ type()

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

Definition at line 115 of file asn1_obj.h.

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

115 { return type_tag; }

Friends And Related Function Documentation

◆ BER_Decoder

friend class BER_Decoder
friend

Definition at line 140 of file asn1_obj.h.

Member Data Documentation

◆ __pad0__

BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES Botan::BER_Object::__pad0__

Definition at line 135 of file asn1_obj.h.

◆ class_tag

BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES Botan::BER_Object::class_tag

Definition at line 135 of file asn1_obj.h.

Referenced by assert_is_a(), and is_a().

◆ value

secure_vector<uint8_t> Botan::BER_Object::value

Definition at line 136 of file asn1_obj.h.


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