Botan  2.10.0
Crypto and TLS for C++11
Functions
Botan::ASN1 Namespace Reference

Functions

bool maybe_BER (DataSource &source)
 
std::vector< uint8_t > put_in_sequence (const std::vector< uint8_t > &contents)
 
std::vector< uint8_t > put_in_sequence (const uint8_t bits[], size_t len)
 
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 219 of file asn1_obj.cpp.

220  {
221  uint8_t first_u8;
222  if(!source.peek_byte(first_u8))
223  {
224  BOTAN_ASSERT_EQUAL(source.read_byte(first_u8), 0, "Expected EOF");
225  throw Stream_IO_Error("ASN1::maybe_BER: Source was empty");
226  }
227 
228  if(first_u8 == (SEQUENCE | CONSTRUCTED))
229  return true;
230  return false;
231  }
#define BOTAN_ASSERT_EQUAL(expr1, expr2, assertion_made)
Definition: assert.h:81
const botan_hash_t source
Definition: ffi.h:269

References BOTAN_ASSERT_EQUAL, Botan::CONSTRUCTED, Botan::SEQUENCE, and source.

Referenced by Botan::X509::load_key().

◆ put_in_sequence() [1/2]

std::vector< uint8_t > Botan::ASN1::put_in_sequence ( const std::vector< uint8_t > &  contents)

Definition at line 192 of file asn1_obj.cpp.

193  {
194  return ASN1::put_in_sequence(contents.data(), contents.size());
195  }
std::vector< uint8_t > put_in_sequence(const uint8_t bits[], size_t len)
Definition: asn1_obj.cpp:197

References put_in_sequence().

◆ put_in_sequence() [2/2]

std::vector< uint8_t > Botan::ASN1::put_in_sequence ( const uint8_t  bits[],
size_t  len 
)

Definition at line 197 of file asn1_obj.cpp.

198  {
199  std::vector<uint8_t> output;
200  DER_Encoder(output)
201  .start_cons(SEQUENCE)
202  .raw_bytes(bits, len)
203  .end_cons();
204  return output;
205  }
uint32_t uint8_t output[]
Definition: ffi.h:509
size_t bits
Definition: ffi.h:216
const uint8_t size_t len
Definition: ffi.h:139

References bits, len, output, and Botan::SEQUENCE.

Referenced by put_in_sequence().

◆ to_string()

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