ASCON Suite
Classes | Macros | Functions
kmac.h File Reference

Keyed Message Authentication Code (KMAC) based on ASCON-XOF. More...

#include <ascon/xof.h>

Go to the source code of this file.

Classes

struct  ascon_kmac_state_t
 State information for the ASCON-KMAC incremental mode. More...
 
struct  ascon_kmaca_state_t
 State information for the ASCON-KMACA incremental mode. More...
 

Macros

#define ASCON_KMAC_SIZE   ASCON_HASH_SIZE
 Default size of the output for ASCON-KMAC. More...
 
#define ASCON_KMACA_SIZE   ASCON_HASHA_SIZE
 Default size of the output for ASCON-KMACA. More...
 

Functions

void ascon_kmac (const unsigned char *key, size_t keylen, const unsigned char *in, size_t inlen, const unsigned char *custom, size_t customlen, unsigned char *out, size_t outlen)
 Computes a KMAC value using ASCON-XOF. More...
 
void ascon_kmac_init (ascon_kmac_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *custom, size_t customlen, size_t outlen)
 Initializes an incremental KMAC state using ASCON-XOF. More...
 
void ascon_kmac_reinit (ascon_kmac_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *custom, size_t customlen, size_t outlen)
 Re-initializes an incremental KMAC state using ASCON-XOF. More...
 
void ascon_kmac_free (ascon_kmac_state_t *state)
 Frees the ASCON-KMAC state and destroys any sensitive material. More...
 
void ascon_kmac_absorb (ascon_kmac_state_t *state, const unsigned char *in, size_t inlen)
 Absorbs more input data into an incremental ASCON-KMAC state. More...
 
void ascon_kmac_squeeze (ascon_kmac_state_t *state, unsigned char *out, size_t outlen)
 Squeezes output data from an incremental ASCON-KMAC state. More...
 
void ascon_kmaca (const unsigned char *key, size_t keylen, const unsigned char *in, size_t inlen, const unsigned char *custom, size_t customlen, unsigned char *out, size_t outlen)
 Computes a KMAC value using ASCON-XOFA. More...
 
void ascon_kmaca_init (ascon_kmaca_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *custom, size_t customlen, size_t outlen)
 Initializes an incremental KMAC state using ASCON-XOFA. More...
 
void ascon_kmaca_reinit (ascon_kmaca_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *custom, size_t customlen, size_t outlen)
 Re-initializes an incremental KMAC state using ASCON-XOFA. More...
 
void ascon_kmaca_free (ascon_kmaca_state_t *state)
 Frees the ASCON-KMACA state and destroys any sensitive material. More...
 
void ascon_kmaca_absorb (ascon_kmaca_state_t *state, const unsigned char *in, size_t inlen)
 Absorbs more input data into an incremental ASCON-KMACA state. More...
 
void ascon_kmaca_squeeze (ascon_kmaca_state_t *state, unsigned char *out, size_t outlen)
 Squeezes output data from an incremental ASCON-KMACA state. More...
 

Detailed Description

Keyed Message Authentication Code (KMAC) based on ASCON-XOF.

The KMAC mode provides a method to authenticate a sequence of bytes using ASCON in hashing mode. The output is essentially equivalent to hashing the key followed by the data.

NIST SP 800-185 is an extension of the XOF modes SHAKE128 and SHAKE256. The nearest equivalent for us is ASCON-XOF with function names and customization strings.

Two versions of KMAC are provided: ASCON-KMAC based around ASCON-XOF, and ASCON-KMACA based around ASCON-XOFA.

References: NIST SP 800-185

Definition in file kmac.h.

Macro Definition Documentation

◆ ASCON_KMAC_SIZE

#define ASCON_KMAC_SIZE   ASCON_HASH_SIZE

Default size of the output for ASCON-KMAC.

Definition at line 53 of file kmac.h.

◆ ASCON_KMACA_SIZE

#define ASCON_KMACA_SIZE   ASCON_HASHA_SIZE

Default size of the output for ASCON-KMACA.

Definition at line 58 of file kmac.h.

Function Documentation

◆ ascon_kmac()

void ascon_kmac ( const unsigned char *  key,
size_t  keylen,
const unsigned char *  in,
size_t  inlen,
const unsigned char *  custom,
size_t  customlen,
unsigned char *  out,
size_t  outlen 
)

Computes a KMAC value using ASCON-XOF.

Parameters
keyPoints to the key.
keylenNumber of bytes in the key.
inPoints to the data to authenticate.
inlenNumber of bytes of data to authenticate.
customPoints to the customization string.
customlenNumber of bytes in the customization string.
outBuffer to receive the output KMAC value.
outlenLength of the output KMAC value.

The customization string allows the application to perform domain separation between different uses of the KMAC algorithm.

Definition at line 70 of file ascon-kmac.c.

◆ ascon_kmac_absorb()

void ascon_kmac_absorb ( ascon_kmac_state_t state,
const unsigned char *  in,
size_t  inlen 
)

Absorbs more input data into an incremental ASCON-KMAC state.

Parameters
stateKMAC state to be updated.
inPoints to the input data to be absorbed into the state.
inlenLength of the input data to be absorbed into the state.
See also
ascon_kmac_init(), ascon_kmac_squeeze()

Definition at line 110 of file ascon-kmac.c.

◆ ascon_kmac_free()

void ascon_kmac_free ( ascon_kmac_state_t state)

Frees the ASCON-KMAC state and destroys any sensitive material.

Parameters
stateKMAC state to be freed.

