49 EAXCommon::~EAXCommon()
84 omac.
update(state.counter, iv, len);
89 memcpy(state.tag, state.counter, 16);
104 encryptCTR(output, input, len);
105 omac.
update(state.hash, output, len);
112 omac.
update(state.hash, input, len);
113 encryptCTR(output, input, len);
119 omac.
update(state.hash, (
const uint8_t *)data, len);
127 memcpy(tag, state.tag, len);
138 return secure_compare(state.tag, tag, len);
150 void EAXCommon::closeAuthData()
154 for (uint8_t index = 0; index < 16; ++index)
155 state.tag[index] ^= state.hash[index];
171 void EAXCommon::encryptCTR(uint8_t *output,
const uint8_t *input,
size_t len)
175 if (state.encPosn == 16) {
188 temp += state.counter[index];
189 state.counter[index] = (uint8_t)temp;
195 uint8_t size = 16 - state.encPosn;
198 for (uint8_t index = 0; index < size; ++index)
199 output[index] = input[index] ^ state.stream[(state.encPosn)++];
208 void EAXCommon::closeTag()
216 for (uint8_t index = 0; index < 16; ++index)
217 state.tag[index] ^= state.hash[index];
virtual bool setKey(const uint8_t *key, size_t len)=0
Sets the key to use for future encryption and decryption operations.
virtual void encryptBlock(uint8_t *output, const uint8_t *input)=0
Encrypts a single block using this cipher.
virtual size_t keySize() const =0
Default size of the key for this block cipher, in bytes.
size_t keySize() const
Default size of the key for this cipher, in bytes.
bool setIV(const uint8_t *iv, size_t len)
Sets the initialization vector to use for future encryption and decryption operations.
size_t tagSize() const
Returns the size of the authentication tag.
void decrypt(uint8_t *output, const uint8_t *input, size_t len)
Decrypts an input buffer and writes the plaintext to an output buffer.
bool checkTag(const void *tag, size_t len)
Finalizes the decryption process and checks the authentication tag.
void encrypt(uint8_t *output, const uint8_t *input, size_t len)
Encrypts an input buffer and writes the ciphertext to an output buffer.
void computeTag(void *tag, size_t len)
Finalizes the encryption process and computes the authentication tag.
size_t ivSize() const
Size of the initialization vector for this cipher, in bytes.
void addAuthData(const void *data, size_t len)
Adds extra data that will be authenticated but not encrypted.
EAXCommon()
Constructs a new cipher in EAX mode.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
void clear()
Clears all security-sensitive state from this cipher.
void initFirst(uint8_t omac[16])
Initialises the first OMAC hashing context and creates the B value.
void update(uint8_t omac[16], const uint8_t *data, size_t size)
Updates an OMAC hashing context with more data.
BlockCipher * blockCipher() const
Gets the block cipher that is in use for this OMAC object.
void initNext(uint8_t omac[16], uint8_t tag)
Initialises or restarts an OMAC hashing context.
void finalize(uint8_t omac[16])
Finalises an OMAC hashing context.