Botan 1.10.17

Public Member Functions | List of all members
Botan::BER_Decoder Class Reference

`#include <ber_dec.h>`

## Public Member Functions
| BER_Decoder (DataSource &)
| BER_Decoder (const byte[], size_t)
| BER_Decoder (const MemoryRegion< byte > &)
| BER_Decoder (const BER_Decoder &)
BER_Decoder & | decode (bool &)
BER_Decoder & | decode (size_t &)
BER_Decoder & | decode (class BigInt &)
BER_Decoder & | decode (MemoryRegion< byte > &, ASN1_Tag)
BER_Decoder & | decode (bool &, ASN1_Tag, ASN1_Tag=CONTEXT_SPECIFIC)
BER_Decoder & | decode (size_t &, ASN1_Tag, ASN1_Tag=CONTEXT_SPECIFIC)
BER_Decoder & | decode (class BigInt &, ASN1_Tag, ASN1_Tag=CONTEXT_SPECIFIC)
BER_Decoder & | decode (MemoryRegion< byte > &, ASN1_Tag, ASN1_Tag, ASN1_Tag=CONTEXT_SPECIFIC)
BER_Decoder & | decode (class ASN1_Object &)
template<typename T >
BER_Decoder & | decode_and_check (const T &expected, const std::string &error_msg)
template<typename T >
BER_Decoder & | decode_list (std::vector< T > &out, bool clear_out=true)
BER_Decoder & | decode_null ()
BER_Decoder & | decode_octet_string_bigint (class BigInt &)
template<typename T >
BER_Decoder & | decode_optional (T &out, ASN1_Tag type_tag, ASN1_Tag class_tag, const T &default_value=T())
BER_Decoder & | decode_optional_string (MemoryRegion< byte > &, ASN1_Tag, u16bit)
BER_Decoder & | discard_remaining ()
BER_Decoder & | end_cons ()
BER_Object | get_next_object ()
bool | more_items () const
void | push_back (const BER_Object &)
BER_Decoder & | raw_bytes (MemoryRegion< byte > &)
BER_Decoder | start_cons (ASN1_Tag, ASN1_Tag=UNIVERSAL)
BER_Decoder & | verify_end ()
| ~BER_Decoder ()

## Detailed Description

BER Decoding Object

Definition at line 19 of file ber_dec.h.

## Constructor & Destructor Documentation

## ◆ BER_Decoder() [1/4]

Botan::BER_Decoder::BER_Decoder | ( | DataSource & | src | ) |

Definition at line 264 of file ber_dec.cpp.

References Botan::BER_Object::class_tag, Botan::NO_OBJECT, and Botan::BER_Object::type_tag.

Referenced by decode_optional().

265 {
266 source = &src;
267 owns = false;
268 pushed.type_tag = pushed.class_tag = NO_OBJECT;
269 parent = 0;
270 }
Botan::BER_Object::class_tag
ASN1_Tag class_tag
Definition: asn1_int.h:82
Botan::BER_Object::type_tag
ASN1_Tag type_tag
Definition: asn1_int.h:82
Botan::NO_OBJECT
Definition: asn1_int.h:49

## ◆ BER_Decoder() [2/4]

Botan::BER_Decoder::BER_Decoder | ( | const byte | data[],
|  | size_t | length
| ) |  |

Definition at line 275 of file ber_dec.cpp.

References Botan::BER_Object::class_tag, Botan::NO_OBJECT, and Botan::BER_Object::type_tag.

276 {
277 source = new DataSource_Memory(data, length);
278 owns = true;
279 pushed.type_tag = pushed.class_tag = NO_OBJECT;
280 parent = 0;
281 }
Botan::BER_Object::class_tag
ASN1_Tag class_tag
Definition: asn1_int.h:82
Botan::BER_Object::type_tag
ASN1_Tag type_tag
Definition: asn1_int.h:82
Botan::NO_OBJECT
Definition: asn1_int.h:49

## ◆ BER_Decoder() [3/4]

Botan::BER_Decoder::BER_Decoder | ( | const MemoryRegion< byte > & | data | ) |

Definition at line 286 of file ber_dec.cpp.

