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;
39void CMAC::add_data(
const byte input[],
size_t length)
41 buffer.
copy(position, input, length);
55 buffer.
copy(input, length);
64void CMAC::final_result(
byte mac[])
66 xor_buf(state, buffer, position);
74 state[position] ^= 0x80;
91void CMAC::key_schedule(
const byte key[],
size_t length)
94 e->set_key(key, length);
118 return "CMAC(" + e->name() +
")";
126 return new CMAC(e->clone());
134 if(e->block_size() == 16)
136 else if(e->block_size() == 8)
void encrypt(const byte in[], byte out[]) const
static SecureVector< byte > poly_double(const MemoryRegion< byte > &in, byte polynomial)
size_t output_length() const
CMAC(BlockCipher *cipher)
MessageAuthenticationCode * clone() const
void copy(const T in[], size_t n)
void zeroise(MemoryRegion< T > &vec)
void xor_buf(byte out[], const byte in[], size_t length)
std::invalid_argument Invalid_Argument