Botan 3.0.0-alpha0
Crypto and TLS for C&
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 218 of file asn1_obj.cpp.

219 {
220 uint8_t first_u8;
221 if(!source.peek_byte(first_u8))
222 {
223 BOTAN_ASSERT_EQUAL(source.read_byte(first_u8), 0, "Expected EOF");
224 throw Stream_IO_Error("ASN1::maybe_BER: Source was empty");
225 }
226
227 const auto cons_seq = static_cast<uint8_t>(ASN1_Class::Constructed) | static_cast<uint8_t>(ASN1_Type::Sequence);
228 if(first_u8 == cons_seq)
229 return true;
230 return false;
231 }
#define BOTAN_ASSERT_EQUAL(expr1, expr2, assertion_made)
Definition: assert.h:80

References BOTAN_ASSERT_EQUAL, Botan::Constructed, Botan::DataSource::peek_byte(), Botan::DataSource::read_byte(), and Botan::Sequence.

Referenced by Botan::X509_Object::load_data(), and 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 191 of file asn1_obj.cpp.

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

References put_in_sequence().

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

◆ put_in_sequence() [2/2]

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

Definition at line 196 of file asn1_obj.cpp.

197 {
198 std::vector<uint8_t> output;
199 DER_Encoder(output)
201 .raw_bytes(bits, len)
202 .end_cons();
203 return output;
204 }
DER_Encoder & start_sequence()
Definition: der_enc.h:66
DER_Encoder & raw_bytes(const uint8_t val[], size_t len)
Definition: der_enc.cpp:231
DER_Encoder & end_cons()
Definition: der_enc.cpp:194

References Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::raw_bytes(), and Botan::DER_Encoder::start_sequence().

◆ to_string()

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

Definition at line 209 of file asn1_obj.cpp.

210 {
211 return std::string(cast_uint8_ptr_to_char(obj.bits()),
212 obj.length());
213 }
size_t length() const
Definition: asn1_obj.h:153
const uint8_t * bits() const
Definition: asn1_obj.h:151
const char * cast_uint8_ptr_to_char(const uint8_t *b)
Definition: mem_ops.h:188

References Botan::BER_Object::bits(), Botan::cast_uint8_ptr_to_char(), and Botan::BER_Object::length().

Referenced by Botan::TLS::Extensions::add(), Botan::TLS::Stream_Handshake_IO::add_record(), Botan::TLS::Alert::Alert(), Botan::GOST_3410_PublicKey::algo_name(), Botan::TLS::Application_Layer_Protocol_Notification::Application_Layer_Protocol_Notification(), Botan::SCAN_Name::arg(), Botan::argon2_generate_pwhash(), Botan::asn1_class_to_string(), Botan::asn1_tag_to_string(), botan_privkey_create_mceliece(), botan_privkey_create_rsa(), Botan::check_passhash9(), Botan::TLS::Policy::check_peer_key_acceptable(), Botan::TLS::Session::ciphersuite(), Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan::ASN1_Time::decode_from(), Botan::ASN1_String::decode_from(), Botan::AlternativeName::decode_from(), Botan::GeneralName::decode_from(), Botan::DL_Group::DL_Group(), Botan::GCM_Mode::GCM_Mode(), Botan::generate_dsa_primes(), Botan::generate_passhash9(), Botan::BER_Decoder::get_next_value(), Botan::GOST_3410_PrivateKey::GOST_3410_PrivateKey(), Botan::GOST_3410_PublicKey::GOST_3410_PublicKey(), Botan::TLS::handshake_type_to_string(), Botan::HTTP::http_sync(), Botan::ipv4_to_string(), Botan::Keccak_1600::Keccak_1600(), Botan::Lion::name(), Botan::BLAKE2b::name(), Botan::Keccak_1600::name(), Botan::SHA_3::name(), Botan::SHAKE_128::name(), Botan::SHAKE_256::name(), Botan::Skein_512::name(), Botan::Streebog::name(), Botan::SipHash::name(), Botan::FPE_FE1::name(), Botan::CCM_Mode::name(), Botan::PSSR::name(), Botan::PSSR_Raw::name(), Botan::EMSA_Raw::name(), Botan::ISO_9796_DS2::name(), Botan::ChaCha::name(), Botan::CTR_BE::name(), Botan::RC4::name(), Botan::GCM_Mode::name(), Botan::CFB_Mode::name(), Botan::OS::open_socket_udp(), Botan::HTTP::operator<<(), Botan::OS2ECP(), Botan::random_prime(), Botan::random_safe_prime(), Botan::read_cfg(), Botan::TLS::Channel_Impl_12::received_data(), Botan::TLS::Channel_Impl_13::received_data(), Botan::rfc3394_keyunwrap(), Botan::rfc3394_keywrap(), Botan::RSA_PrivateKey::RSA_PrivateKey(), Botan::runtime_version_check(), Botan::TLS::Session::Session(), Botan::SIV_Mode::set_associated_data_n(), Botan::SHA_3::SHA_3(), Botan::SHAKE_128::SHAKE_128(), Botan::SHAKE_256::SHAKE_256(), Botan::Streebog::Streebog(), Botan::OID::to_string(), Botan::ASN1_Time::to_string(), Botan::polyn_gf2m::to_string(), Botan::TLS::Protocol_Version::to_string(), Botan::TLS::Signature_Scheme::to_string(), Botan::Argon2::to_string(), Botan::Bcrypt_PBKDF::to_string(), Botan::PBKDF2::to_string(), Botan::RFC4880_S2K::to_string(), Botan::Scrypt::to_string(), Botan::TLS::Alert::type_string(), Botan::X509_Object::verify_signature(), and Botan::Path_Validation_Result::warnings_string().