References Botan::BER_Object::class_tag, Botan::NO_OBJECT, and Botan::BER_Object::type_tag.

287 {
288 source = new DataSource_Memory(data);
289 owns = true;
290 pushed.type_tag = pushed.class_tag = NO_OBJECT;
291 parent = 0;
292 }
Botan::BER_Object::class_tag
ASN1_Tag class_tag
Definition: asn1_int.h:82
Botan::BER_Object::type_tag
ASN1_Tag type_tag
Definition: asn1_int.h:82
Botan::NO_OBJECT
Definition: asn1_int.h:49

## ◆ BER_Decoder() [4/4]

Botan::BER_Decoder::BER_Decoder | ( | const BER_Decoder & | other | ) |

Definition at line 297 of file ber_dec.cpp.

References Botan::BER_Object::class_tag, Botan::NO_OBJECT, and Botan::BER_Object::type_tag.

298 {
299 source = other.source;
300 owns = false;
301 if(other.owns)
302 {
303 other.owns = false;
304 owns = true;
305 }
306 pushed.type_tag = pushed.class_tag = NO_OBJECT;
307 parent = other.parent;
308 }
Botan::BER_Object::class_tag
ASN1_Tag class_tag
Definition: asn1_int.h:82
Botan::BER_Object::type_tag
ASN1_Tag type_tag
Definition: asn1_int.h:82
Botan::NO_OBJECT
Definition: asn1_int.h:49

## ◆ ~BER_Decoder()

Botan::BER_Decoder::~BER_Decoder | ( |  | ) |

Definition at line 313 of file ber_dec.cpp.

314 {
315 if(owns)
316 delete source;
317 source = 0;
318 }

## Member Function Documentation

## ◆ decode() [1/9]

BER_Decoder & Botan::BER_Decoder::decode | ( | bool & | out | ) |

Definition at line 344 of file ber_dec.cpp.

References Botan::BOOLEAN, and Botan::UNIVERSAL.

Referenced by Botan::DL_Group::BER_decode(), Botan::PK_Verifier::check_signature(), decode(), Botan::CRL_Entry::decode_from(), Botan::X509_DN::decode_from(), Botan::AlgorithmIdentifier::decode_from(), Botan::Attribute::decode_from(), Botan::Extensions::decode_from(), Botan::AlternativeName::decode_from(), Botan::EAC1_1_gen_CVC< EAC1_1_Req >::decode_info(), decode_list(), decode_octet_string_bigint(), decode_optional(), decode_optional_string(), Botan::DL_Scheme_PrivateKey::DL_Scheme_PrivateKey(), Botan::DL_Scheme_PublicKey::DL_Scheme_PublicKey(), Botan::EC_Group::EC_Group(), Botan::ECDSA_Signature::ECDSA_Signature(), Botan::IF_Scheme_PublicKey::IF_Scheme_PublicKey(), and Botan::X509::load_key().

345 {
346 return decode(out, BOOLEAN, UNIVERSAL);
347 }
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:344
Botan::UNIVERSAL
Definition: asn1_int.h:20
Botan::BOOLEAN
Definition: asn1_int.h:28

## ◆ decode() [2/9]

BER_Decoder & Botan::BER_Decoder::decode | ( | size_t & | out | ) |

Definition at line 352 of file ber_dec.cpp.

References decode(), Botan::INTEGER, and Botan::UNIVERSAL.

353 {
354 return decode(out, INTEGER, UNIVERSAL);
355 }
Botan::INTEGER
Definition: asn1_int.h:29
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:344
Botan::UNIVERSAL
Definition: asn1_int.h:20

## ◆ decode() [3/9]

BER_Decoder & Botan::BER_Decoder::decode | ( | class BigInt & | out | ) |

Definition at line 360 of file ber_dec.cpp.

References decode(), Botan::INTEGER, and Botan::UNIVERSAL.

361 {
362 return decode(out, INTEGER, UNIVERSAL);
363 }
Botan::INTEGER
Definition: asn1_int.h:29
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:344
Botan::UNIVERSAL
Definition: asn1_int.h:20

## ◆ decode() [4/9]

