Botan: Botan::BER_Decoder Class Reference

Botan 1.10.12

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

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

Definition at line 261 of file ber_dec.cpp.

References Botan::NO_OBJECT.

262 {
263 source = &src;
264 owns = false;
265 pushed.type_tag = pushed.class_tag = NO_OBJECT;
266 parent = 0;
267 }
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::BER_Decoder::BER_Decoder | ( | const byte | data[],
|  | size_t | length
| ) |  |

Definition at line 272 of file ber_dec.cpp.

References Botan::NO_OBJECT.

273 {
274 source = new DataSource_Memory(data, length);
275 owns = true;
276 pushed.type_tag = pushed.class_tag = NO_OBJECT;
277 parent = 0;
278 }
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::BER_Decoder::BER_Decoder | ( | const MemoryRegion< byte > & | data | ) |

Definition at line 283 of file ber_dec.cpp.

References Botan::NO_OBJECT.

284 {
285 source = new DataSource_Memory(data);
286 owns = true;
287 pushed.type_tag = pushed.class_tag = NO_OBJECT;
288 parent = 0;
289 }
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::BER_Decoder::BER_Decoder | ( | const BER_Decoder & | other | ) |

Definition at line 294 of file ber_dec.cpp.

References Botan::NO_OBJECT.

295 {
296 source = other.source;
297 owns = false;
298 if(other.owns)
299 {
300 other.owns = false;
301 owns = true;
302 }
303 pushed.type_tag = pushed.class_tag = NO_OBJECT;
304 parent = other.parent;
305 }
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::BER_Decoder::~BER_Decoder | ( |  | ) |

Definition at line 310 of file ber_dec.cpp.

311 {
312 if(owns)
313 delete source;
314 source = 0;
315 }

## Member Function Documentation

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

Definition at line 341 of file ber_dec.cpp.

References Botan::BOOLEAN, Botan::PEM_Code::decode(), and Botan::UNIVERSAL.

Referenced by Botan::DL_Group::BER_decode(), Botan::CMS_Encoder::can_compress_with(), Botan::Certificate_Req::Certificate_Req(), Botan::PK_Verifier::check_signature(), Botan::Cert_Extension::CRL_Number::copy(), 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< Derived >::decode_info(), decode_optional(), Botan::DL_Scheme_PrivateKey::DL_Scheme_PrivateKey(), Botan::DL_Scheme_PublicKey::DL_Scheme_PublicKey(), Botan::EAC1_1_ADO::EAC1_1_ADO(), Botan::EC_Group::EC_Group(), Botan::ECDSA_Signature::ECDSA_Signature(), Botan::PBE_PKCS5v15::end_msg(), Botan::PBE_PKCS5v20::end_msg(), Botan::EAC1_1_ADO::get_car(), Botan::EAC1_1_CVC::get_chat_value(), Botan::Cert_Extension::Basic_Constraints::get_path_limit(), Botan::IF_Scheme_PublicKey::IF_Scheme_PublicKey(), Botan::CMS_Decoder::layer_info(), Botan::X509::load_key(), Botan::EAC1_1_Req::operator==(), Botan::PKCS10_Request::PKCS10_Request(), Botan::Cert_Extension::Subject_Key_ID::Subject_Key_ID(), Botan::X509_Certificate::X509_Certificate(), Botan::X509_CRL::X509_CRL(), and Botan::X509_Object::X509_Object().

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

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

Definition at line 349 of file ber_dec.cpp.

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

350 {
351 return decode(out, INTEGER, UNIVERSAL);
352 }
Botan::INTEGER
Definition: asn1_int.h:29
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:341
Botan::UNIVERSAL
Definition: asn1_int.h:20

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

Definition at line 357 of file ber_dec.cpp.

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

358 {
359 return decode(out, INTEGER, UNIVERSAL);
360 }
Botan::INTEGER
Definition: asn1_int.h:29
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:341
Botan::UNIVERSAL
Definition: asn1_int.h:20

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

