Botan
2.17.3
Crypto and TLS for C++11
|
#include <hmac.h>
Public Member Functions | |
void | clear () override |
MessageAuthenticationCode * | clone () const override |
void | final (uint8_t out[]) |
secure_vector< uint8_t > | final () |
template<typename Alloc > | |
void | final (std::vector< uint8_t, Alloc > &out) |
std::vector< uint8_t > | final_stdvec () |
HMAC (HashFunction *hash) | |
HMAC (const HMAC &)=delete | |
Key_Length_Specification | key_spec () const override |
size_t | maximum_keylength () const |
size_t | minimum_keylength () const |
std::string | name () const override |
HMAC & | operator= (const HMAC &)=delete |
size_t | output_length () const override |
secure_vector< uint8_t > | process (const uint8_t in[], size_t length) |
secure_vector< uint8_t > | process (const secure_vector< uint8_t > &in) |
secure_vector< uint8_t > | process (const std::vector< uint8_t > &in) |
secure_vector< uint8_t > | process (const std::string &in) |
virtual std::string | provider () const |
void | set_key (const SymmetricKey &key) |
template<typename Alloc > | |
void | set_key (const std::vector< uint8_t, Alloc > &key) |
void | set_key (const uint8_t key[], size_t length) |
template<typename Alloc > | |
void | start (const std::vector< uint8_t, Alloc > &nonce) |
void | start (const uint8_t nonce[], size_t nonce_len) |
void | start () |
virtual void | start_msg (const uint8_t nonce[], size_t nonce_len) |
void | update (const uint8_t in[], size_t length) |
void | update (const secure_vector< uint8_t > &in) |
void | update (const std::vector< uint8_t > &in) |
void | update (const std::string &str) |
void | update (uint8_t in) |
void | update_be (uint16_t val) |
void | update_be (uint32_t val) |
void | update_be (uint64_t val) |
void | update_le (uint16_t val) |
void | update_le (uint32_t val) |
void | update_le (uint64_t val) |
bool | valid_keylength (size_t length) const |
virtual bool | verify_mac (const uint8_t in[], size_t length) |
virtual bool | verify_mac (const std::vector< uint8_t > &in) |
virtual bool | verify_mac (const secure_vector< uint8_t > &in) |
Static Public Member Functions | |
static std::unique_ptr< MessageAuthenticationCode > | create (const std::string &algo_spec, const std::string &provider="") |
static std::unique_ptr< MessageAuthenticationCode > | create_or_throw (const std::string &algo_spec, const std::string &provider="") |
static std::vector< std::string > | providers (const std::string &algo_spec) |
Protected Member Functions | |
void | verify_key_set (bool cond) const |
|
explicit |
|
delete |
|
overridevirtual |
Reset the state.
Implements Botan::SymmetricAlgorithm.
Definition at line 115 of file hmac.cpp.
References Botan::zap().
|
overridevirtual |
Get a new object representing the same algorithm as *this
Implements Botan::MessageAuthenticationCode.
Definition at line 133 of file hmac.cpp.
References HMAC().
|
staticinherited |
Create an instance based on a name If provider is empty then best available is chosen.
algo_spec | algorithm name |
provider | provider implementation to use |
Definition at line 46 of file mac.cpp.
References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_as_integer(), Botan::SCAN_Name::arg_count(), BOTAN_UNUSED, Botan::HashFunction::create(), Botan::BlockCipher::create(), and Botan::MessageAuthenticationCode::provider().
Referenced by botan_mac_init(), Botan::KDF::create(), Botan::PBKDF::create(), Botan::PasswordHashFamily::create(), Botan::MessageAuthenticationCode::create_or_throw(), and Botan::RFC6979_Nonce_Generator::RFC6979_Nonce_Generator().
|
staticinherited |
Definition at line 141 of file mac.cpp.
References Botan::MessageAuthenticationCode::create(), and Botan::MessageAuthenticationCode::provider().
Referenced by Botan::AutoSeeded_RNG::AutoSeeded_RNG(), Botan::ChaCha_RNG::ChaCha_RNG(), Botan::TLS::Connection_Cipher_State::Connection_Cipher_State(), Botan::ECIES_System_Params::create_mac(), Botan::Sodium::crypto_auth_hmacsha256(), Botan::Sodium::crypto_auth_hmacsha512(), Botan::Sodium::crypto_auth_hmacsha512256(), Botan::Sodium::crypto_onetimeauth_poly1305(), Botan::Sodium::crypto_secretbox_detached(), Botan::Sodium::crypto_secretbox_open_detached(), Botan::Sodium::crypto_secretbox_xsalsa20poly1305(), Botan::Sodium::crypto_secretbox_xsalsa20poly1305_open(), Botan::Sodium::crypto_shorthash_siphash24(), Botan::TLS::Session::decrypt(), Botan::CryptoBox::decrypt_bin(), Botan::CryptoBox::encrypt(), Botan::TLS::Session::encrypt(), Botan::Encrypted_PSK_Database::Encrypted_PSK_Database(), Botan::FPE_FE1::FPE_FE1(), Botan::TLS::Hello_Verify_Request::Hello_Verify_Request(), Botan::hkdf_expand_label(), Botan::HOTP::HOTP(), and Botan::scrypt().
|
inlineinherited |
Complete the computation and retrieve the final result.
out | The byte array to be filled with the result. Must be of length output_length() |
Definition at line 83 of file buf_comp.h.
Referenced by botan_mac_final(), Botan::ed25519_gen_keypair(), Botan::ed25519_sign(), Botan::ed25519_verify(), Botan::TLS::TLS_CBC_HMAC_AEAD_Encryption::finish(), Botan::TLS::TLS_CBC_HMAC_AEAD_Decryption::finish(), and Botan::pbkdf2().
|
inlineinherited |
Complete the computation and retrieve the final result.
Definition at line 90 of file buf_comp.h.
|
inlineinherited |
Definition at line 105 of file buf_comp.h.
|
inlineinherited |
Definition at line 97 of file buf_comp.h.
|
overridevirtual |
Implements Botan::SymmetricAlgorithm.
|
inlineinherited |
Definition at line 120 of file sym_algo.h.
|
inlineinherited |
Definition at line 128 of file sym_algo.h.
Referenced by botan_block_cipher_get_keyspec(), and botan_mac_get_keyspec().
|
overridevirtual |
Implements Botan::SymmetricAlgorithm.
|
overridevirtual |
Implements Botan::Buffered_Computation.
|
inlineinherited |
Update and finalize computation. Does the same as calling update() and final() consecutively.
in | the input to process as a byte array |
length | the length of the byte array |
Definition at line 118 of file buf_comp.h.
|
inlineinherited |
Update and finalize computation. Does the same as calling update() and final() consecutively.
in | the input to process |
Definition at line 130 of file buf_comp.h.
|
inlineinherited |
Update and finalize computation. Does the same as calling update() and final() consecutively.
in | the input to process |
Definition at line 142 of file buf_comp.h.
|
inlineinherited |
Update and finalize computation. Does the same as calling update() and final() consecutively.
in | the input to process as a string |
Definition at line 154 of file buf_comp.h.
References update.
|
inlinevirtualinherited |
Definition at line 135 of file mac.h.
Referenced by Botan::MessageAuthenticationCode::create(), and Botan::MessageAuthenticationCode::create_or_throw().
|
staticinherited |
|
inlineinherited |
Set the symmetric key of this object.
key | the SymmetricKey to be set. |
Definition at line 147 of file sym_algo.h.
References Botan::OctetString::begin(), and Botan::OctetString::length().
Referenced by Botan::aont_package(), Botan::aont_unpackage(), botan_block_cipher_set_key(), botan_cipher_set_key(), botan_mac_set_key(), Botan::Sodium::crypto_stream_salsa20(), Botan::Sodium::crypto_stream_salsa20_xor_ic(), Botan::Sodium::crypto_stream_xsalsa20(), Botan::Sodium::crypto_stream_xsalsa20_xor_ic(), Botan::FPE::fe1_decrypt(), Botan::FPE::fe1_encrypt(), and Botan::Sodium::randombytes_buf_deterministic().
|
inlineinherited |
Definition at line 153 of file sym_algo.h.
|
inherited |
Set the symmetric key of this object.
key | the to be set as a byte array. |
length | in bytes of key param |
Definition at line 17 of file sym_algo.cpp.
References Botan::SymmetricAlgorithm::name(), and Botan::SymmetricAlgorithm::valid_keylength().
|
inlineinherited |
Begin processing a message with a nonce
nonce | the per message nonce |
Definition at line 75 of file mac.h.
|
inlineinherited |
Begin processing a message.
nonce | the per message nonce |
nonce_len | length of nonce |
Definition at line 85 of file mac.h.
|
inlineinherited |
Begin processing a message.
Definition at line 93 of file mac.h.
|
virtualinherited |
Prepare for processing a message under the specified nonce
Most MACs neither require nor support a nonce; for these algorithms calling start_msg
is optional and calling it with anything other than an empty string is an error. One MAC which requires a per-message nonce be specified is GMAC.
nonce | the message nonce bytes |
nonce_len | the size of len in bytes Default implementation simply rejects all non-empty nonces since most hash/MAC algorithms do not support randomization |
Definition at line 151 of file mac.cpp.
References BOTAN_UNUSED, and Botan::SymmetricAlgorithm::name().
|
inlineinherited |
Add new input to process.
in | the input to process as a byte array |
length | of param in in bytes |
Definition at line 33 of file buf_comp.h.
Referenced by botan_mac_update(), Botan::ed25519_gen_keypair(), Botan::ed25519_sign(), Botan::ed25519_verify(), Botan::TLS::TLS_CBC_HMAC_AEAD_Encryption::finish(), Botan::TLS::TLS_CBC_HMAC_AEAD_Decryption::finish(), and Botan::pbkdf2().
|
inlineinherited |
Add new input to process.
in | the input to process as a secure_vector |
Definition at line 39 of file buf_comp.h.
|
inlineinherited |
Add new input to process.
in | the input to process as a std::vector |
Definition at line 48 of file buf_comp.h.
|
inlineinherited |
Add new input to process.
str | the input to process as a std::string. Will be interpreted as a byte array based on the strings encoding. |
Definition at line 66 of file buf_comp.h.
References Botan::cast_char_ptr_to_uint8().
|
inlineinherited |
|
inherited |
Definition at line 12 of file buf_comp.cpp.
References Botan::store_be().
Referenced by Botan::pbkdf2().
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inlineinherited |
Check whether a given key length is valid for this algorithm.
length | the key length to be checked. |
Definition at line 138 of file sym_algo.h.
Referenced by Botan::aont_package(), Botan::aont_unpackage(), and Botan::SymmetricAlgorithm::set_key().
|
inlineprotectedinherited |
Definition at line 171 of file sym_algo.h.
Referenced by Botan::Salsa20::cipher(), Botan::CTR_BE::cipher(), Botan::RC4::cipher(), Botan::SHAKE_128_Cipher::cipher(), Botan::ChaCha::cipher(), Botan::DES::decrypt_n(), Botan::Camellia_128::decrypt_n(), Botan::SEED::decrypt_n(), Botan::CAST_128::decrypt_n(), Botan::AES_128::decrypt_n(), Botan::IDEA::decrypt_n(), Botan::Twofish::decrypt_n(), Botan::CAST_256::decrypt_n(), Botan::SHACAL2::decrypt_n(), Botan::Blowfish::decrypt_n(), Botan::KASUMI::decrypt_n(), Botan::MISTY1::decrypt_n(), Botan::XTEA::decrypt_n(), Botan::SM4::decrypt_n(), Botan::DESX::decrypt_n(), Botan::Noekeon::decrypt_n(), Botan::Serpent::decrypt_n(), Botan::Threefish_512::decrypt_n(), Botan::Lion::decrypt_n(), Botan::ARIA_128::decrypt_n(), Botan::Camellia_192::decrypt_n(), Botan::TripleDES::decrypt_n(), Botan::ARIA_192::decrypt_n(), Botan::Camellia_256::decrypt_n(), Botan::AES_192::decrypt_n(), Botan::GOST_28147_89::decrypt_n(), Botan::ARIA_256::decrypt_n(), Botan::AES_256::decrypt_n(), Botan::MISTY1::encrypt_n(), Botan::Noekeon::encrypt_n(), Botan::CAST_128::encrypt_n(), Botan::SEED::encrypt_n(), Botan::CAST_256::encrypt_n(), Botan::SHACAL2::encrypt_n(), Botan::SM4::encrypt_n(), Botan::IDEA::encrypt_n(), Botan::KASUMI::encrypt_n(), Botan::AES_128::encrypt_n(), Botan::DES::encrypt_n(), Botan::Blowfish::encrypt_n(), Botan::Twofish::encrypt_n(), Botan::Camellia_128::encrypt_n(), Botan::XTEA::encrypt_n(), Botan::DESX::encrypt_n(), Botan::Serpent::encrypt_n(), Botan::Threefish_512::encrypt_n(), Botan::Lion::encrypt_n(), Botan::ARIA_128::encrypt_n(), Botan::Camellia_192::encrypt_n(), Botan::TripleDES::encrypt_n(), Botan::ARIA_192::encrypt_n(), Botan::Camellia_256::encrypt_n(), Botan::AES_192::encrypt_n(), Botan::GOST_28147_89::encrypt_n(), Botan::ARIA_256::encrypt_n(), Botan::AES_256::encrypt_n(), Botan::OCB_Encryption::finish(), Botan::OCB_Decryption::finish(), Botan::GHASH::ghash_update(), Botan::CFB_Encryption::process(), Botan::CFB_Decryption::process(), Botan::Salsa20::seek(), Botan::CTR_BE::seek(), Botan::ChaCha::seek(), Botan::OCB_Mode::set_associated_data(), Botan::Salsa20::set_iv(), Botan::ChaCha::set_iv(), Botan::GHASH::update(), Botan::GHASH::update_associated_data(), and Botan::ChaCha::write_keystream().
|
virtualinherited |
Verify a MAC.
in | the MAC to verify as a byte array |
length | the length of param in |
Definition at line 161 of file mac.cpp.
References Botan::constant_time_compare().
|
inlinevirtualinherited |
Verify a MAC.
in | the MAC to verify as a byte array |
Definition at line 111 of file mac.h.
|
inlinevirtualinherited |
Verify a MAC.
in | the MAC to verify as a byte array |
Definition at line 121 of file mac.h.