8 #include <botan/cmac.h>
9 #include <botan/exceptn.h>
10 #include <botan/internal/poly_dbl.h>
27 void 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);
54 void 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);
80 void 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());
129 " bit cipher " + m_cipher->name());
std::string name() const override
size_t output_length() const override
void poly_double_n(uint8_t out[], const uint8_t in[], size_t n)
std::string to_string(const BER_Object &obj)
std::vector< T, secure_allocator< T >> secure_vector
void xor_buf(uint8_t out[], const uint8_t in[], size_t length)
MessageAuthenticationCode * clone() const override
void copy_mem(T *out, const T *in, size_t n)
static secure_vector< uint8_t > poly_double(const secure_vector< uint8_t > &in)
CMAC(BlockCipher *cipher)
size_t buffer_insert(std::vector< T, Alloc > &buf, size_t buf_offset, const T input[], size_t input_length)
bool poly_double_supported_size(size_t n)
void zeroise(std::vector< T, Alloc > &vec)