BER_Decoder & Botan::BER_Decoder::decode | ( | MemoryRegion< byte > & | out,
|  | ASN1_Tag | real_type
| ) |  |

Definition at line 444 of file ber_dec.cpp.

References decode(), and Botan::UNIVERSAL.

445 {
446 return decode(out, real_type, real_type, UNIVERSAL);
447 }
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:344
Botan::UNIVERSAL
Definition: asn1_int.h:20

## ◆ decode() [5/9]

BER_Decoder & Botan::BER_Decoder::decode | ( | bool & | out,
|  | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag = `CONTEXT_SPECIFIC`
| ) |  |

Definition at line 376 of file ber_dec.cpp.

References Botan::BER_Object::assert_is_a(), get_next_object(), Botan::MemoryRegion< T >::size(), and Botan::BER_Object::value.

378 {
379 BER_Object obj = get_next_object();
380 obj.assert_is_a(type_tag, class_tag);
381
382 if(obj.value.size() != 1)
383 throw BER_Decoding_Error("BER boolean value had invalid size");
384
385 out = (obj.value[0]) ? true : false;
386 return (*this);
387 }
Botan::BER_Decoder::get_next_object
BER_Object get_next_object()
Definition: ber_dec.cpp:196

## ◆ decode() [6/9]

BER_Decoder & Botan::BER_Decoder::decode | ( | size_t & | out,
|  | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag = `CONTEXT_SPECIFIC`
| ) |  |

Definition at line 392 of file ber_dec.cpp.

References Botan::BigInt::bits(), Botan::BigInt::byte_at(), and decode().

394 {
395 BigInt integer;
396 decode(integer, type_tag, class_tag);
397
398 if(integer.bits() > 32)
399 throw BER_Decoding_Error("Decoded integer value larger than expected");
400
401 out = 0;
402 for(size_t i = 0; i != 4; ++i)
403 out = (out << 8) | integer.byte_at(3-i);
404
405 return (*this);
406 }
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:344

## ◆ decode() [7/9]

BER_Decoder & Botan::BER_Decoder::decode | ( | class BigInt & | out,
|  | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag = `CONTEXT_SPECIFIC`
| ) |  |

Definition at line 411 of file ber_dec.cpp.

References Botan::BER_Object::assert_is_a(), Botan::MemoryRegion< T >::empty(), Botan::BigInt::flip_sign(), get_next_object(), Botan::MemoryRegion< T >::size(), and Botan::BER_Object::value.

413 {
414 BER_Object obj = get_next_object();
415 obj.assert_is_a(type_tag, class_tag);
416
417 if(obj.value.empty())
418 out = 0;
419 else
420 {
421 const bool negative = (obj.value[0] & 0x80) ? true : false;
422
423 if(negative)
424 {
425 for(size_t i = obj.value.size(); i > 0; --i)
426 if(obj.value[i-1]--)
427 break;
428 for(size_t i = 0; i != obj.value.size(); ++i)
429 obj.value[i] = ~obj.value[i];
430 }
431
432 out = BigInt(&obj.value[0], obj.value.size());
433
434 if(negative)
435 out.flip_sign();
436 }
437
438 return (*this);
439 }
Botan::BER_Decoder::get_next_object
BER_Object get_next_object()
Definition: ber_dec.cpp:196

## ◆ decode() [8/9]

BER_Decoder & Botan::BER_Decoder::decode | ( | MemoryRegion< byte > & | buffer,
|  | ASN1_Tag | real_type,
|  | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag = `CONTEXT_SPECIFIC`
| ) |  |

Definition at line 452 of file ber_dec.cpp.

References Botan::BER_Object::assert_is_a(), Botan::BIT_STRING, Botan::copy_mem(), Botan::MemoryRegion< T >::empty(), get_next_object(), Botan::OCTET_STRING, Botan::MemoryRegion< T >::resize(), Botan::MemoryRegion< T >::size(), and Botan::BER_Object::value.

