Botan 2.19.1
Crypto and TLS for C&
|
#include <der_enc.h>
Public Types | |
typedef std::function< void(const uint8_t[], size_t)> | append_fn |
Public Member Functions | |
DER_Encoder & | add_object (ASN1_Tag type_tag, ASN1_Tag class_tag, const secure_vector< uint8_t > &rep) |
DER_Encoder & | add_object (ASN1_Tag type_tag, ASN1_Tag class_tag, const std::string &str) |
DER_Encoder & | add_object (ASN1_Tag type_tag, ASN1_Tag class_tag, const std::vector< uint8_t > &rep) |
DER_Encoder & | add_object (ASN1_Tag type_tag, ASN1_Tag class_tag, const uint8_t rep[], size_t length) |
DER_Encoder & | add_object (ASN1_Tag type_tag, ASN1_Tag class_tag, uint8_t val) |
DER_Encoder ()=default | |
DER_Encoder (append_fn append) | |
DER_Encoder (secure_vector< uint8_t > &vec) | |
DER_Encoder (std::vector< uint8_t > &vec) | |
DER_Encoder & | encode (bool b) |
DER_Encoder & | encode (bool b, ASN1_Tag type_tag, ASN1_Tag class_tag=CONTEXT_SPECIFIC) |
DER_Encoder & | encode (const ASN1_Object &obj) |
DER_Encoder & | encode (const BigInt &n) |
DER_Encoder & | encode (const BigInt &n, ASN1_Tag type_tag, ASN1_Tag class_tag=CONTEXT_SPECIFIC) |
template<typename Alloc > | |
DER_Encoder & | encode (const std::vector< uint8_t, Alloc > &bytes, ASN1_Tag real_type, ASN1_Tag type_tag, ASN1_Tag class_tag) |
template<typename Alloc > | |
DER_Encoder & | encode (const std::vector< uint8_t, Alloc > &vec, ASN1_Tag real_type) |
DER_Encoder & | encode (const uint8_t v[], size_t len, ASN1_Tag real_type, ASN1_Tag type_tag, ASN1_Tag class_tag=CONTEXT_SPECIFIC) |
DER_Encoder & | encode (const uint8_t val[], size_t len, ASN1_Tag real_type) |
DER_Encoder & | encode (size_t s) |
DER_Encoder & | encode (size_t s, ASN1_Tag type_tag, ASN1_Tag class_tag=CONTEXT_SPECIFIC) |
DER_Encoder & | encode_if (bool pred, const ASN1_Object &obj) |
DER_Encoder & | encode_if (bool pred, DER_Encoder &enc) |
template<typename T > | |
DER_Encoder & | encode_list (const std::vector< T > &values) |
DER_Encoder & | encode_null () |
template<typename T > | |
DER_Encoder & | encode_optional (const T &value, const T &default_value) |
DER_Encoder & | end_cons () |
DER_Encoder & | end_explicit () |
secure_vector< uint8_t > | get_contents () |
std::vector< uint8_t > | get_contents_unlocked () |
template<typename Alloc > | |
DER_Encoder & | raw_bytes (const std::vector< uint8_t, Alloc > &val) |
DER_Encoder & | raw_bytes (const uint8_t val[], size_t len) |
DER_Encoder & | start_cons (ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL) |
DER_Encoder & | start_explicit (uint16_t type_tag) |
typedef std::function<void (const uint8_t[], size_t)> Botan::DER_Encoder::append_fn |
|
default |
DER encode, writing to an internal buffer Use get_contents or get_contents_unlocked to read the results after all encoding is completed.
Botan::DER_Encoder::DER_Encoder | ( | secure_vector< uint8_t > & | vec | ) |
DER encode, writing to
vec | If this constructor is used, get_contents* may not be called. |
Definition at line 69 of file der_enc.cpp.
Botan::DER_Encoder::DER_Encoder | ( | std::vector< uint8_t > & | vec | ) |
DER encode, writing to
vec | If this constructor is used, get_contents* may not be called. |
Definition at line 77 of file der_enc.cpp.
|
inline |
|
inline |
Definition at line 166 of file der_enc.h.
DER_Encoder & Botan::DER_Encoder::add_object | ( | ASN1_Tag | type_tag, |
ASN1_Tag | class_tag, | ||
const std::string & | str | ||
) |
Definition at line 388 of file der_enc.cpp.
References add_object(), and Botan::cast_char_ptr_to_uint8().
|
inline |
DER_Encoder & Botan::DER_Encoder::add_object | ( | ASN1_Tag | type_tag, |
ASN1_Tag | class_tag, | ||
const uint8_t | rep[], | ||
size_t | length | ||
) |
Definition at line 249 of file der_enc.cpp.
Referenced by add_object(), encode(), Botan::OID::encode_into(), Botan::ASN1_String::encode_into(), Botan::ASN1_Time::encode_into(), and encode_null().
DER_Encoder & Botan::DER_Encoder::add_object | ( | ASN1_Tag | type_tag, |
ASN1_Tag | class_tag, | ||
uint8_t | val | ||
) |
Definition at line 399 of file der_enc.cpp.
References add_object().
DER_Encoder & Botan::DER_Encoder::encode | ( | bool | b | ) |
Definition at line 285 of file der_enc.cpp.
References Botan::BOOLEAN, encode(), and Botan::UNIVERSAL.
Referenced by Botan::GOST_3410_PublicKey::algorithm_identifier(), Botan::OCSP::Request::BER_encode(), Botan::PKCS8::BER_encode(), Botan::PKCS8::BER_encode_encrypted_pbkdf_iter(), Botan::PKCS8::BER_encode_encrypted_pbkdf_msec(), Botan::PSSR::config_for_x509(), Botan::PKCS10_Request::create(), Botan::TLS::Session::DER_encode(), Botan::EC_Group::DER_encode(), Botan::DL_Group::DER_encode(), encode(), Botan::AlgorithmIdentifier::encode_into(), Botan::Extensions::encode_into(), Botan::CRL_Entry::encode_into(), Botan::OCSP::CertID::encode_into(), Botan::X509_Object::encode_into(), Botan::X509_DN::encode_into(), Botan::AlternativeName::encode_into(), Botan::Attribute::encode_into(), Botan::X509_Object::make_signed(), Botan::Curve25519_PrivateKey::private_key_bits(), Botan::DL_Scheme_PrivateKey::private_key_bits(), Botan::EC_PrivateKey::private_key_bits(), Botan::Ed25519_PrivateKey::private_key_bits(), Botan::McEliece_PrivateKey::private_key_bits(), Botan::RSA_PrivateKey::private_key_bits(), Botan::XMSS_PrivateKey::private_key_bits(), Botan::Private_Key::private_key_info(), Botan::TPM_PrivateKey::public_key_bits(), Botan::DL_Scheme_PublicKey::public_key_bits(), Botan::GOST_3410_PublicKey::public_key_bits(), Botan::McEliece_PublicKey::public_key_bits(), Botan::RSA_PublicKey::public_key_bits(), Botan::XMSS_PublicKey::public_key_bits(), and Botan::Public_Key::subject_public_key().
DER_Encoder & Botan::DER_Encoder::encode | ( | bool | b, |
ASN1_Tag | type_tag, | ||
ASN1_Tag | class_tag = CONTEXT_SPECIFIC |
||
) |
Definition at line 318 of file der_enc.cpp.
References add_object().
DER_Encoder & Botan::DER_Encoder::encode | ( | const ASN1_Object & | obj | ) |
Definition at line 379 of file der_enc.cpp.
References Botan::ASN1_Object::encode_into().
DER_Encoder & Botan::DER_Encoder::encode | ( | const BigInt & | n | ) |
Definition at line 301 of file der_enc.cpp.
References encode(), Botan::INTEGER, and Botan::UNIVERSAL.
DER_Encoder & Botan::DER_Encoder::encode | ( | const BigInt & | n, |
ASN1_Tag | type_tag, | ||
ASN1_Tag | class_tag = CONTEXT_SPECIFIC |
||
) |
Definition at line 337 of file der_enc.cpp.
References add_object(), Botan::BigInt::binary_encode(), Botan::BigInt::bits(), and Botan::BigInt::bytes().
|
inline |
Definition at line 111 of file der_enc.h.
References Botan::PEM_Code::encode().
|
inline |
Definition at line 88 of file der_enc.h.
References Botan::PEM_Code::encode().
DER_Encoder & Botan::DER_Encoder::encode | ( | const uint8_t | v[], |
size_t | len, | ||
ASN1_Tag | real_type, | ||
ASN1_Tag | type_tag, | ||
ASN1_Tag | class_tag = CONTEXT_SPECIFIC |
||
) |
Definition at line 361 of file der_enc.cpp.
References add_object(), Botan::BIT_STRING, and Botan::OCTET_STRING.
DER_Encoder & Botan::DER_Encoder::encode | ( | const uint8_t | val[], |
size_t | len, | ||
ASN1_Tag | real_type | ||
) |
Definition at line 309 of file der_enc.cpp.
References encode(), and Botan::UNIVERSAL.
DER_Encoder & Botan::DER_Encoder::encode | ( | size_t | s | ) |
Definition at line 293 of file der_enc.cpp.
References encode(), Botan::INTEGER, and Botan::UNIVERSAL.
DER_Encoder & Botan::DER_Encoder::encode | ( | size_t | s, |
ASN1_Tag | type_tag, | ||
ASN1_Tag | class_tag = CONTEXT_SPECIFIC |
||
) |
Definition at line 328 of file der_enc.cpp.
References encode().
|
inline |
Definition at line 150 of file der_enc.h.
References Botan::PEM_Code::encode().
|
inline |
Definition at line 143 of file der_enc.h.
References get_contents().
|
inline |
Definition at line 128 of file der_enc.h.
References Botan::PEM_Code::encode().
DER_Encoder & Botan::DER_Encoder::encode_null | ( | ) |
Definition at line 277 of file der_enc.cpp.
References add_object(), Botan::NULL_TAG, and Botan::UNIVERSAL.
Referenced by Botan::EC_Group::DER_encode().
|
inline |
Definition at line 120 of file der_enc.h.
References Botan::PEM_Code::encode().
Referenced by Botan::Extensions::encode_into().
DER_Encoder & Botan::DER_Encoder::end_cons | ( | ) |
Definition at line 191 of file der_enc.cpp.
Referenced by Botan::GOST_3410_PublicKey::algorithm_identifier(), Botan::OCSP::Request::BER_encode(), Botan::PKCS8::BER_encode(), Botan::PKCS8::BER_encode_encrypted_pbkdf_iter(), Botan::PKCS8::BER_encode_encrypted_pbkdf_msec(), Botan::PSSR::config_for_x509(), Botan::PKCS10_Request::create(), Botan::TLS::Session::DER_encode(), Botan::EC_Group::DER_encode(), Botan::DL_Group::DER_encode(), Botan::AlgorithmIdentifier::encode_into(), Botan::Extensions::encode_into(), Botan::CRL_Entry::encode_into(), Botan::OCSP::CertID::encode_into(), Botan::X509_Object::encode_into(), Botan::X509_DN::encode_into(), Botan::AlternativeName::encode_into(), Botan::Attribute::encode_into(), end_explicit(), Botan::X509_Object::make_signed(), Botan::EC_PrivateKey::private_key_bits(), Botan::McEliece_PrivateKey::private_key_bits(), Botan::RSA_PrivateKey::private_key_bits(), Botan::Private_Key::private_key_info(), Botan::TPM_PrivateKey::public_key_bits(), Botan::McEliece_PublicKey::public_key_bits(), Botan::RSA_PublicKey::public_key_bits(), Botan::ASN1::put_in_sequence(), and Botan::Public_Key::subject_public_key().
DER_Encoder & Botan::DER_Encoder::end_explicit | ( | ) |
Definition at line 220 of file der_enc.cpp.
References end_cons().
Referenced by Botan::OCSP::Request::BER_encode(), Botan::PKCS10_Request::create(), and Botan::AlternativeName::encode_into().
secure_vector< uint8_t > Botan::DER_Encoder::get_contents | ( | ) |
Definition at line 152 of file der_enc.cpp.
Referenced by Botan::PKCS10_Request::create(), Botan::TLS::Session::DER_encode(), encode_if(), Botan::Curve25519_PrivateKey::private_key_bits(), Botan::DL_Scheme_PrivateKey::private_key_bits(), Botan::EC_PrivateKey::private_key_bits(), Botan::Ed25519_PrivateKey::private_key_bits(), Botan::McEliece_PrivateKey::private_key_bits(), Botan::RSA_PrivateKey::private_key_bits(), Botan::XMSS_PrivateKey::private_key_bits(), and Botan::Private_Key::private_key_info().
std::vector< uint8_t > Botan::DER_Encoder::get_contents_unlocked | ( | ) |
Return the encoded contents as a std::vector
If using this function, instead pass a std::vector to the contructor of DER_Encoder where the output will be placed. This avoids several unecessary copies.
Definition at line 165 of file der_enc.cpp.
|
inline |
DER_Encoder & Botan::DER_Encoder::raw_bytes | ( | const uint8_t | val[], |
size_t | len | ||
) |
Insert raw bytes directly into the output stream
Definition at line 228 of file der_enc.cpp.
Referenced by Botan::PKCS10_Request::create(), Botan::AlgorithmIdentifier::encode_into(), Botan::X509_Object::encode_into(), Botan::X509_DN::encode_into(), Botan::Attribute::encode_into(), Botan::X509_Object::make_signed(), and Botan::ASN1::put_in_sequence().
DER_Encoder & Botan::DER_Encoder::start_cons | ( | ASN1_Tag | type_tag, |
ASN1_Tag | class_tag = UNIVERSAL |
||
) |
Definition at line 181 of file der_enc.cpp.
Referenced by Botan::GOST_3410_PublicKey::algorithm_identifier(), Botan::OCSP::Request::BER_encode(), Botan::PKCS8::BER_encode(), Botan::PKCS8::BER_encode_encrypted_pbkdf_iter(), Botan::PKCS8::BER_encode_encrypted_pbkdf_msec(), Botan::PSSR::config_for_x509(), Botan::PKCS10_Request::create(), Botan::TLS::Session::DER_encode(), Botan::EC_Group::DER_encode(), Botan::DL_Group::DER_encode(), Botan::AlgorithmIdentifier::encode_into(), Botan::Extensions::encode_into(), Botan::CRL_Entry::encode_into(), Botan::OCSP::CertID::encode_into(), Botan::X509_Object::encode_into(), Botan::X509_DN::encode_into(), Botan::AlternativeName::encode_into(), Botan::Attribute::encode_into(), Botan::X509_Object::make_signed(), Botan::EC_PrivateKey::private_key_bits(), Botan::McEliece_PrivateKey::private_key_bits(), Botan::RSA_PrivateKey::private_key_bits(), Botan::Private_Key::private_key_info(), Botan::TPM_PrivateKey::public_key_bits(), Botan::McEliece_PublicKey::public_key_bits(), Botan::RSA_PublicKey::public_key_bits(), Botan::ASN1::put_in_sequence(), start_explicit(), and Botan::Public_Key::subject_public_key().
DER_Encoder & Botan::DER_Encoder::start_explicit | ( | uint16_t | type_tag | ) |
Definition at line 206 of file der_enc.cpp.
References Botan::CONTEXT_SPECIFIC, Botan::SET, and start_cons().
Referenced by Botan::OCSP::Request::BER_encode(), Botan::PKCS10_Request::create(), and Botan::AlternativeName::encode_into().