Definition at line 441 of file ber_dec.cpp.

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

442 {
443 return decode(out, real_type, real_type, UNIVERSAL);
444 }
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:341
Botan::UNIVERSAL
Definition: asn1_int.h:20

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

Definition at line 373 of file ber_dec.cpp.

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

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

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

Definition at line 389 of file ber_dec.cpp.

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

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

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

Definition at line 408 of file ber_dec.cpp.

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

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

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 449 of file ber_dec.cpp.

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

452 {
453 if(real_type != OCTET_STRING && real_type != BIT_STRING)
454 throw BER_Bad_Tag("Bad tag for {BIT,OCTET} STRING", real_type);
455
456 BER_Object obj = get_next_object();
457 obj.assert_is_a(type_tag, class_tag);
458
459 if(real_type == OCTET_STRING)
460 buffer = obj.value;
461 else
462 {
463 if(obj.value.empty())
464 throw BER_Decoding_Error("Invalid BIT STRING");
465 if(obj.value[0] >= 8)
466 throw BER_Decoding_Error("Bad number of unused bits in BIT STRING");
467
468 buffer.resize(obj.value.size() - 1);
469 copy_mem(&buffer[0], &obj.value[1], obj.value.size() - 1);
470 }
471 return (*this);
472 }
Botan::MemoryRegion::resize
void resize(size_t n)
Definition: secmem.h:211
Botan::OCTET_STRING
Definition: asn1_int.h:31
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29
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:193
Botan::BIT_STRING
Definition: asn1_int.h:30

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

Definition at line 320 of file ber_dec.cpp.

References Botan::ASN1_Object::decode_from().

321 {
322 obj.decode_from(*this);
323 return (*this);
324 }
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(), Botan::EC_PrivateKey::EC_PrivateKey(), and Botan::IF_Scheme_PrivateKey::IF_Scheme_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:341
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 Botan::PEM_Code::decode().

Referenced by Botan::Cert_Extension::Issuer_Alternative_Name::Issuer_Alternative_Name().

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:341
Botan::BER_Decoder::more_items
bool more_items() const
Definition: ber_dec.cpp:150

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

Definition at line 329 of file ber_dec.cpp.

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

330 {
331 BER_Object obj = get_next_object();
332 obj.assert_is_a(NULL_TAG, UNIVERSAL);
333 if(obj.value.size())
334 throw BER_Decoding_Error("NULL object had nonzero size");
335 return (*this);
336 }
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:193

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

Definition at line 362 of file ber_dec.cpp.

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

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

363 {
364 SecureVector<byte> out_vec;
365 decode(out_vec, OCTET_STRING);
366 out = BigInt::decode(&out_vec[0], out_vec.size());
367 return (*this);
368 }
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:341
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
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 Botan::BER_Object::class_tag, Botan::CONSTRUCTED, decode(), Botan::PEM_Code::decode(), Botan::BER_Object::type_tag, Botan::BER_Object::value, and verify_end().

Referenced by Botan::Extensions::decode_from(), Botan::PBE_PKCS5v20::end_msg(), Botan::Cert_Extension::Basic_Constraints::get_path_limit(), Botan::X509_Certificate::X509_Certificate(), and Botan::X509_CRL::X509_CRL().

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:261
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:341
Botan::CONSTRUCTED
Definition: asn1_int.h:25
Botan::BER_Decoder::push_back
void push_back(const BER_Object &)
Definition: ber_dec.cpp:225
Botan::BER_Decoder::get_next_object
BER_Object get_next_object()
Definition: ber_dec.cpp:193

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

Definition at line 477 of file ber_dec.cpp.

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

Referenced by Botan::Cert_Extension::Subject_Key_ID::Subject_Key_ID(), and Botan::X509_Certificate::X509_Certificate().

480 {
481 BER_Object obj = get_next_object();
482
483 ASN1_Tag type_tag = static_cast<ASN1_Tag>(type_no);
484
485 out.clear();
486 push_back(obj);
487
488 if(obj.type_tag == type_tag && obj.class_tag == CONTEXT_SPECIFIC)
489 decode(out, real_type, type_tag, CONTEXT_SPECIFIC);
490
491 return (*this);
492 }
Botan::CONTEXT_SPECIFIC
Definition: asn1_int.h:22
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:341
Botan::MemoryRegion::clear
void clear()
Definition: secmem.h:152
Botan::BER_Decoder::push_back
void push_back(const BER_Object &)
Definition: ber_dec.cpp:225
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:193

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

Definition at line 182 of file ber_dec.cpp.

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

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

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

Definition at line 249 of file ber_dec.cpp.

Referenced by Botan::CMS_Encoder::can_compress_with(), 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< Derived >::decode_info(), Botan::EAC1_1_ADO::EAC1_1_ADO(), Botan::EC_Group::EC_Group(), Botan::ECDSA_Signature::ECDSA_Signature(), Botan::DER_Encoder::end_explicit(), Botan::PBE_PKCS5v15::end_msg(), Botan::PBE_PKCS5v20::end_msg(), Botan::EAC1_1_ADO::get_car(), Botan::EAC1_1_CVC::get_chat_value(), Botan::Cert_Extension::Basic_Constraints::get_path_limit(), Botan::IF_Scheme_PublicKey::IF_Scheme_PublicKey(), Botan::Cert_Extension::Issuer_Alternative_Name::Issuer_Alternative_Name(), Botan::X509::load_key(), Botan::EAC1_1_Req::operator==(), Botan::X509_Certificate::X509_Certificate(), and Botan::X509_Object::X509_Object().

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

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

Definition at line 193 of file ber_dec.cpp.

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

Referenced by Botan::BER::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(), Botan::EC_Group::EC_Group(), Botan::Cert_Extension::Basic_Constraints::get_path_limit(), Botan::PKCS10_Request::PKCS10_Request(), Botan::X509_Certificate::X509_Certificate(), and Botan::X509_CRL::X509_CRL().

194 {
195 BER_Object next;
196
197 if(pushed.type_tag != NO_OBJECT)
198 {
199 next = pushed;
200 pushed.class_tag = pushed.type_tag = NO_OBJECT;
201 return next;
202 }
203
204 decode_tag(source, next.type_tag, next.class_tag);
205 if(next.type_tag == NO_OBJECT)
206 return next;
207
208 const size_t length = decode_length(source);
209 if(!source->check_available(length))
210 throw BER_Decoding_Error("Value truncated");
211
212 next.value.resize(length);
213 if(source->read(&next.value[0], length) != length)
214 throw BER_Decoding_Error("Value truncated");
215
216 if(next.type_tag == EOC && next.class_tag == UNIVERSAL)
217 return get_next_object();
218
219 return next;
220 }
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:193
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

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

Definition at line 150 of file ber_dec.cpp.

References Botan::NO_OBJECT.

Referenced by Botan::Certificate_Req::Certificate_Req(), Botan::PK_Verifier::check_signature(), Botan::CRL_Entry::decode_from(), Botan::X509_DN::decode_from(), Botan::Extensions::decode_from(), Botan::AlternativeName::decode_from(), Botan::PKCS10_Request::PKCS10_Request(), Botan::X509_Certificate::X509_Certificate(), and Botan::X509_CRL::X509_CRL().

151 {
152 if(source->end_of_data() && (pushed.type_tag == NO_OBJECT))
153 return false;
154 return true;
155 }
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

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

Definition at line 225 of file ber_dec.cpp.

References Botan::NO_OBJECT.

226 {
227 if(pushed.type_tag != NO_OBJECT)
228 throw Invalid_State("BER_Decoder: Only one push back is allowed");
229 pushed = obj;
230 }
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::raw_bytes | ( | MemoryRegion< byte > & | out | ) |

