Botan 3.6.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_Type type_tag, ASN1_Class class_tag, const secure_vector< uint8_t > &rep) |
DER_Encoder & | add_object (ASN1_Type type_tag, ASN1_Class class_tag, const std::vector< uint8_t > &rep) |
DER_Encoder & | add_object (ASN1_Type type_tag, ASN1_Class class_tag, const uint8_t rep[], size_t length) |
DER_Encoder & | add_object (ASN1_Type type_tag, ASN1_Class class_tag, std::string_view str) |
DER_Encoder & | add_object (ASN1_Type type_tag, ASN1_Class 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_Type type_tag, ASN1_Class class_tag=ASN1_Class::ContextSpecific) |
DER_Encoder & | encode (const ASN1_Object &obj) |
DER_Encoder & | encode (const BigInt &n) |
DER_Encoder & | encode (const BigInt &n, ASN1_Type type_tag, ASN1_Class class_tag=ASN1_Class::ContextSpecific) |
template<typename Alloc > | |
DER_Encoder & | encode (const std::vector< uint8_t, Alloc > &bytes, ASN1_Type real_type, ASN1_Type type_tag, ASN1_Class class_tag) |
template<typename Alloc > | |
DER_Encoder & | encode (const std::vector< uint8_t, Alloc > &vec, ASN1_Type real_type) |
DER_Encoder & | encode (const uint8_t v[], size_t len, ASN1_Type real_type, ASN1_Type type_tag, ASN1_Class class_tag=ASN1_Class::ContextSpecific) |
DER_Encoder & | encode (const uint8_t val[], size_t len, ASN1_Type real_type) |
DER_Encoder & | encode (size_t s) |
DER_Encoder & | encode (size_t s, ASN1_Type type_tag, ASN1_Class class_tag=ASN1_Class::ContextSpecific) |
DER_Encoder & | encode_if (bool pred, const ASN1_Object &obj) |
DER_Encoder & | encode_if (bool pred, DER_Encoder &enc) |
DER_Encoder & | encode_if (bool pred, size_t num) |
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_Type type_tag, ASN1_Class class_tag) |
DER_Encoder & | start_context_specific (uint32_t tag) |
DER_Encoder & | start_explicit (uint16_t type_tag) |
DER_Encoder & | start_explicit_context_specific (uint32_t tag) |
DER_Encoder & | start_sequence () |
DER_Encoder & | start_set () |
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 67 of file der_enc.cpp.
References Botan::b.
Botan::DER_Encoder::DER_Encoder | ( | std::vector< uint8_t > & | vec | ) |
|
inline |
|
inline |
Definition at line 173 of file der_enc.h.
|
inline |
DER_Encoder & Botan::DER_Encoder::add_object | ( | ASN1_Type | type_tag, |
ASN1_Class | class_tag, | ||
const uint8_t | rep[], | ||
size_t | length ) |
Definition at line 222 of file der_enc.cpp.
Referenced by add_object(), add_object(), encode(), encode(), encode(), Botan::AlternativeName::encode_into(), Botan::ASN1_String::encode_into(), Botan::ASN1_Time::encode_into(), Botan::Cert_Extension::CRL_Distribution_Points::Distribution_Point::encode_into(), Botan::OID::encode_into(), and encode_null().
DER_Encoder & Botan::DER_Encoder::add_object | ( | ASN1_Type | type_tag, |
ASN1_Class | class_tag, | ||
std::string_view | str ) |
Definition at line 342 of file der_enc.cpp.
References add_object(), and Botan::cast_char_ptr_to_uint8().
DER_Encoder & Botan::DER_Encoder::add_object | ( | ASN1_Type | type_tag, |
ASN1_Class | class_tag, | ||
uint8_t | val ) |
Definition at line 351 of file der_enc.cpp.
References add_object().
DER_Encoder & Botan::DER_Encoder::encode | ( | bool | b | ) |
Definition at line 250 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::PKCS10_Request::create(), Botan::DL_Group::DER_encode(), Botan::DL_PrivateKey::DER_encode(), Botan::DL_PublicKey::DER_encode(), Botan::EC_Group::DER_encode(), Botan::TLS::Session::DER_encode(), encode(), encode(), encode(), encode(), encode(), Botan::AlgorithmIdentifier::encode_into(), Botan::AlternativeName::encode_into(), Botan::Attribute::encode_into(), Botan::CRL_Entry::encode_into(), Botan::Extensions::encode_into(), Botan::OCSP::CertID::encode_into(), Botan::PSS_Params::encode_into(), Botan::X509_DN::encode_into(), Botan::X509_Object::encode_into(), Botan::X509_Object::make_signed(), Botan::EC_PrivateKey::private_key_bits(), Botan::Ed25519_PrivateKey::private_key_bits(), Botan::Ed448_PrivateKey::private_key_bits(), Botan::McEliece_PrivateKey::private_key_bits(), Botan::RSA_PrivateKey::private_key_bits(), Botan::X25519_PrivateKey::private_key_bits(), Botan::X448_PrivateKey::private_key_bits(), Botan::XMSS_PrivateKey::private_key_bits(), Botan::Private_Key::private_key_info(), Botan::GOST_3410_PublicKey::public_key_bits(), Botan::McEliece_PublicKey::public_key_bits(), Botan::RSA_PublicKey::public_key_bits(), Botan::TPM_PrivateKey::public_key_bits(), Botan::XMSS_PublicKey::public_key_bits(), Botan::PSS_Params::serialize(), Botan::TLS::Certificate_Request_12::serialize(), Botan::EC_Group_Data::set_oid(), and Botan::Public_Key::subject_public_key().
DER_Encoder & Botan::DER_Encoder::encode | ( | bool | b, |
ASN1_Type | type_tag, | ||
ASN1_Class | class_tag = ASN1_Class::ContextSpecific ) |
Definition at line 278 of file der_enc.cpp.
References add_object().
DER_Encoder & Botan::DER_Encoder::encode | ( | const ASN1_Object & | obj | ) |
Definition at line 334 of file der_enc.cpp.
References Botan::ASN1_Object::encode_into().
DER_Encoder & Botan::DER_Encoder::encode | ( | const BigInt & | n | ) |
Definition at line 264 of file der_enc.cpp.
References encode(), Botan::Integer, and Botan::Universal.
DER_Encoder & Botan::DER_Encoder::encode | ( | const BigInt & | n, |
ASN1_Type | type_tag, | ||
ASN1_Class | class_tag = ASN1_Class::ContextSpecific ) |
Definition at line 293 of file der_enc.cpp.
References add_object(), Botan::BigInt::bits(), Botan::BigInt::bytes(), and Botan::BigInt::serialize().
|
inline |
|
inline |
DER_Encoder & Botan::DER_Encoder::encode | ( | const uint8_t | v[], |
size_t | len, | ||
ASN1_Type | real_type, | ||
ASN1_Type | type_tag, | ||
ASN1_Class | class_tag = ASN1_Class::ContextSpecific ) |
Definition at line 318 of file der_enc.cpp.
References add_object(), Botan::BitString, and Botan::OctetString.
DER_Encoder & Botan::DER_Encoder::encode | ( | const uint8_t | val[], |
size_t | len, | ||
ASN1_Type | real_type ) |
Definition at line 271 of file der_enc.cpp.
References encode(), and Botan::Universal.
DER_Encoder & Botan::DER_Encoder::encode | ( | size_t | s | ) |
Definition at line 257 of file der_enc.cpp.
References encode(), Botan::BigInt::from_u64(), Botan::Integer, and Botan::Universal.
DER_Encoder & Botan::DER_Encoder::encode | ( | size_t | s, |
ASN1_Type | type_tag, | ||
ASN1_Class | class_tag = ASN1_Class::ContextSpecific ) |
Definition at line 286 of file der_enc.cpp.
References encode(), and Botan::BigInt::from_u64().
|
inline |
|
inline |
Definition at line 146 of file der_enc.h.
References get_contents().
|
inline |
|
inline |
Definition at line 131 of file der_enc.h.
Referenced by Botan::TLS::Session::DER_encode().
DER_Encoder & Botan::DER_Encoder::encode_null | ( | ) |
Definition at line 243 of file der_enc.cpp.
References add_object(), Botan::Null, and Botan::Universal.
|
inline |
Definition at line 123 of file der_enc.h.
Referenced by Botan::Extensions::encode_into().
DER_Encoder & Botan::DER_Encoder::end_cons | ( | ) |
Definition at line 171 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::PKCS10_Request::create(), Botan::DL_Group::DER_encode(), Botan::EC_Group::DER_encode(), Botan::TLS::Session::DER_encode(), Botan::AlgorithmIdentifier::encode_into(), Botan::AlternativeName::encode_into(), Botan::Attribute::encode_into(), Botan::Cert_Extension::CRL_Distribution_Points::Distribution_Point::encode_into(), Botan::CRL_Entry::encode_into(), Botan::Extensions::encode_into(), Botan::OCSP::CertID::encode_into(), Botan::PSS_Params::encode_into(), Botan::X509_DN::encode_into(), Botan::X509_Object::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::McEliece_PublicKey::public_key_bits(), Botan::RSA_PublicKey::public_key_bits(), Botan::TPM_PrivateKey::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 200 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 132 of file der_enc.cpp.
Referenced by Botan::PKCS10_Request::create(), Botan::DL_PrivateKey::DER_encode(), Botan::TLS::Session::DER_encode(), encode_if(), Botan::EC_PrivateKey::private_key_bits(), Botan::Ed25519_PrivateKey::private_key_bits(), Botan::Ed448_PrivateKey::private_key_bits(), Botan::McEliece_PrivateKey::private_key_bits(), Botan::RSA_PrivateKey::private_key_bits(), Botan::X25519_PrivateKey::private_key_bits(), Botan::X448_PrivateKey::private_key_bits(), Botan::XMSS_PrivateKey::private_key_bits(), Botan::Private_Key::private_key_info(), and Botan::TLS::Certificate_Request_12::serialize().
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 146 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 207 of file der_enc.cpp.
Referenced by Botan::PKCS10_Request::create(), Botan::AlgorithmIdentifier::encode_into(), Botan::Attribute::encode_into(), Botan::X509_DN::encode_into(), Botan::X509_Object::encode_into(), Botan::X509_Object::make_signed(), and Botan::ASN1::put_in_sequence().
DER_Encoder & Botan::DER_Encoder::start_cons | ( | ASN1_Type | type_tag, |
ASN1_Class | class_tag ) |
Definition at line 163 of file der_enc.cpp.
Referenced by Botan::Cert_Extension::CRL_Distribution_Points::Distribution_Point::encode_into(), and start_explicit().
|
inline |
Definition at line 68 of file der_enc.h.
Referenced by Botan::PSS_Params::encode_into().
DER_Encoder & Botan::DER_Encoder::start_explicit | ( | uint16_t | type_tag | ) |
Definition at line 186 of file der_enc.cpp.
References Botan::ContextSpecific, Botan::Set, and start_cons().
Referenced by Botan::OCSP::Request::BER_encode(), Botan::PKCS10_Request::create(), and Botan::AlternativeName::encode_into().
|
inline |
Definition at line 72 of file der_enc.h.
Referenced by Botan::EC_PrivateKey::private_key_bits().
|
inline |
Definition at line 64 of file der_enc.h.
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::PKCS10_Request::create(), Botan::DL_Group::DER_encode(), Botan::EC_Group::DER_encode(), Botan::TLS::Session::DER_encode(), Botan::AlgorithmIdentifier::encode_into(), Botan::AlternativeName::encode_into(), Botan::Attribute::encode_into(), Botan::Cert_Extension::CRL_Distribution_Points::Distribution_Point::encode_into(), Botan::CRL_Entry::encode_into(), Botan::Extensions::encode_into(), Botan::OCSP::CertID::encode_into(), Botan::PSS_Params::encode_into(), Botan::X509_DN::encode_into(), Botan::X509_Object::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::McEliece_PublicKey::public_key_bits(), Botan::RSA_PublicKey::public_key_bits(), Botan::TPM_PrivateKey::public_key_bits(), Botan::ASN1::put_in_sequence(), and Botan::Public_Key::subject_public_key().
|
inline |
Definition at line 66 of file der_enc.h.
Referenced by Botan::Attribute::encode_into(), and Botan::X509_DN::encode_into().