Botan 1.10.17

Functions
Botan::ASN1 Namespace Reference

## Functions
bool | maybe_BER (DataSource &source)
SecureVector< byte > | put_in_sequence (const MemoryRegion< byte > &contents)
std::string | to_string (const BER_Object &obj)

## Function Documentation

## ◆ maybe_BER()

bool Botan::ASN1::maybe_BER | ( | DataSource & | src | ) |

Heuristics tests; is this object possibly BER?

Parameters

  src | a data source that will be peeked at but not modified

Definition at line 55 of file asn1_int.cpp.

References Botan::CONSTRUCTED, Botan::DataSource::peek_byte(), and Botan::SEQUENCE.

Referenced by Botan::CMS_Decoder::CMS_Decoder(), and Botan::X509::load_key().

56 {
57 byte first_byte;
58 if(!source.peek_byte(first_byte))
59 throw Stream_IO_Error("ASN1::maybe_BER: Source was empty");
60
61 if(first_byte == (SEQUENCE | CONSTRUCTED))
62 return true;
63 return false;
64 }
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::CONSTRUCTED
Definition: asn1_int.h:25
Botan::SEQUENCE
Definition: asn1_int.h:35

## ◆ put_in_sequence()

SecureVector< byte > Botan::ASN1::put_in_sequence | ( | const MemoryRegion< byte > & | contents | ) |

Definition at line 34 of file asn1_int.cpp.

References Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::get_contents(), Botan::DER_Encoder::raw_bytes(), Botan::SEQUENCE, and Botan::DER_Encoder::start_cons().

Referenced by Botan::X509_Object::tbs_data().

35 {
36 return DER_Encoder()
37 .start_cons(SEQUENCE)
38 .raw_bytes(contents)
39 .end_cons()
40 .get_contents();
41 }
Botan::SEQUENCE
Definition: asn1_int.h:35

## ◆ to_string()

std::string Botan::ASN1::to_string | ( | const BER_Object & | obj | ) |

Definition at line 46 of file asn1_int.cpp.

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

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

47 {
48 return std::string(reinterpret_cast<const char*>(&obj.value[0]),
49 obj.value.size());
50 }