455 {
456 if(real_type != OCTET_STRING && real_type != BIT_STRING)
457 throw BER_Bad_Tag("Bad tag for {BIT,OCTET} STRING", real_type);
458
459 BER_Object obj = get_next_object();
460 obj.assert_is_a(type_tag, class_tag);
461
462 if(real_type == OCTET_STRING)
463 buffer = obj.value;
464 else
465 {
466 if(obj.value.empty())
467 throw BER_Decoding_Error("Invalid BIT STRING");
468 if(obj.value[0] >= 8)
469 throw BER_Decoding_Error("Bad number of unused bits in BIT STRING");
470
471 buffer.resize(obj.value.size() - 1);
472 copy_mem(&buffer[0], &obj.value[1], obj.value.size() - 1);
473 }
474 return (*this);
475 }
Botan::MemoryRegion::resize
void resize(size_t n)
Definition: secmem.h:217
Botan::OCTET_STRING
Definition: asn1_int.h:31
Botan::copy_mem
void copy_mem(T *out, const T *in, size_t n)
Definition: mem_ops.h:22
Botan::BER_Decoder::get_next_object
BER_Object get_next_object()
Definition: ber_dec.cpp:196
Botan::BIT_STRING
Definition: asn1_int.h:30

## ◆ decode() [9/9]

BER_Decoder & Botan::BER_Decoder::decode | ( | class ASN1_Object & | obj | ) |

Definition at line 323 of file ber_dec.cpp.

References Botan::ASN1_Object::decode_from().

324 {
325 obj.decode_from(*this);
326 return (*this);
327 }

## ◆ decode_and_check()

template<typename T >

BER_Decoder& Botan::BER_Decoder::decode_and_check | ( | const T & | expected,
|  | const std::string & | error_msg
| ) |  |
| inline

Definition at line 62 of file ber_dec.h.

References Botan::PEM_Code::decode().

Referenced by Botan::EC_Group::EC_Group(), and Botan::EC_PrivateKey::EC_PrivateKey().

64 {
65 T actual;
66 decode(actual);
67
68 if(actual != expected)
69 throw Decoding_Error(error_msg);
70
71 return (*this);
72 }
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:344

## ◆ decode_list()

template<typename T >

BER_Decoder & Botan::BER_Decoder::decode_list | ( | std::vector< T > & | out,
|  | bool | clear_out = `true`
| ) |  |

Definition at line 125 of file ber_dec.h.

References decode(), and more_items().

126 {
127 if(clear_it)
128 vec.clear();
129
130 while(more_items())
131 {
132 T value;
133 decode(value);
134 vec.push_back(value);
135 }
136 return (*this);
137 }
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:344
Botan::BER_Decoder::more_items
bool more_items() const
Definition: ber_dec.cpp:153

## ◆ decode_null()

BER_Decoder & Botan::BER_Decoder::decode_null | ( |  | ) |

Definition at line 332 of file ber_dec.cpp.

References Botan::BER_Object::assert_is_a(), get_next_object(), Botan::NULL_TAG, Botan::MemoryRegion< T >::size(), Botan::UNIVERSAL, and Botan::BER_Object::value.

333 {
334 BER_Object obj = get_next_object();
335 obj.assert_is_a(NULL_TAG, UNIVERSAL);
336 if(obj.value.size())
337 throw BER_Decoding_Error("NULL object had nonzero size");
338 return (*this);
339 }
Botan::UNIVERSAL
Definition: asn1_int.h:20
Botan::NULL_TAG
Definition: asn1_int.h:32
Botan::BER_Decoder::get_next_object
BER_Object get_next_object()
Definition: ber_dec.cpp:196

## ◆ decode_octet_string_bigint()

BER_Decoder & Botan::BER_Decoder::decode_octet_string_bigint | ( | class BigInt & | out | ) |

Definition at line 365 of file ber_dec.cpp.

References decode(), Botan::BigInt::decode(), Botan::OCTET_STRING, and Botan::MemoryRegion< T >::size().

Referenced by Botan::EC_Group::EC_Group().

366 {
367 SecureVector<byte> out_vec;
368 decode(out_vec, OCTET_STRING);
369 out = BigInt::decode(&out_vec[0], out_vec.size());
370 return (*this);
371 }
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:344
Botan::OCTET_STRING
Definition: asn1_int.h:31
Botan::BigInt::decode
static BigInt decode(const byte buf[], size_t length, Base base=Binary)
Definition: big_code.cpp:102