Definition at line 104 of file ascon-kmac.c.

◆ ascon_kmac_init()

void ascon_kmac_init ( ascon_kmac_state_t state,
const unsigned char *  key,
size_t  keylen,
const unsigned char *  custom,
size_t  customlen,
size_t  outlen 
)

Initializes an incremental KMAC state using ASCON-XOF.

Parameters
statePoints to the state to be initialized.
keyPoints to the key.
keylenNumber of bytes in the key.
customPoints to the customization string.
customlenNumber of bytes in the customization string.
outlenThe desired output length in bytes, or 0 for arbitrary-length.
See also
ascon_kmac_update(), ascon_kmac_squeeze()

Definition at line 83 of file ascon-kmac.c.

◆ ascon_kmac_reinit()

void ascon_kmac_reinit ( ascon_kmac_state_t state,
const unsigned char *  key,
size_t  keylen,
const unsigned char *  custom,
size_t  customlen,
size_t  outlen 
)

Re-initializes an incremental KMAC state using ASCON-XOF.

Parameters
statePoints to the state to be initialized.
keyPoints to the key.
keylenNumber of bytes in the key.
customPoints to the customization string.
customlenNumber of bytes in the customization string.
outlenThe desired output length in bytes, or 0 for arbitrary-length.

This function is equivalent to calling ascon_kmac_free() and then ascon_kmac_init().

See also
ascon_kmac_init()

Definition at line 96 of file ascon-kmac.c.

◆ ascon_kmac_squeeze()

void ascon_kmac_squeeze ( ascon_kmac_state_t state,
unsigned char *  out,
size_t  outlen 
)

Squeezes output data from an incremental ASCON-KMAC state.

Parameters
stateKMAC state to squeeze the output data from.
outPoints to the output buffer to receive the squeezed data.
outlenNumber of bytes of data to squeeze out of the state.
See also
ascon_kmac_init(), ascon_kmac_update(), ascon_kmac_finalize()

Definition at line 116 of file ascon-kmac.c.

◆ ascon_kmaca()

void ascon_kmaca ( const unsigned char *  key,
size_t  keylen,
const unsigned char *  in,
size_t  inlen,
const unsigned char *  custom,
size_t  customlen,
unsigned char *  out,
size_t  outlen 
)

Computes a KMAC value using ASCON-XOFA.

Parameters
keyPoints to the key.
keylenNumber of bytes in the key.
inPoints to the data to authenticate.
inlenNumber of bytes of data to authenticate.
customPoints to the customization string.
customlenNumber of bytes in the customization string.
outBuffer to receive the output KMAC value.
outlenLength of the output KMAC value.

The customization string allows the application to perform domain separation between different uses of the KMAC algorithm.

Definition at line 70 of file ascon-kmaca.c.

◆ ascon_kmaca_absorb()

void ascon_kmaca_absorb ( ascon_kmaca_state_t state,
const unsigned char *  in,
size_t  inlen 
)

Absorbs more input data into an incremental ASCON-KMACA state.

Parameters
stateKMAC state to be updated.
inPoints to the input data to be absorbed into the state.
inlenLength of the input data to be absorbed into the state.
See also
ascon_kmaca_init(), ascon_kmaca_squeeze()

Definition at line 110 of file ascon-kmaca.c.

◆ ascon_kmaca_free()

void ascon_kmaca_free ( ascon_kmaca_state_t state)

Frees the ASCON-KMACA state and destroys any sensitive material.

Parameters
stateKMAC state to be freed.

Definition at line 104 of file ascon-kmaca.c.

◆ ascon_kmaca_init()

void ascon_kmaca_init ( ascon_kmaca_state_t state,
const unsigned char *  key,
size_t  keylen,
const unsigned char *  custom,
size_t  customlen,
size_t  outlen 
)

Initializes an incremental KMAC state using ASCON-XOFA.

Parameters
statePoints to the state to be initialized.
keyPoints to the key.
keylenNumber of bytes in the key.
customPoints to the customization string.
customlenNumber of bytes in the customization string.
outlenThe desired output length in bytes, or 0 for arbitrary-length.
See also
ascon_kmaca_update(), ascon_kmaca_squeeze()

Definition at line 83 of file ascon-kmaca.c.

◆ ascon_kmaca_reinit()

void ascon_kmaca_reinit ( ascon_kmaca_state_t state,
const unsigned char *  key,
size_t  keylen,
const unsigned char *  custom,
size_t  customlen,
size_t  outlen 
)

Re-initializes an incremental KMAC state using ASCON-XOFA.

Parameters
statePoints to the state to be initialized.
keyPoints to the key.
keylenNumber of bytes in the key.
customPoints to the customization string.
customlenNumber of bytes in the customization string.
outlenThe desired output length in bytes, or 0 for arbitrary-length.

This function is equivalent to calling ascon_kmaca_free() and then ascon_kmaca_init().

See also
ascon_kmaca_init()

Definition at line 96 of file ascon-kmaca.c.

◆ ascon_kmaca_squeeze()

void ascon_kmaca_squeeze ( ascon_kmaca_state_t state,
unsigned char *  out,
size_t  outlen 
)

Squeezes output data from an incremental ASCON-KMACA state.

Parameters
stateKMAC state to squeeze the output data from.
outPoints to the output buffer to receive the squeezed data.
outlenNumber of bytes of data to squeeze out of the state.
See also
ascon_kmaca_init(), ascon_kmaca_update(), ascon_kmaca_finalize()

Definition at line 116 of file ascon-kmaca.c.