Botan 2.19.3
Crypto and TLS for C&
|
#include <mac.h>
Public Member Functions | |
virtual void | clear ()=0 |
virtual MessageAuthenticationCode * | clone () const =0 |
secure_vector< uint8_t > | final () |
template<typename Alloc > | |
void | final (std::vector< uint8_t, Alloc > &out) |
void | final (uint8_t out[]) |
std::vector< uint8_t > | final_stdvec () |
virtual Key_Length_Specification | key_spec () const =0 |
size_t | maximum_keylength () const |
size_t | minimum_keylength () const |
virtual std::string | name () const =0 |
virtual size_t | output_length () const =0 |
secure_vector< uint8_t > | process (const secure_vector< uint8_t > &in) |
secure_vector< uint8_t > | process (const std::string &in) |
secure_vector< uint8_t > | process (const std::vector< uint8_t > &in) |
secure_vector< uint8_t > | process (const uint8_t in[], size_t length) |
virtual std::string | provider () const |
template<typename Alloc > | |
void | set_key (const std::vector< uint8_t, Alloc > &key) |
void | set_key (const SymmetricKey &key) |
void | set_key (const uint8_t key[], size_t length) |
void | start () |
template<typename Alloc > | |
void | start (const std::vector< uint8_t, Alloc > &nonce) |
void | start (const uint8_t nonce[], size_t nonce_len) |
virtual void | start_msg (const uint8_t nonce[], size_t nonce_len) |
void | update (const secure_vector< uint8_t > &in) |
void | update (const std::string &str) |
void | update (const std::vector< uint8_t > &in) |
void | update (const uint8_t in[], size_t length) |
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 secure_vector< uint8_t > &in) |
virtual bool | verify_mac (const std::vector< uint8_t > &in) |
virtual bool | verify_mac (const uint8_t in[], size_t length) |
virtual | ~MessageAuthenticationCode ()=default |
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 |
This class represents Message Authentication Code (MAC) objects.
|
virtualdefault |
|
pure virtualinherited |
Reset the state.
Implemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::ARIA_128, Botan::ARIA_192, Botan::ARIA_256, Botan::Blowfish, Botan::Camellia_128, Botan::Camellia_192, Botan::Camellia_256, Botan::Cascade_Cipher, Botan::CAST_128, Botan::CAST_256, Botan::DES, Botan::TripleDES, Botan::DESX, Botan::GOST_28147_89, Botan::IDEA, Botan::KASUMI, Botan::Lion, Botan::MISTY1, Botan::Noekeon, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SM4, Botan::Threefish_512, Botan::Twofish, Botan::XTEA, Botan::CBC_MAC, Botan::CMAC, Botan::GMAC, Botan::HMAC, Botan::Poly1305, Botan::SipHash, Botan::ANSI_X919_MAC, Botan::FPE_FE1, Botan::CCM_Mode, Botan::ChaCha20Poly1305_Mode, Botan::EAX_Mode, Botan::GCM_Mode, Botan::OCB_Mode, Botan::SIV_Mode, Botan::CBC_Mode, Botan::XTS_Mode, Botan::ChaCha, Botan::CTR_BE, Botan::OFB, Botan::RC4, Botan::Salsa20, Botan::SHAKE_128_Cipher, Botan::GHASH, Botan::CFB_Mode, and Botan::TLS::TLS_CBC_HMAC_AEAD_Mode.
Referenced by botan_block_cipher_clear(), botan_cipher_clear(), botan_mac_clear(), Botan::TLS::TLS_CBC_HMAC_AEAD_Mode::clear(), and Botan::RC4::~RC4().
|
pure virtual |
Get a new object representing the same algorithm as *this
Implemented in Botan::CBC_MAC, Botan::CMAC, Botan::GMAC, Botan::HMAC, Botan::Poly1305, Botan::SipHash, and Botan::ANSI_X919_MAC.
|
static |
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::BlockCipher::create(), Botan::HashFunction::create(), and provider().
Referenced by botan_mac_init(), Botan::KDF::create(), Botan::PBKDF::create(), Botan::PasswordHashFamily::create(), create_or_throw(), and Botan::RFC6979_Nonce_Generator::RFC6979_Nonce_Generator().
|
static |
Definition at line 139 of file mac.cpp.
References create(), and provider().
Referenced by Botan::AutoSeeded_RNG::AutoSeeded_RNG(), Botan::AutoSeeded_RNG::AutoSeeded_RNG(), Botan::AutoSeeded_RNG::AutoSeeded_RNG(), Botan::ChaCha_RNG::ChaCha_RNG(), Botan::ChaCha_RNG::ChaCha_RNG(), Botan::ChaCha_RNG::ChaCha_RNG(), Botan::ChaCha_RNG::ChaCha_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::TLS::Session::encrypt(), Botan::CryptoBox::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.
Definition at line 90 of file buf_comp.h.
|
inlineinherited |
Definition at line 105 of file buf_comp.h.
|
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_hash_final(), 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 |
Definition at line 97 of file buf_comp.h.
|
pure virtualinherited |
Implemented in Botan::Block_Cipher_Fixed_Params< BS, KMIN, KMAX, KMOD, BaseClass >, Botan::Block_Cipher_Fixed_Params< 16, 16 >, Botan::Block_Cipher_Fixed_Params< 16, 16, 32, 8 >, Botan::Block_Cipher_Fixed_Params< 16, 24 >, Botan::Block_Cipher_Fixed_Params< 16, 32 >, Botan::Block_Cipher_Fixed_Params< 16, 4, 32, 4 >, Botan::Block_Cipher_Fixed_Params< 32, 16, 64, 4 >, Botan::Block_Cipher_Fixed_Params< 64, 64, 0, 1, Tweakable_Block_Cipher >, Botan::Block_Cipher_Fixed_Params< 8, 1, 56 >, Botan::Block_Cipher_Fixed_Params< 8, 11, 16 >, Botan::Block_Cipher_Fixed_Params< 8, 16 >, Botan::Block_Cipher_Fixed_Params< 8, 16, 24, 8 >, Botan::Block_Cipher_Fixed_Params< 8, 24 >, Botan::Block_Cipher_Fixed_Params< 8, 32 >, Botan::Block_Cipher_Fixed_Params< 8, 8 >, Botan::Cascade_Cipher, Botan::Lion, Botan::CBC_MAC, Botan::CMAC, Botan::GMAC, Botan::HMAC, Botan::Poly1305, Botan::SipHash, Botan::ANSI_X919_MAC, Botan::FPE_FE1, Botan::CCM_Mode, Botan::ChaCha20Poly1305_Mode, Botan::EAX_Mode, Botan::GCM_Mode, Botan::OCB_Mode, Botan::SIV_Mode, Botan::CBC_Mode, Botan::XTS_Mode, Botan::ChaCha, Botan::CTR_BE, Botan::OFB, Botan::RC4, Botan::Salsa20, Botan::SHAKE_128_Cipher, Botan::GHASH, Botan::CFB_Mode, and Botan::TLS::TLS_CBC_HMAC_AEAD_Mode.
Referenced by botan_cipher_get_keyspec(), botan_cipher_query_keylen(), Botan::CBC_Mode::key_spec(), Botan::XTS_Mode::key_spec(), and Botan::CFB_Mode::key_spec().
|
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().
|
pure virtualinherited |
Implemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::ARIA_128, Botan::ARIA_192, Botan::ARIA_256, Botan::Blowfish, Botan::Camellia_128, Botan::Camellia_192, Botan::Camellia_256, Botan::Cascade_Cipher, Botan::CAST_128, Botan::CAST_256, Botan::DES, Botan::TripleDES, Botan::DESX, Botan::GOST_28147_89, Botan::IDEA, Botan::KASUMI, Botan::Lion, Botan::MISTY1, Botan::Noekeon, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SM4, Botan::Threefish_512, Botan::Twofish, Botan::XTEA, Botan::CBC_MAC, Botan::CMAC, Botan::GMAC, Botan::HMAC, Botan::Poly1305, Botan::SipHash, Botan::ANSI_X919_MAC, Botan::FPE_FE1, Botan::CCM_Mode, Botan::ChaCha20Poly1305_Mode, Botan::EAX_Mode, Botan::GCM_Mode, Botan::OCB_Mode, Botan::SIV_Mode, Botan::CBC_Mode, Botan::XTS_Mode, Botan::ChaCha, Botan::CTR_BE, Botan::OFB, Botan::RC4, Botan::Salsa20, Botan::SHAKE_128_Cipher, Botan::GHASH, Botan::CFB_Mode, and Botan::TLS::TLS_CBC_HMAC_AEAD_Mode.
Referenced by Botan::CBC_Mode::CBC_Mode(), Botan::CBC_Mode::name(), Botan::XTS_Mode::name(), Botan::CFB_Mode::name(), Botan::AEAD_Mode::set_associated_data_n(), Botan::SymmetricAlgorithm::set_key(), start_msg(), and Botan::XTS_Mode::XTS_Mode().
|
pure virtualinherited |
Implemented in Botan::BLAKE2b, Botan::Adler32, Botan::CRC24, Botan::CRC32, Botan::Comb4P, Botan::GOST_34_11, Botan::Keccak_1600, Botan::MD4, Botan::MD5, Botan::Parallel, Botan::RIPEMD_160, Botan::SHA_160, Botan::SHA_224, Botan::SHA_256, Botan::SHA_384, Botan::SHA_512, Botan::SHA_512_256, Botan::SHA_3, Botan::SHAKE_128, Botan::SHAKE_256, Botan::Skein_512, Botan::SM3, Botan::Streebog, Botan::Tiger, Botan::Whirlpool, Botan::CBC_MAC, Botan::CMAC, Botan::GMAC, Botan::HMAC, Botan::Poly1305, Botan::SipHash, and Botan::ANSI_X919_MAC.
Referenced by botan_hash_output_length(), botan_mac_output_length(), Botan::Tiger::clone(), Botan::pbkdf2(), Botan::TLS::TLS_CBC_HMAC_AEAD_Mode::TLS_CBC_HMAC_AEAD_Mode(), and Botan::MDx_HashFunction::write_count().
|
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 |
|
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 byte array |
length | the length of the byte array |
Definition at line 118 of file buf_comp.h.
|
inlinevirtual |
Definition at line 135 of file mac.h.
Referenced by create(), and create_or_throw().
|
static |
|
inlineinherited |
Definition at line 153 of file sym_algo.h.
|
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().
|
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().
|
inline |
Begin processing a message.
|
inline |
|
inline |
|
virtual |
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 149 of file mac.cpp.
References BOTAN_UNUSED, and Botan::SymmetricAlgorithm::name().
|
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.
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 |
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.
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_hash_update(), 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 |
Process a single byte.
in | the byte to process |
Definition at line 75 of file buf_comp.h.
|
inherited |
Definition at line 12 of file buf_comp.cpp.
References Botan::store_be().
Referenced by Botan::pbkdf2().
|
inherited |
Definition at line 19 of file buf_comp.cpp.
References Botan::store_be().
|
inherited |
Definition at line 26 of file buf_comp.cpp.
References Botan::store_be().
|
inherited |
Definition at line 33 of file buf_comp.cpp.
References Botan::store_le().
|
inherited |
Definition at line 40 of file buf_comp.cpp.
References Botan::store_le().
|
inherited |
Definition at line 47 of file buf_comp.cpp.
References Botan::store_le().
|
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::ChaCha::cipher(), Botan::CTR_BE::cipher(), Botan::RC4::cipher(), Botan::Salsa20::cipher(), Botan::SHAKE_128_Cipher::cipher(), Botan::AES_128::decrypt_n(), Botan::AES_192::decrypt_n(), Botan::AES_256::decrypt_n(), Botan::ARIA_128::decrypt_n(), Botan::ARIA_192::decrypt_n(), Botan::ARIA_256::decrypt_n(), Botan::Blowfish::decrypt_n(), Botan::Camellia_128::decrypt_n(), Botan::Camellia_192::decrypt_n(), Botan::Camellia_256::decrypt_n(), Botan::CAST_128::decrypt_n(), Botan::CAST_256::decrypt_n(), Botan::DES::decrypt_n(), Botan::TripleDES::decrypt_n(), Botan::DESX::decrypt_n(), Botan::GOST_28147_89::decrypt_n(), Botan::IDEA::decrypt_n(), Botan::KASUMI::decrypt_n(), Botan::Lion::decrypt_n(), Botan::MISTY1::decrypt_n(), Botan::Noekeon::decrypt_n(), Botan::SEED::decrypt_n(), Botan::Serpent::decrypt_n(), Botan::SHACAL2::decrypt_n(), Botan::SM4::decrypt_n(), Botan::Threefish_512::decrypt_n(), Botan::Twofish::decrypt_n(), Botan::XTEA::decrypt_n(), Botan::AES_128::encrypt_n(), Botan::AES_192::encrypt_n(), Botan::AES_256::encrypt_n(), Botan::ARIA_128::encrypt_n(), Botan::ARIA_192::encrypt_n(), Botan::ARIA_256::encrypt_n(), Botan::Blowfish::encrypt_n(), Botan::Camellia_128::encrypt_n(), Botan::Camellia_192::encrypt_n(), Botan::Camellia_256::encrypt_n(), Botan::CAST_128::encrypt_n(), Botan::CAST_256::encrypt_n(), Botan::DES::encrypt_n(), Botan::TripleDES::encrypt_n(), Botan::DESX::encrypt_n(), Botan::GOST_28147_89::encrypt_n(), Botan::IDEA::encrypt_n(), Botan::KASUMI::encrypt_n(), Botan::Lion::encrypt_n(), Botan::MISTY1::encrypt_n(), Botan::Noekeon::encrypt_n(), Botan::SEED::encrypt_n(), Botan::Serpent::encrypt_n(), Botan::SHACAL2::encrypt_n(), Botan::SM4::encrypt_n(), Botan::Threefish_512::encrypt_n(), Botan::Twofish::encrypt_n(), Botan::XTEA::encrypt_n(), Botan::OCB_Encryption::finish(), Botan::OCB_Decryption::finish(), Botan::GHASH::ghash_update(), Botan::CFB_Encryption::process(), Botan::CFB_Decryption::process(), Botan::ChaCha::seek(), Botan::CTR_BE::seek(), Botan::Salsa20::seek(), Botan::OCB_Mode::set_associated_data(), Botan::ChaCha::set_iv(), Botan::Salsa20::set_iv(), Botan::GHASH::update(), Botan::GHASH::update_associated_data(), and Botan::ChaCha::write_keystream().
|
inlinevirtual |
Verify a MAC.
in | the MAC to verify as a byte array |
|
inlinevirtual |
Verify a MAC.
in | the MAC to verify as a byte array |
|
virtual |
Verify a MAC.
in | the MAC to verify as a byte array |
length | the length of param in |
Definition at line 159 of file mac.cpp.
References Botan::constant_time_compare().