## ◆ decode_optional()

template<typename T >

BER_Decoder & Botan::BER_Decoder::decode_optional | ( | T & | out,
|  | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag,
|  | const T & | default_value = `T()`
| ) |  |

Definition at line 95 of file ber_dec.h.

References BER_Decoder(), Botan::BER_Object::class_tag, Botan::CONSTRUCTED, decode(), get_next_object(), push_back(), Botan::BER_Object::type_tag, and Botan::BER_Object::value.

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

99 {
100 BER_Object obj = get_next_object();
101
102 if(obj.type_tag == type_tag && obj.class_tag == class_tag)
103 {
104 if(class_tag & CONSTRUCTED)
105 BER_Decoder(obj.value).decode(out).verify_end();
106 else
107 {
108 push_back(obj);
109 decode(out, type_tag, class_tag);
110 }
111 }
112 else
113 {
114 out = default_value;
115 push_back(obj);
116 }
117
118 return (*this);
119 }
Botan::BER_Decoder::BER_Decoder
BER_Decoder(DataSource &)
Definition: ber_dec.cpp:264
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:344
Botan::CONSTRUCTED
Definition: asn1_int.h:25
Botan::BER_Decoder::push_back
void push_back(const BER_Object &)
Definition: ber_dec.cpp:228
Botan::BER_Decoder::get_next_object
BER_Object get_next_object()
Definition: ber_dec.cpp:196

## ◆ decode_optional_string()

BER_Decoder & Botan::BER_Decoder::decode_optional_string | ( | MemoryRegion< byte > & | out,
|  | ASN1_Tag | real_type,
|  | u16bit | type_no
| ) |  |

Definition at line 480 of file ber_dec.cpp.

References Botan::BER_Object::class_tag, Botan::MemoryRegion< T >::clear(), Botan::CONTEXT_SPECIFIC, decode(), get_next_object(), push_back(), and Botan::BER_Object::type_tag.

483 {
484 BER_Object obj = get_next_object();
485
486 ASN1_Tag type_tag = static_cast<ASN1_Tag>(type_no);
487
488 out.clear();
489 push_back(obj);
490
491 if(obj.type_tag == type_tag && obj.class_tag == CONTEXT_SPECIFIC)
492 decode(out, real_type, type_tag, CONTEXT_SPECIFIC);
493
494 return (*this);
495 }
Botan::CONTEXT_SPECIFIC
Definition: asn1_int.h:22
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:344
Botan::MemoryRegion::clear
void clear()
Definition: secmem.h:158
Botan::BER_Decoder::push_back
void push_back(const BER_Object &)
Definition: ber_dec.cpp:228
Botan::ASN1_Tag
ASN1_Tag
Definition: asn1_int.h:19
Botan::BER_Decoder::get_next_object
BER_Object get_next_object()
Definition: ber_dec.cpp:196

## ◆ discard_remaining()

BER_Decoder & Botan::BER_Decoder::discard_remaining | ( |  | ) |

Definition at line 185 of file ber_dec.cpp.

References Botan::DataSource::read_byte().

Referenced by Botan::DL_Group::BER_decode().

186 {
187 byte buf;
188 while(source->read_byte(buf))
189 ;
190 return (*this);
191 }
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::DataSource::read_byte
size_t read_byte(byte &out)
Definition: data_src.cpp:19

## ◆ end_cons()

BER_Decoder & Botan::BER_Decoder::end_cons | ( |  | ) |

Definition at line 252 of file ber_dec.cpp.

References Botan::DataSource::end_of_data().

Referenced by Botan::CRL_Entry::decode_from(), Botan::X509_DN::decode_from(), Botan::AlgorithmIdentifier::decode_from(), Botan::Attribute::decode_from(), Botan::Extensions::decode_from(), Botan::EAC1_1_gen_CVC< EAC1_1_Req >::decode_info(), Botan::EC_Group::EC_Group(), Botan::ECDSA_Signature::ECDSA_Signature(), Botan::IF_Scheme_PublicKey::IF_Scheme_PublicKey(), and Botan::X509::load_key().

