Arduino Cryptography Library
|
Implementation of the OMAC message authenticator. More...
#include <OMAC.h>
Public Member Functions | |
OMAC () | |
Constructs a new OMAC object. More... | |
~OMAC () | |
Destroys this OMAC object. More... | |
BlockCipher * | blockCipher () const |
Gets the block cipher that is in use for this OMAC object. More... | |
void | setBlockCipher (BlockCipher *cipher) |
Sets the block cipher to use for this OMAC object. More... | |
void | initFirst (uint8_t omac[16]) |
Initialises the first OMAC hashing context and creates the B value. More... | |
void | initNext (uint8_t omac[16], uint8_t tag) |
Initialises or restarts an OMAC hashing context. More... | |
void | update (uint8_t omac[16], const uint8_t *data, size_t size) |
Updates an OMAC hashing context with more data. More... | |
void | finalize (uint8_t omac[16]) |
Finalises an OMAC hashing context. More... | |
void | clear () |
Clears all security-sensitive state from this object. | |
Implementation of the OMAC message authenticator.
OMAC is the message authentication part of EAX mode. It is provided as a separate class for the convenience of applications that need message authentication separate from encryption.
References: https://en.wikipedia.org/wiki/EAX_mode, http://web.cs.ucdavis.edu/~rogaway/papers/eax.html
OMAC::OMAC | ( | ) |
Constructs a new OMAC object.
This constructor must be followed by a call to setBlockCipher() to specify the block cipher to use.
|
inline |
Gets the block cipher that is in use for this OMAC object.
void OMAC::finalize | ( | uint8_t | omac[16] | ) |
Finalises an OMAC hashing context.
void OMAC::initFirst | ( | uint8_t | omac[16] | ) |
Initialises the first OMAC hashing context and creates the B value.
omac | The OMAC hashing context. |
This function must be called first before initNext(), update(), or finalize() to create the B value from the OMAC algorithm which is used to finalize later hashes. It is assumed that setBlockCipher() has already been called.
The tag value for the context is implicitly set to zero, which means that the context can be used for ordinary hashing as long as the data that follows is non-zero in length. Alternatively, initNext() can be called to restart the context with a specific tag.
This function must be called again whenever the block cipher or the key changes.
void OMAC::initNext | ( | uint8_t | omac[16], |
uint8_t | tag | ||
) |
Initialises or restarts an OMAC hashing context.
omac | The OMAC hashing context. |
tag | The tag value indicating which OMAC calculation we are doing. |
It is assumed that initFirst() was called previously to create the B value for the context.
|
inline |
Sets the block cipher to use for this OMAC object.
cipher | The block cipher to use to implement OMAC. This object must have a block size of 128 bits (16 bytes). |
void OMAC::update | ( | uint8_t | omac[16], |
const uint8_t * | data, | ||
size_t | size | ||
) |
Updates an OMAC hashing context with more data.
omac | The OMAC hashing context. |
data | Points to the data to be hashed. |
size | The number of bytes to be hashed. |