Definition at line 170 of file ber_dec.cpp.

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

Referenced by Botan::DER_Encoder::add_object(), Botan::X509_DN::decode_from(), Botan::AlgorithmIdentifier::decode_from(), Botan::Attribute::decode_from(), Botan::EAC1_1_gen_CVC< Derived >::decode_info(), Botan::EAC1_1_ADO::EAC1_1_ADO(), Botan::DER_Encoder::encode_if(), Botan::DER_Encoder::end_cons(), Botan::EAC1_1_ADO::get_car(), Botan::EAC1_1_CVC::get_chat_value(), Botan::EAC1_1_Req::operator==(), Botan::DER_Encoder::raw_bytes(), and Botan::X509_Object::X509_Object().

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

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

Definition at line 235 of file ber_dec.cpp.

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

Referenced by Botan::DL_Group::BER_decode(), Botan::CMS_Encoder::can_compress_with(), 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< Derived >::decode_info(), Botan::EAC1_1_ADO::EAC1_1_ADO(), Botan::EC_Group::EC_Group(), Botan::EC_PrivateKey::EC_PrivateKey(), Botan::ECDSA_Signature::ECDSA_Signature(), Botan::PBE_PKCS5v15::end_msg(), Botan::PBE_PKCS5v20::end_msg(), Botan::EAC1_1_ADO::get_car(), Botan::EAC1_1_CVC::get_chat_value(), Botan::Cert_Extension::Basic_Constraints::get_path_limit(), Botan::IF_Scheme_PrivateKey::IF_Scheme_PrivateKey(), Botan::IF_Scheme_PublicKey::IF_Scheme_PublicKey(), Botan::Cert_Extension::Issuer_Alternative_Name::Issuer_Alternative_Name(), Botan::CMS_Decoder::layer_info(), Botan::X509::load_key(), Botan::EAC1_1_Req::operator==(), Botan::DER_Encoder::start_explicit(), Botan::Cert_Extension::Subject_Key_ID::Subject_Key_ID(), Botan::X509_Certificate::X509_Certificate(), and Botan::X509_Object::X509_Object().

237 {
238 BER_Object obj = get_next_object();
239 obj.assert_is_a(type_tag, ASN1_Tag(class_tag | CONSTRUCTED));
240
241 BER_Decoder result(&obj.value[0], obj.value.size());
242 result.parent = this;
243 return result;
244 }
Botan::BER_Decoder::BER_Decoder
BER_Decoder(DataSource &)
Definition: ber_dec.cpp:261
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:193

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

Definition at line 160 of file ber_dec.cpp.

References Botan::NO_OBJECT.

Referenced by Botan::DL_Group::BER_decode(), Botan::X509_DN::decode_from(), Botan::Extensions::decode_from(), Botan::AlternativeName::decode_from(), decode_optional(), Botan::EAC1_1_ADO::EAC1_1_ADO(), Botan::EC_Group::EC_Group(), Botan::ECDSA_Signature::ECDSA_Signature(), Botan::PBE_PKCS5v15::end_msg(), Botan::PBE_PKCS5v20::end_msg(), Botan::EAC1_1_CVC::get_chat_value(), Botan::Cert_Extension::Basic_Constraints::get_path_limit(), Botan::IF_Scheme_PublicKey::IF_Scheme_PublicKey(), Botan::X509::load_key(), Botan::EAC1_1_Req::operator==(), Botan::PKCS10_Request::PKCS10_Request(), Botan::X509_Certificate::X509_Certificate(), Botan::X509_CRL::X509_CRL(), and Botan::X509_Object::X509_Object().

161 {
162 if(!source->end_of_data() || (pushed.type_tag != NO_OBJECT))
163 throw Invalid_State("BER_Decoder::verify_end called, but data remains");
164 return (*this);
165 }
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