253 {
254 if(!parent)
255 throw Invalid_State("BER_Decoder::end_cons called with NULL parent");
256 if(!source->end_of_data())
257 throw Decoding_Error("BER_Decoder::end_cons called with data left");
258 return (*parent);
259 }
Botan::DataSource::end_of_data
virtual bool end_of_data() const =0

## ◆ get_next_object()

BER_Object Botan::BER_Decoder::get_next_object | ( |  | ) |

Definition at line 196 of file ber_dec.cpp.

References Botan::DataSource::check_available(), Botan::BER_Object::class_tag, Botan::EOC, Botan::NO_OBJECT, Botan::DataSource::read(), Botan::MemoryRegion< T >::resize(), Botan::BER_Object::type_tag, Botan::UNIVERSAL, and Botan::BER_Object::value.

Referenced by Botan::BER::decode(), decode(), Botan::ASN1_String::decode_from(), Botan::OID::decode_from(), Botan::EAC_Time::decode_from(), Botan::X509_Time::decode_from(), Botan::AlternativeName::decode_from(), Botan::ASN1_EAC_String::decode_from(), decode_null(), decode_optional(), decode_optional_string(), Botan::EC_Group::EC_Group(), and start_cons().

197 {
198 BER_Object next;
199
200 if(pushed.type_tag != NO_OBJECT)
201 {
202 next = pushed;
203 pushed.class_tag = pushed.type_tag = NO_OBJECT;
204 return next;
205 }
206
207 decode_tag(source, next.type_tag, next.class_tag);
208 if(next.type_tag == NO_OBJECT)
209 return next;
210
211 const size_t length = decode_length(source);
212 if(!source->check_available(length))
213 throw BER_Decoding_Error("Value truncated");
214
215 next.value.resize(length);
216 if(source->read(&next.value[0], length) != length)
217 throw BER_Decoding_Error("Value truncated");
218
219 if(next.type_tag == EOC && next.class_tag == UNIVERSAL)
220 return get_next_object();
221
222 return next;
223 }
Botan::DataSource::check_available
virtual bool check_available(size_t n)=0
Botan::DataSource::read
virtual size_t read(byte out[], size_t length)=0
Botan::UNIVERSAL
Definition: asn1_int.h:20
Botan::BER_Decoder::get_next_object
BER_Object get_next_object()
Definition: ber_dec.cpp:196
Botan::BER_Object::class_tag
ASN1_Tag class_tag
Definition: asn1_int.h:82
Botan::BER_Object::type_tag
ASN1_Tag type_tag
Definition: asn1_int.h:82
Botan::NO_OBJECT
Definition: asn1_int.h:49
Botan::EOC
Definition: asn1_int.h:27

## ◆ more_items()

bool Botan::BER_Decoder::more_items | ( |  | ) | const

Definition at line 153 of file ber_dec.cpp.

References Botan::DataSource::end_of_data(), Botan::NO_OBJECT, and Botan::BER_Object::type_tag.

Referenced by Botan::PK_Verifier::check_signature(), Botan::CRL_Entry::decode_from(), Botan::X509_DN::decode_from(), Botan::Extensions::decode_from(), Botan::AlternativeName::decode_from(), and decode_list().

154 {
155 if(source->end_of_data() && (pushed.type_tag == NO_OBJECT))
156 return false;
157 return true;
158 }
Botan::DataSource::end_of_data
virtual bool end_of_data() const =0
Botan::BER_Object::type_tag
ASN1_Tag type_tag
Definition: asn1_int.h:82
Botan::NO_OBJECT
Definition: asn1_int.h:49

## ◆ push_back()

void Botan::BER_Decoder::push_back | ( | const BER_Object & | obj | ) |

Definition at line 228 of file ber_dec.cpp.

References Botan::NO_OBJECT, and Botan::BER_Object::type_tag.

Referenced by decode_optional(), and decode_optional_string().

229 {
230 if(pushed.type_tag != NO_OBJECT)
231 throw Invalid_State("BER_Decoder: Only one push back is allowed");
232 pushed = obj;
233 }
Botan::BER_Object::type_tag
ASN1_Tag type_tag
Definition: asn1_int.h:82
Botan::NO_OBJECT
Definition: asn1_int.h:49

