8#include <botan/cbc_mac.h>
15void CBC_MAC::add_data(
const uint8_t input[],
size_t length)
19 size_t xored = std::min(
output_length() - m_position, length);
20 xor_buf(&m_state[m_position], input, xored);
26 m_cipher->encrypt(m_state);
32 m_cipher->encrypt(m_state);
37 xor_buf(m_state, input, length);
44void CBC_MAC::final_result(uint8_t mac[])
49 m_cipher->encrypt(m_state);
51 copy_mem(mac, m_state.data(), m_state.size());
59void CBC_MAC::key_schedule(
const uint8_t key[],
size_t length)
61 m_state.resize(m_cipher->block_size());
62 m_cipher->set_key(key, length);
80 return "CBC-MAC(" + m_cipher->name() +
")";
88 return new CBC_MAC(m_cipher->clone());
size_t output_length() const override
CBC_MAC(BlockCipher *cipher)
MessageAuthenticationCode * clone() const override
std::string name() const override
void verify_key_set(bool cond) const
void zeroise(std::vector< T, Alloc > &vec)
void zap(std::vector< T, Alloc > &vec)
void copy_mem(T *out, const T *in, size_t n)
void xor_buf(uint8_t out[], const uint8_t in[], size_t length)