Botan 1.10.17
Botan::ASN1 Namespace Reference

Functions

bool maybe_BER (DataSource &source)
SecureVector< byteput_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
srca data source that will be peeked at but not modified

Definition at line 55 of file asn1_int.cpp.

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 }
@ CONSTRUCTED
Definition asn1_int.h:25
@ SEQUENCE
Definition asn1_int.h:35
Stream_IO_Error(const std::string &err)
Definition exceptn.h:167

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

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

◆ put_in_sequence()

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

Definition at line 34 of file asn1_int.cpp.

35 {
36 return DER_Encoder()
38 .raw_bytes(contents)
39 .end_cons()
40 .get_contents();
41 }
DER_Encoder & start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
Definition der_enc.cpp:135
DER_Encoder & raw_bytes(const byte val[], size_t len)
Definition der_enc.cpp:188
SecureVector< byte > get_contents()
Definition der_enc.cpp:122
DER_Encoder & end_cons()
Definition der_enc.cpp:145

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

Referenced by put_in_sequence(), and Botan::X509_Object::tbs_data().

◆ to_string()

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

Definition at line 46 of file asn1_int.cpp.

47 {
48 return std::string(reinterpret_cast<const char*>(&obj.value[0]),
49 obj.value.size());
50 }
SecureVector< byte > value
Definition asn1_int.h:83
size_t size() const
Definition secmem.h:29

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

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