Arduino Cryptography Library
Public Member Functions | List of all members
OMAC Class Reference

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...
 
BlockCipherblockCipher () 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.
 

Detailed Description

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

See also
EAX

Definition at line 28 of file OMAC.h.

Constructor & Destructor Documentation

◆ OMAC()

OMAC::OMAC ( )

Constructs a new OMAC object.

This constructor must be followed by a call to setBlockCipher() to specify the block cipher to use.

Definition at line 48 of file OMAC.cpp.

◆ ~OMAC()

OMAC::~OMAC ( )

Destroys this OMAC object.

See also
clear()

Definition at line 59 of file OMAC.cpp.

Member Function Documentation

◆ blockCipher()

BlockCipher * OMAC::blockCipher ( ) const
inline

Gets the block cipher that is in use for this OMAC object.

See also
setBlockCipher()

Definition at line 34 of file OMAC.h.

◆ finalize()

void OMAC::finalize ( uint8_t  omac[16])

Finalises an OMAC hashing context.

Parameters
omacThe OMAC hashing context on entry, the final OMAC value on exit.
See also
initFirst(), initNext(), update()

Definition at line 172 of file OMAC.cpp.

◆ initFirst()

void OMAC::initFirst ( uint8_t  omac[16])

Initialises the first OMAC hashing context and creates the B value.

Parameters
omacThe 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.

See also
initNext(), update(), finalize()

Definition at line 101 of file OMAC.cpp.

◆ initNext()

void OMAC::initNext ( uint8_t  omac[16],
uint8_t  tag 
)

Initialises or restarts an OMAC hashing context.

Parameters
omacThe OMAC hashing context.
tagThe 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.

See also
initFirst(), update(), finalize()

Definition at line 127 of file OMAC.cpp.

◆ setBlockCipher()

void OMAC::setBlockCipher ( BlockCipher cipher)
inline

Sets the block cipher to use for this OMAC object.

Parameters
cipherThe block cipher to use to implement OMAC. This object must have a block size of 128 bits (16 bytes).
See also
blockCipher()

Definition at line 35 of file OMAC.h.

◆ update()

void OMAC::update ( uint8_t  omac[16],
const uint8_t *  data,
size_t  size 
)

Updates an OMAC hashing context with more data.

Parameters
omacThe OMAC hashing context.
dataPoints to the data to be hashed.
sizeThe number of bytes to be hashed.
See also
initFirst(), initNext(), finalize()

Definition at line 143 of file OMAC.cpp.


The documentation for this class was generated from the following files: