Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
Macros | Typedefs | Functions
photon-beetle-hmac.h File Reference

Hashed Message Authentication Code (HMAC) based on PHOTON-Beetle-Hash. More...

#include "photon-beetle-hash.h"
#include <stddef.h>

Go to the source code of this file.

Macros

#define PHOTON_BEETLE_HMAC_SIZE   PHOTON_BEETLE_HASH_SIZE
 Default size of the output for PHOTON-Beetle-HMAC.
 

Typedefs

typedef photon_beetle_hash_state_t photon_beetle_hmac_state_t
 State information for the PHOTON-Beetle-HMAC incremental mode.
 

Functions

void photon_beetle_hmac (unsigned char *out, const unsigned char *key, size_t keylen, const unsigned char *in, size_t inlen)
 Computes a HMAC value using PHOTON-Beetle-Hash. More...
 
void photon_beetle_hmac_init (photon_beetle_hmac_state_t *state, const unsigned char *key, size_t keylen)
 Initializes an incremental HMAC state using PHOTON-Beetle-Hash. More...
 
void photon_beetle_hmac_update (photon_beetle_hmac_state_t *state, const unsigned char *in, size_t inlen)
 Updates an incremental PHOTON-Beetle-HMAC state with more input data. More...
 
void photon_beetle_hmac_finalize (photon_beetle_hmac_state_t *state, const unsigned char *key, size_t keylen, unsigned char *out)
 Finalizes an incremental PHOTON-Beetle-HMAC state. More...
 

Detailed Description

Hashed Message Authentication Code (HMAC) based on PHOTON-Beetle-Hash.

The HMAC mode provides a method to authenticate a sequence of bytes using PHOTON-Beetle-Hash as the underlying digest algorithm.

HMAC uses an underlying block size to pad the key data. The PHOTON-Beetle-Hash block absorption rates of 16 and 4 bytes are too short so we use the HMAC-SHA-256 block size of 64 instead.

Note
The KMAC construction is preferable for sponge-based hash algorithms as it is simpler and more efficient. HMAC mode is provided for drop-in compatibility with existing designs.

Reference: https://tools.ietf.org/html/rfc2104

Function Documentation

void photon_beetle_hmac ( unsigned char *  out,
const unsigned char *  key,
size_t  keylen,
const unsigned char *  in,
size_t  inlen 
)

Computes a HMAC value using PHOTON-Beetle-Hash.

Parameters
outBuffer to receive the output HMAC value; must be at least PHOTON_BEETLE_HMAC_SIZE bytes in length.
keyPoints to the key.
keylenNumber of bytes in the key.
inPoints to the data to authenticate.
inlenNumber of bytes of data to authenticate.
void photon_beetle_hmac_finalize ( photon_beetle_hmac_state_t state,
const unsigned char *  key,
size_t  keylen,
unsigned char *  out 
)

Finalizes an incremental PHOTON-Beetle-HMAC state.

Parameters
stateHMAC state to squeeze the output data from.
keyPoints to the key.
keylenNumber of bytes in the key.
outPoints to the output buffer to receive the HMAC value; must be at least PHOTON_BEETLE_HMAC_SIZE bytes in length.
See Also
photon_beetle_hmac_init(), photon_beetle_hmac_update()
void photon_beetle_hmac_init ( photon_beetle_hmac_state_t state,
const unsigned char *  key,
size_t  keylen 
)

Initializes an incremental HMAC state using PHOTON-Beetle-Hash.

Parameters
statePoints to the state to be initialized.
keyPoints to the key.
keylenNumber of bytes in the key.

The key needs to be preserved until the photon_beetle_hmac_finalize() call to provide the outer HMAC hashing key.

See Also
photon_beetle_hmac_update(), photon_beetle_hmac_finalize()
void photon_beetle_hmac_update ( photon_beetle_hmac_state_t state,
const unsigned char *  in,
size_t  inlen 
)

Updates an incremental PHOTON-Beetle-HMAC state with more input data.

Parameters
stateHMAC state to be updated.
inPoints to the input data to be incorporated into the state.
inlenLength of the input data to be incorporated into the state.
See Also
photon_beetle_hmac_init(), photon_beetle_hmac_finalize()