## ◆ raw_bytes()

BER_Decoder & Botan::BER_Decoder::raw_bytes | ( | MemoryRegion< byte > & | out | ) |

Definition at line 173 of file ber_dec.cpp.

References Botan::MemoryRegion< T >::clear(), Botan::MemoryRegion< T >::push_back(), and Botan::DataSource::read_byte().

Referenced by Botan::X509_DN::decode_from(), Botan::AlgorithmIdentifier::decode_from(), Botan::Attribute::decode_from(), and Botan::EAC1_1_gen_CVC< EAC1_1_Req >::decode_info().

174 {
175 out.clear();
176 byte buf;
177 while(source->read_byte(buf))
178 out.push_back(buf);
179 return (*this);
180 }
Botan::MemoryRegion::clear
void clear()
Definition: secmem.h:158
Botan::MemoryRegion::push_back
void push_back(T x)
Definition: secmem.h:149
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::DataSource::read_byte
size_t read_byte(byte &out)
Definition: data_src.cpp:19

## ◆ start_cons()

BER_Decoder Botan::BER_Decoder::start_cons | ( | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag = `UNIVERSAL`
| ) |  |

Definition at line 238 of file ber_dec.cpp.

References Botan::BER_Object::assert_is_a(), Botan::CONSTRUCTED, get_next_object(), Botan::MemoryRegion< T >::size(), and Botan::BER_Object::value.

Referenced by Botan::DL_Group::BER_decode(), Botan::PK_Verifier::check_signature(), Botan::CRL_Entry::decode_from(), Botan::X509_DN::decode_from(), Botan::AlgorithmIdentifier::decode_from(), Botan::Attribute::decode_from(), Botan::Extensions::decode_from(), Botan::AlternativeName::decode_from(), Botan::EAC1_1_gen_CVC< EAC1_1_Req >::decode_info(), Botan::EC_Group::EC_Group(), Botan::EC_PrivateKey::EC_PrivateKey(), Botan::ECDSA_Signature::ECDSA_Signature(), Botan::IF_Scheme_PublicKey::IF_Scheme_PublicKey(), and Botan::X509::load_key().

240 {
241 BER_Object obj = get_next_object();
242 obj.assert_is_a(type_tag, ASN1_Tag(class_tag | CONSTRUCTED));
243
244 BER_Decoder result(&obj.value[0], obj.value.size());
245 result.parent = this;
246 return result;
247 }
Botan::BER_Decoder::BER_Decoder
BER_Decoder(DataSource &)
Definition: ber_dec.cpp:264
Botan::CONSTRUCTED
Definition: asn1_int.h:25
Botan::ASN1_Tag
ASN1_Tag
Definition: asn1_int.h:19
Botan::BER_Decoder::get_next_object
BER_Object get_next_object()
Definition: ber_dec.cpp:196

## ◆ verify_end()

BER_Decoder & Botan::BER_Decoder::verify_end | ( |  | ) |

Definition at line 163 of file ber_dec.cpp.

References Botan::DataSource::end_of_data(), Botan::NO_OBJECT, and Botan::BER_Object::type_tag.

Referenced by Botan::DL_Group::BER_decode(), Botan::X509_DN::decode_from(), Botan::Extensions::decode_from(), Botan::AlternativeName::decode_from(), Botan::EC_Group::EC_Group(), Botan::ECDSA_Signature::ECDSA_Signature(), Botan::IF_Scheme_PublicKey::IF_Scheme_PublicKey(), and Botan::X509::load_key().

164 {
165 if(!source->end_of_data() || (pushed.type_tag != NO_OBJECT))
166 throw Invalid_State("BER_Decoder::verify_end called, but data remains");
167 return (*this);
168 }
Botan::DataSource::end_of_data
virtual bool end_of_data() const =0
Botan::BER_Object::type_tag
ASN1_Tag type_tag
Definition: asn1_int.h:82
Botan::NO_OBJECT
Definition: asn1_int.h:49

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

- src/asn1/ber_dec.h
- src/asn1/ber_dec.cpp