Botan
2.1.0
Crypto and TLS for C++11
|
#include <mac.h>
Public Member Functions | |
virtual void | clear ()=0 |
virtual MessageAuthenticationCode * | clone () const =0 |
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 () |
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 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) |
template<typename T > | |
void | update_be (const T in) |
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) |
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) |
This class represents Message Authentication Code (MAC) objects.
|
virtualdefault |
|
pure virtualinherited |
Reset the state.
Implemented in Botan::GHASH, Botan::AES_256, Botan::Camellia_256, Botan::GOST_28147_89, Botan::AES_192, Botan::SHAKE_128_Cipher, Botan::ChaCha, Botan::Camellia_192, Botan::TripleDES, Botan::CTR_BE, Botan::OFB, Botan::Lion, Botan::Salsa20, Botan::Cascade_Cipher, Botan::Blowfish, Botan::Poly1305, Botan::Threefish_512, Botan::CMAC, Botan::GMAC, Botan::RC4, Botan::Noekeon, Botan::Serpent, Botan::CBC_MAC, Botan::AES_128, Botan::Camellia_128, Botan::CAST_128, Botan::CAST_256, Botan::DES, Botan::DESX, Botan::IDEA, Botan::KASUMI, Botan::MISTY1, Botan::SEED, Botan::Twofish, Botan::XTEA, Botan::HMAC, Botan::ANSI_X919_MAC, and Botan::SipHash.
Referenced by botan_block_cipher_clear(), botan_mac_clear(), and Botan::TLS::TLS_CBC_HMAC_AEAD_Mode::clear().
|
pure virtual |
Get a new object representing the same algorithm as *this
Implemented in Botan::GMAC, Botan::ANSI_X919_MAC, Botan::Poly1305, Botan::CMAC, Botan::HMAC, Botan::CBC_MAC, and Botan::SipHash.
|
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 43 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(), and Botan::BlockCipher::create().
Referenced by botan_mac_init(), Botan::PBKDF::create(), Botan::KDF::create(), create_or_throw(), Botan::TLS::Session::decrypt(), Botan::TLS::Session::encrypt(), Botan::get_mac(), Botan::TLS::Hello_Verify_Request::Hello_Verify_Request(), Botan::make_message_auth(), and Botan::RFC6979_Nonce_Generator::RFC6979_Nonce_Generator().
|
static |
Definition at line 138 of file mac.cpp.
References create().
Referenced by Botan::AutoSeeded_RNG::AutoSeeded_RNG(), Botan::ECIES_System_Params::create_mac(), and Botan::TLS::TLS_CBC_HMAC_AEAD_Mode::TLS_CBC_HMAC_AEAD_Mode().
|
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 89 of file buf_comp.h.
Referenced by botan_hash_final(), botan_mac_final(), Botan::TLS::TLS_CBC_HMAC_AEAD_Encryption::finish(), Botan::TLS::TLS_CBC_HMAC_AEAD_Decryption::finish(), Botan::mgf1_mask(), and Botan::pbkdf2().
|
inlineinherited |
Complete the computation and retrieve the final result.
Definition at line 96 of file buf_comp.h.
|
inlineinherited |
Definition at line 111 of file buf_comp.h.
|
inlineinherited |
Definition at line 103 of file buf_comp.h.
|
pure virtualinherited |
Implemented in Botan::Block_Cipher_Fixed_Params< BS, KMIN, KMAX, KMOD >, Botan::Block_Cipher_Fixed_Params< 16, 32 >, Botan::Block_Cipher_Fixed_Params< 8, 1, 56 >, Botan::Block_Cipher_Fixed_Params< 8, 32 >, Botan::Block_Cipher_Fixed_Params< 16, 16 >, Botan::Block_Cipher_Fixed_Params< 8, 11, 16 >, Botan::Block_Cipher_Fixed_Params< 8, 16, 24, 8 >, Botan::Block_Cipher_Fixed_Params< 16, 16, 32, 8 >, Botan::Block_Cipher_Fixed_Params< 16, 4, 32, 4 >, Botan::Block_Cipher_Fixed_Params< 64, 64 >, Botan::Block_Cipher_Fixed_Params< 16, 24 >, Botan::Block_Cipher_Fixed_Params< 8, 16 >, Botan::Block_Cipher_Fixed_Params< 8, 8 >, Botan::Block_Cipher_Fixed_Params< 8, 24 >, Botan::GHASH, Botan::GMAC, Botan::SHAKE_128_Cipher, Botan::ChaCha, Botan::Lion, Botan::Poly1305, Botan::RC4, Botan::CTR_BE, Botan::OFB, Botan::CMAC, Botan::HMAC, Botan::ANSI_X919_MAC, Botan::Salsa20, Botan::CBC_MAC, Botan::SipHash, and Botan::Cascade_Cipher.
Referenced by Botan::CBC_Mode::key_spec(), Botan::CFB_Mode::key_spec(), and Botan::XTS_Mode::key_spec().
|
inlineinherited |
Definition at line 39 of file sym_algo.h.
|
inlineinherited |
Definition at line 47 of file sym_algo.h.
|
pure virtualinherited |
Implemented in Botan::GHASH, Botan::AES_256, Botan::Camellia_256, Botan::AES_192, Botan::GOST_28147_89, Botan::SHAKE_128_Cipher, Botan::ChaCha, Botan::Camellia_192, Botan::TripleDES, Botan::Lion, Botan::CTR_BE, Botan::OFB, Botan::Salsa20, Botan::Cascade_Cipher, Botan::Blowfish, Botan::Threefish_512, Botan::AES_128, Botan::IDEA, Botan::Serpent, Botan::GMAC, Botan::RC4, Botan::Noekeon, Botan::Camellia_128, Botan::CAST_128, Botan::CAST_256, Botan::DES, Botan::DESX, Botan::KASUMI, Botan::MISTY1, Botan::SEED, Botan::Twofish, Botan::XTEA, Botan::HMAC, Botan::Poly1305, Botan::ANSI_X919_MAC, Botan::CBC_MAC, Botan::CMAC, and Botan::SipHash.
Referenced by Botan::CBC_Mode::CBC_Mode(), Botan::XTS_Mode::name(), Botan::CFB_Mode::name(), Botan::CBC_Mode::name(), Botan::pbkdf2(), and Botan::XTS_Mode::XTS_Mode().
|
pure virtualinherited |
Implemented in Botan::SHA_512_256, Botan::SHAKE_256, Botan::SHA_256, Botan::SHA_512, Botan::Blake2b, Botan::Skein_512, Botan::Keccak_1600, Botan::SHA_3, Botan::SHAKE_128, Botan::Comb4P, Botan::Poly1305, Botan::GMAC, Botan::Parallel, Botan::HMAC, Botan::SipHash, Botan::CBC_MAC, Botan::ANSI_X919_MAC, Botan::GOST_34_11, Botan::SHA_224, Botan::CMAC, Botan::Adler32, Botan::CRC24, Botan::CRC32, Botan::MD4, Botan::MD5, Botan::RIPEMD_160, Botan::SHA_160, Botan::SHA_384, Botan::Tiger, and Botan::Whirlpool.
Referenced by botan_hash_output_length(), botan_mac_output_length(), Botan::pbkdf2(), 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 as a byte array |
length | the length of the byte array |
Definition at line 124 of file buf_comp.h.
Referenced by Botan::RTSS_Share::split().
|
inlineinherited |
Update and finalize computation. Does the same as calling update() and final() consecutively.
in | the input to process |
Definition at line 136 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 148 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 160 of file buf_comp.h.
|
inlinevirtual |
|
static |
Definition at line 131 of file mac.cpp.
Referenced by Botan::get_mac_providers().
|
inlineinherited |
Set the symmetric key of this object.
key | the SymmetricKey to be set. |
Definition at line 66 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_mac_set_key(), and Botan::pbkdf2().
|
inlineinherited |
Definition at line 72 of file sym_algo.h.
|
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 82 of file sym_algo.h.
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
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 66 of file mac.h.
References BOTAN_UNUSED.
|
inlineinherited |
Add new input to process.
in | the input to process as a byte array |
length | of param in in bytes |
Definition at line 34 of file buf_comp.h.
Referenced by botan_hash_update(), botan_mac_update(), Botan::TLS::TLS_CBC_HMAC_AEAD_Encryption::finish(), Botan::TLS::TLS_CBC_HMAC_AEAD_Decryption::finish(), Botan::mgf1_mask(), and Botan::pbkdf2().
|
inlineinherited |
Add new input to process.
in | the input to process as a secure_vector |
Definition at line 40 of file buf_comp.h.
|
inlineinherited |
Add new input to process.
in | the input to process as a std::vector |
Definition at line 49 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 72 of file buf_comp.h.
|
inlineinherited |
|
inlineinherited |
Add an integer in big-endian order
in | the value |
Definition at line 58 of file buf_comp.h.
References Botan::get_byte().
Referenced by Botan::mgf1_mask(), and Botan::pbkdf2().
|
inlineinherited |
Check whether a given key length is valid for this algorithm.
length | the key length to be checked. |
Definition at line 57 of file sym_algo.h.
Referenced by Botan::aont_package(), and Botan::aont_unpackage().
|
virtual |
Verify a MAC.
in | the MAC to verify as a byte array |
length | the length of param in |
Definition at line 151 of file mac.cpp.
References Botan::same_mem().
|
inlinevirtual |
Verify a MAC.
in | the MAC to verify as a byte array |
Definition at line 115 of file mac.h.
|
inlinevirtual |
Verify a MAC.
in | the MAC to verify as a byte array |
Definition at line 125 of file mac.h.