9#include <botan/exceptn.h>
10#include <botan/internal/poly_dbl.h>
27void CMAC::add_data(
const uint8_t input[],
size_t length)
32 if(m_position + length > bs)
35 m_cipher->encrypt(m_state);
36 input += (bs - m_position);
37 length -= (bs - m_position);
41 m_cipher->encrypt(m_state);
45 copy_mem(m_buffer.data(), input, length);
54void CMAC::final_result(uint8_t mac[])
56 xor_buf(m_state, m_buffer, m_position);
64 m_state[m_position] ^= 0x80;
68 m_cipher->encrypt(m_state);
80void CMAC::key_schedule(
const uint8_t key[],
size_t length)
83 m_cipher->set_key(key, length);
84 m_cipher->encrypt(m_B);
107 return "CMAC(" + m_cipher->name() +
")";
115 return new CMAC(m_cipher->clone());
123 m_block_size(m_cipher->block_size())
128 std::to_string(m_block_size * 8) +
129 " bit cipher " + m_cipher->name());
size_t output_length() const override
MessageAuthenticationCode * clone() const override
std::string name() const override
CMAC(BlockCipher *cipher)
static secure_vector< uint8_t > poly_double(const secure_vector< uint8_t > &in)
void zeroise(std::vector< T, Alloc > &vec)
size_t buffer_insert(std::vector< T, Alloc > &buf, size_t buf_offset, const T input[], size_t input_length)
void copy_mem(T *out, const T *in, size_t n)
void xor_buf(uint8_t out[], const uint8_t in[], size_t length)
void poly_double_n(uint8_t out[], const uint8_t in[], size_t n)
bool poly_double_supported_size(size_t n)
std::vector< T, secure_allocator< T > > secure_vector