8 #include <botan/cmac.h>
9 #include <botan/internal/xor_buf.h>
19 const byte poly_xor = (in[0] & 0x80) ? polynomial : 0;
24 for(
size_t i = out.
size(); i != 0; --i)
27 out[i-1] = (temp << 1) | carry;
31 out[out.
size()-1] ^= poly_xor;
39 void CMAC::add_data(
const byte input[],
size_t length)
41 buffer.
copy(position, input, length);
55 buffer.
copy(input, length);
64 void CMAC::final_result(
byte mac[])
66 xor_buf(state, buffer, position);
74 state[position] ^= 0x80;
91 void CMAC::key_schedule(
const byte key[],
size_t length)
118 return "CMAC(" + e->
name() +
")";
virtual BlockCipher * clone() const =0
std::invalid_argument Invalid_Argument
void copy(const T in[], size_t n)
void set_key(const SymmetricKey &key)
MessageAuthenticationCode * mac
size_t output_length() const
virtual std::string name() const =0
CMAC(BlockCipher *cipher)
void encrypt(const byte in[], byte out[]) const
MessageAuthenticationCode * clone() const
void xor_buf(byte out[], const byte in[], size_t length)
void zeroise(MemoryRegion< T > &vec)
static SecureVector< byte > poly_double(const MemoryRegion< byte > &in, byte polynomial)
virtual size_t block_size() const =0