Botan 3.5.0
Crypto and TLS for C&
|
#include <mac.h>
Public Member Functions | |
virtual void | clear ()=0 |
MessageAuthenticationCode * | clone () const |
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>> | |
T | final () |
void | final (std::span< uint8_t > out) |
template<concepts::resizable_byte_buffer T> | |
void | final (T &out) |
void | final (uint8_t out[]) |
std::vector< uint8_t > | final_stdvec () |
virtual bool | fresh_key_required_per_message () const |
virtual bool | has_keying_material () const =0 |
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 std::unique_ptr< MessageAuthenticationCode > | new_object () const =0 |
virtual size_t | output_length () const =0 |
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>> | |
T | process (const uint8_t in[], size_t length) |
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>> | |
T | process (std::span< const uint8_t > in) |
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>> | |
T | process (std::string_view in) |
virtual std::string | provider () const |
void | set_key (const SymmetricKey &key) |
void | set_key (const uint8_t key[], size_t length) |
void | set_key (std::span< const uint8_t > key) |
void | start () |
void | start (const uint8_t nonce[], size_t nonce_len) |
void | start (std::span< const uint8_t > nonce) |
void | update (const uint8_t in[], size_t length) |
void | update (std::span< const uint8_t > in) |
void | update (std::string_view 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 |
bool | verify_mac (const uint8_t in[], size_t length) |
bool | verify_mac (std::span< const uint8_t > in) |
~MessageAuthenticationCode () override=default | |
Static Public Member Functions | |
static std::unique_ptr< MessageAuthenticationCode > | create (std::string_view algo_spec, std::string_view provider="") |
static std::unique_ptr< MessageAuthenticationCode > | create_or_throw (std::string_view algo_spec, std::string_view provider="") |
static std::vector< std::string > | providers (std::string_view algo_spec) |
Protected Member Functions | |
void | assert_key_material_set () const |
void | assert_key_material_set (bool predicate) const |
virtual void | start_msg (std::span< const uint8_t > nonce) |
virtual bool | verify_mac_result (std::span< const uint8_t > in) |
This class represents Message Authentication Code (MAC) objects.
|
overridedefault |
|
inlineprotectedinherited |
Definition at line 139 of file sym_algo.h.
References Botan::SymmetricAlgorithm::assert_key_material_set().
Referenced by Botan::SymmetricAlgorithm::assert_key_material_set(), Botan::Salsa20::cipher_bytes(), 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::DES::decrypt_n(), Botan::GOST_28147_89::decrypt_n(), Botan::IDEA::decrypt_n(), Botan::Kuznyechik::decrypt_n(), Botan::Lion::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::TripleDES::decrypt_n(), Botan::Twofish::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::DES::encrypt_n(), Botan::GOST_28147_89::encrypt_n(), Botan::IDEA::encrypt_n(), Botan::Kuznyechik::encrypt_n(), Botan::Lion::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::TripleDES::encrypt_n(), Botan::Twofish::encrypt_n(), Botan::GHASH::final(), Botan::GHASH::ghash_update(), Botan::ChaCha::seek(), Botan::CTR_BE::seek(), Botan::Salsa20::seek(), Botan::OCB_Mode::set_associated_data_n(), Botan::Salsa20::set_iv_bytes(), Botan::GHASH::update(), and Botan::GHASH::update_associated_data().
|
inlineprotectedinherited |
Definition at line 141 of file sym_algo.h.
|
pure virtualinherited |
Reset the internal state. This includes not just the key, but any partial message that may have been in process.
Implemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::ANSI_X919_MAC, Botan::ARIA_128, Botan::ARIA_192, Botan::ARIA_256, Botan::BLAKE2b, Botan::BLAKE2bMAC, Botan::Blowfish, Botan::Camellia_128, Botan::Camellia_192, Botan::Camellia_256, Botan::Cascade_Cipher, Botan::CAST_128, Botan::CBC_Mode, Botan::CCM_Mode, Botan::CFB_Mode, Botan::ChaCha20Poly1305_Mode, Botan::ChaCha, Botan::CMAC, Botan::CTR_BE, Botan::DES, Botan::EAX_Mode, Botan::FPE_FE1, Botan::GCM_Mode, Botan::GHASH, Botan::GMAC, Botan::GOST_28147_89, Botan::HMAC, Botan::IDEA, Botan::KMAC, Botan::Kuznyechik, Botan::Lion, Botan::Noekeon, Botan::OCB_Mode, Botan::OFB, Botan::Poly1305, Botan::RC4, Botan::Salsa20, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SHAKE_Cipher, Botan::SipHash, Botan::SIV_Mode, Botan::SM4, Botan::Threefish_512, Botan::TLS::TLS_CBC_HMAC_AEAD_Mode, Botan::TripleDES, Botan::Twofish, and Botan::XTS_Mode.
Referenced by Botan::TLS::TLS_CBC_HMAC_AEAD_Mode::clear().
|
inline |
|
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 51 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::PasswordHashFamily::create(), Botan::PBKDF::create(), and create_or_throw().
|
static |
Definition at line 148 of file mac.cpp.
References create(), and provider().
Referenced by 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::Scrypt::derive_key(), 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::RFC6979_Nonce_Generator::RFC6979_Nonce_Generator().
|
inlineinherited |
Complete the computation and retrieve the final result as a container of your choice.
Definition at line 78 of file buf_comp.h.
References T.
|
inlineinherited |
Definition at line 86 of file buf_comp.h.
References BOTAN_ARG_CHECK.
|
inlineinherited |
Definition at line 92 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 70 of file buf_comp.h.
Referenced by Botan::ed25519_gen_keypair(), Botan::ed25519_sign(), Botan::ed25519_verify(), Botan::PseudorandomKeyGeneration::gen(), Botan::mgf1_mask(), Botan::pbkdf2(), Botan::Dilithium::Polynomial::poly_challenge(), Botan::Sphincs_Hash_Functions_Sha2::PRF_msg(), Botan::Sphincs_Hash_Functions_Shake::PRF_msg(), and Botan::sm2_compute_za().
|
inlineinherited |
|
inlinevirtual |
This is required for certain polynomial-based MACs which are insecure if a key is ever reused for two different messages.
Reimplemented in Botan::Poly1305.
Definition at line 116 of file mac.h.
|
pure virtualinherited |
Implemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::ANSI_X919_MAC, Botan::ARIA_128, Botan::ARIA_192, Botan::ARIA_256, Botan::BLAKE2b, Botan::BLAKE2bMAC, Botan::Blowfish, Botan::Camellia_128, Botan::Camellia_192, Botan::Camellia_256, Botan::Cascade_Cipher, Botan::CAST_128, Botan::CBC_Mode, Botan::CCM_Mode, Botan::CFB_Mode, Botan::ChaCha20Poly1305_Mode, Botan::ChaCha, Botan::CMAC, Botan::CTR_BE, Botan::DES, Botan::EAX_Mode, Botan::FPE_FE1, Botan::GCM_Mode, Botan::GHASH, Botan::GMAC, Botan::GOST_28147_89, Botan::HMAC, Botan::IDEA, Botan::KMAC, Botan::Kuznyechik, Botan::Lion, Botan::Noekeon, Botan::OCB_Mode, Botan::OFB, Botan::Poly1305, Botan::RC4, Botan::Salsa20, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SHAKE_Cipher, Botan::SipHash, Botan::SIV_Mode, Botan::SM4, Botan::Threefish_512, Botan::TLS::TLS_CBC_HMAC_AEAD_Mode, Botan::TripleDES, Botan::Twofish, and Botan::XTS_Mode.
Referenced by Botan::TLS::TLS_CBC_HMAC_AEAD_Mode::has_keying_material().
|
pure virtualinherited |
Implemented in Botan::ANSI_X919_MAC, Botan::BLAKE2b, Botan::BLAKE2bMAC, 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< 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, 32 >, Botan::Block_Cipher_Fixed_Params< 8, 8 >, Botan::Cascade_Cipher, Botan::CBC_Mode, Botan::CCM_Mode, Botan::CFB_Mode, Botan::ChaCha20Poly1305_Mode, Botan::ChaCha, Botan::CMAC, Botan::CTR_BE, Botan::EAX_Mode, Botan::FPE_FE1, Botan::GCM_Mode, Botan::GHASH, Botan::GMAC, Botan::HMAC, Botan::KMAC, Botan::Lion, Botan::OCB_Mode, Botan::OFB, Botan::Poly1305, Botan::RC4, Botan::Salsa20, Botan::SHAKE_Cipher, Botan::SipHash, Botan::SIV_Mode, Botan::TLS::TLS_CBC_HMAC_AEAD_Mode, and Botan::XTS_Mode.
Referenced by Botan::CBC_Mode::key_spec(), Botan::CFB_Mode::key_spec(), and Botan::XTS_Mode::key_spec().
|
inlineinherited |
Definition at line 95 of file sym_algo.h.
|
inlineinherited |
Definition at line 100 of file sym_algo.h.
|
pure virtualinherited |
Implemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::ANSI_X919_MAC, Botan::ARIA_128, Botan::ARIA_192, Botan::ARIA_256, Botan::BLAKE2b, Botan::BLAKE2bMAC, Botan::Blowfish, Botan::Camellia_128, Botan::Camellia_192, Botan::Camellia_256, Botan::Cascade_Cipher, Botan::CAST_128, Botan::CBC_Mode, Botan::CCM_Mode, Botan::CFB_Mode, Botan::ChaCha20Poly1305_Mode, Botan::ChaCha, Botan::CMAC, Botan::CTR_BE, Botan::DES, Botan::EAX_Mode, Botan::FPE_FE1, Botan::GCM_Mode, Botan::GHASH, Botan::GMAC, Botan::GOST_28147_89, Botan::HMAC, Botan::IDEA, Botan::KMAC128, Botan::KMAC256, Botan::Kuznyechik, Botan::Lion, Botan::Noekeon, Botan::OCB_Mode, Botan::OFB, Botan::Poly1305, Botan::RC4, Botan::Salsa20, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SHAKE_128_Cipher, Botan::SHAKE_256_Cipher, Botan::SipHash, Botan::SIV_Mode, Botan::SM4, Botan::Threefish_512, Botan::TLS::TLS_CBC_HMAC_AEAD_Mode, Botan::TripleDES, Botan::Twofish, and Botan::XTS_Mode.
Referenced by Botan::XTS_Mode::name(), Botan::SymmetricAlgorithm::set_key(), and start_msg().
|
pure virtual |
Implemented in Botan::ANSI_X919_MAC, Botan::BLAKE2bMAC, Botan::CMAC, Botan::GMAC, Botan::HMAC, Botan::KMAC128, Botan::KMAC256, Botan::Poly1305, and Botan::SipHash.
|
pure virtualinherited |
Implemented in Botan::Adler32, Botan::ANSI_X919_MAC, Botan::BLAKE2b, Botan::BLAKE2bMAC, Botan::BLAKE2s, Botan::CMAC, Botan::Comb4P, Botan::CRC24, Botan::CRC32, Botan::GMAC, Botan::GOST_34_11, Botan::HMAC, Botan::Keccak_1600, Botan::KMAC, Botan::MD4, Botan::MD5, Botan::Parallel, Botan::Poly1305, Botan::RawHashFunction, Botan::RIPEMD_160, Botan::SHA_1, Botan::SHA_224, Botan::SHA_256, Botan::SHA_384, Botan::SHA_3, Botan::SHA_512, Botan::SHA_512_256, Botan::SHAKE_128, Botan::SHAKE_256, Botan::SipHash, Botan::Skein_512, Botan::SM3, Botan::Streebog, Botan::Truncated_Hash, and Botan::Whirlpool.
Referenced by Botan::PseudorandomKeyGeneration::gen(), Botan::mgf1_mask(), Botan::pbkdf2(), and Botan::TLS::TLS_CBC_HMAC_AEAD_Mode::TLS_CBC_HMAC_AEAD_Mode().
|
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 105 of file buf_comp.h.
Referenced by Botan::Dilithium_Symmetric_Primitives::CRH(), Botan::Dilithium_Symmetric_Primitives::H(), Botan::Kyber_Symmetric_Primitives::H(), Botan::Kyber_Symmetric_Primitives::H(), and Botan::Kyber_Symmetric_Primitives::H().
|
inlineinherited |
Update and finalize computation. Does the same as calling update() and final() consecutively.
in | the input to process as a contiguous container |
Definition at line 129 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 117 of file buf_comp.h.
|
inlinevirtual |
Reimplemented in Botan::KMAC.
Definition at line 108 of file mac.h.
Referenced by create(), and create_or_throw().
|
static |
Definition at line 143 of file mac.cpp.
References Botan::probe_providers_of().
|
inlineinherited |
Set the symmetric key of this object.
key | the SymmetricKey to be set. |
Definition at line 113 of file sym_algo.h.
References Botan::OctetString::begin(), Botan::OctetString::length(), and Botan::SymmetricAlgorithm::set_key().
Referenced by Botan::create_aes_row_generator(), 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(), Botan::Sphincs_Hash_Functions_Sha2::PRF_msg(), Botan::Sodium::randombytes_buf_deterministic(), and Botan::SymmetricAlgorithm::set_key().
|
inlineinherited |
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 126 of file sym_algo.h.
References Botan::SymmetricAlgorithm::set_key().
Referenced by Botan::SymmetricAlgorithm::set_key().
|
inherited |
Set the symmetric key of this object.
key | the contiguous byte range to be set. |
Definition at line 17 of file sym_algo.cpp.
References Botan::SymmetricAlgorithm::name(), and Botan::SymmetricAlgorithm::valid_keylength().
|
inline |
Begin processing a message.
Definition at line 77 of file mac.h.
|
inline |
|
inline |
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.
Default implementation simply rejects all non-empty nonces since most hash/MAC algorithms do not support randomization
nonce | the message nonce bytes |
Definition at line 65 of file mac.h.
|
protectedvirtual |
Prepare for processing a message under the specified nonce
If the MAC does not support nonces, it should not override the default implementation.
Definition at line 156 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 35 of file buf_comp.h.
Referenced by Botan::ed25519_gen_keypair(), Botan::ed25519_sign(), Botan::ed25519_verify(), Botan::PseudorandomKeyGeneration::gen(), Botan::mgf1_mask(), Botan::pbkdf2(), Botan::Dilithium::Polynomial::poly_challenge(), Botan::Sphincs_Hash_Functions_Sha2::PRF_msg(), Botan::Sphincs_Hash_Functions_Shake::PRF_msg(), Botan::sm2_compute_za(), and Botan::Sphincs_Hash_Functions_Shake::Sphincs_Hash_Functions_Shake().
|
inlineinherited |
Add new input to process.
in | the input to process as a contiguous data range |
Definition at line 41 of file buf_comp.h.
|
inlineinherited |
Add new input to process.
str | the input to process as a std::string_view. Will be interpreted as a byte array based on the strings encoding. |
Definition at line 56 of file buf_comp.h.
References Botan::cast_char_ptr_to_uint8().
|
inlineinherited |
Process a single byte.
in | the byte to process |
Definition at line 62 of file buf_comp.h.
|
inherited |
Definition at line 13 of file buf_comp.cpp.
References Botan::store_be().
Referenced by Botan::mgf1_mask(), and Botan::pbkdf2().
|
inherited |
Definition at line 19 of file buf_comp.cpp.
References Botan::store_be().
|
inherited |
Definition at line 25 of file buf_comp.cpp.
References Botan::store_be().
|
inherited |
Definition at line 31 of file buf_comp.cpp.
References Botan::store_le().
|
inherited |
Definition at line 37 of file buf_comp.cpp.
References Botan::store_le().
|
inherited |
Definition at line 43 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 107 of file sym_algo.h.
Referenced by Botan::SymmetricAlgorithm::set_key().
|
inline |
Verify a MAC.
in | the MAC to verify as a byte array |
length | the length of param in |
Definition at line 85 of file mac.h.
|
inline |
|
protectedvirtual |
Verify the MACs final result
Definition at line 166 of file mac.cpp.
References Botan::CT::is_equal().