ASCON Suite
Functions
ascon-xofa.c File Reference
#include <ascon/xof.h>
#include "core/ascon-util-snp.h"

Go to the source code of this file.

Functions

void ascon_xofa (unsigned char *out, const unsigned char *in, size_t inlen)
 Hashes a block of input data with ASCON-XOFA and generates a fixed-length 32 byte output. More...
 
void ascon_xofa_init (ascon_xofa_state_t *state)
 Initializes the state for an ASCON-XOFA hashing operation. More...
 
void ascon_xofa_init_fixed (ascon_xofa_state_t *state, size_t outlen)
 Initializes the state for an incremental ASCON-XOFA operation, with a fixed output length. More...
 
void ascon_xofa_absorb_custom (ascon_xofa_state_t *state, const unsigned char *custom, size_t customlen)
 Absorbs a customization string into an ASCON-XOFA state. More...
 
void ascon_xofa_init_custom (ascon_xofa_state_t *state, const char *function_name, const unsigned char *custom, size_t customlen, size_t outlen)
 Initializes the state for an incremental ASCON-XOFA operation, with a named function, customization string, and output length. More...
 
void ascon_xofa_reinit (ascon_xofa_state_t *state)
 Re-initializes the state for an ASCON-XOFA hashing operation. More...
 
void ascon_xofa_reinit_fixed (ascon_xofa_state_t *state, size_t outlen)
 Re-initializes the state for an incremental ASCON-XOFA operation, with a fixed output length. More...
 
void ascon_xofa_reinit_custom (ascon_xofa_state_t *state, const char *function_name, const unsigned char *custom, size_t customlen, size_t outlen)
 Re-nitializes the state for an incremental ASCON-XOFA operation, with a named function, customization string, and output length. More...
 
void ascon_xofa_free (ascon_xofa_state_t *state)
 Frees the ASCON-XOFA state and destroys any sensitive material. More...
 
void ascon_xofa_absorb (ascon_xofa_state_t *state, const unsigned char *in, size_t inlen)
 Absorbs more input data into an ASCON-XOFA state. More...
 
void ascon_xofa_squeeze (ascon_xofa_state_t *state, unsigned char *out, size_t outlen)
 Squeezes output data from an ASCON-XOFA state. More...
 
void ascon_xofa_pad (ascon_xofa_state_t *state)
 Absorbs enough zeroes into an ASCON-XOFA state to pad the input to the next multiple of the block rate. More...
 
void ascon_xofa_copy (ascon_xofa_state_t *dest, const ascon_xofa_state_t *src)
 Clones a copy of an ASCON-XOFA state. More...
 

Function Documentation

◆ ascon_xofa()

void ascon_xofa ( unsigned char *  out,
const unsigned char *  in,
size_t  inlen 
)

Hashes a block of input data with ASCON-XOFA and generates a fixed-length 32 byte output.

Parameters
outBuffer to receive the hash output which must be at least 32 bytes in length.
inPoints to the input data to be hashed.
inlenLength of the input data in bytes.

Use ascon_xofa_squeeze() instead if you need variable-length XOF ouutput.

See also
ascon_xofa_init(), ascon_xofa_absorb(), ascon_xofa_squeeze()

Definition at line 26 of file ascon-xofa.c.

◆ ascon_xofa_absorb()

void ascon_xofa_absorb ( ascon_xofa_state_t state,
const unsigned char *  in,
size_t  inlen 
)

Absorbs more input data into an ASCON-XOFA state.

Parameters
stateXOF 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_xofa_init(), ascon_xofa_squeeze()

Definition at line 226 of file ascon-xofa.c.

◆ ascon_xofa_absorb_custom()

void ascon_xofa_absorb_custom ( ascon_xofa_state_t state,
const unsigned char *  custom,
size_t  customlen 
)

Absorbs a customization string into an ASCON-XOFA state.

Parameters
stateXOF state to be updated.
customPoints to the customization string.
customlenNumber of bytes in the customization string.

Definition at line 129 of file ascon-xofa.c.

◆ ascon_xofa_copy()

void ascon_xofa_copy ( ascon_xofa_state_t dest,
const ascon_xofa_state_t src 
)

Clones a copy of an ASCON-XOFA state.

Parameters
destDestination XOF state to copy into.
srcSource XOF state to copy from.

The destination will be initialized by this operation, so it must not previously have been initialized or it has already been freed. The source must be already initialized.

Definition at line 343 of file ascon-xofa.c.

◆ ascon_xofa_free()

void ascon_xofa_free ( ascon_xofa_state_t state)

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

Parameters
stateXOF state to be freed.

Definition at line 216 of file ascon-xofa.c.

◆ ascon_xofa_init()

void ascon_xofa_init ( ascon_xofa_state_t state)

Initializes the state for an ASCON-XOFA hashing operation.

Parameters
stateXOF state to be initialized.
See also
ascon_xofa_absorb(), ascon_xofa_squeeze(), ascon_xofa()

Definition at line 35 of file ascon-xofa.c.

◆ ascon_xofa_init_custom()

void ascon_xofa_init_custom ( ascon_xofa_state_t state,
const char *  function_name,
const unsigned char *  custom,
size_t  customlen,
size_t  outlen 
)

Initializes the state for an incremental ASCON-XOFA operation, with a named function, customization string, and output length.

Parameters
stateXOF state to be initialized.
function_nameName of the function; e.g. "KMAC". May be NULL or empty for no function name.
customPoints to the customization string.
customlenNumber of bytes in the customization string.
outlenThe desired output length in bytes, or 0 for arbitrary-length.

In the ASCON standard, the output length is encoded as a bit counter in a 32-bit word. If outlen is greater than 536870911, it will be replaced with zero to indicate arbitary-length output instead.

This version of initialization is intended for building higher-level functions like KMAC on top of ASCON-XOF. The function name provides domain separation between different functions. The customization string provides domain separation between different users of the same function.

See also
ascon_xofa_init()

Definition at line 143 of file ascon-xofa.c.

◆ ascon_xofa_init_fixed()

void ascon_xofa_init_fixed ( ascon_xofa_state_t state,
size_t  outlen 
)

Initializes the state for an incremental ASCON-XOFA operation, with a fixed output length.

Parameters
stateXOF state to be initialized.
outlenThe desired output length in bytes, or 0 for arbitrary-length.

In the ASCON standard, the output length is encoded as a bit counter in a 32-bit word. If outlen is greater than 536870911, it will be replaced with zero to indicate arbitary-length output instead.

See also
ascon_xofa_init()

Definition at line 72 of file ascon-xofa.c.

◆ ascon_xofa_pad()

void ascon_xofa_pad ( ascon_xofa_state_t state)

Absorbs enough zeroes into an ASCON-XOFA state to pad the input to the next multiple of the block rate.

Parameters
stateXOF state to pad. Does nothing if the state is already aligned on a multiple of the block rate.

This function can avoid unnecessary XOR-with-zero operations to save some time when padding is required.

Definition at line 328 of file ascon-xofa.c.

◆ ascon_xofa_reinit()

void ascon_xofa_reinit ( ascon_xofa_state_t state)

Re-initializes the state for an ASCON-XOFA hashing operation.

Parameters
stateXOF state to be re-initialized.

This function is equivalent to calling ascon_xofa_free() and then ascon_xofa_init() to restart the hashing process.

See also
ascon_xof_init()

Definition at line 181 of file ascon-xofa.c.

◆ ascon_xofa_reinit_custom()

void ascon_xofa_reinit_custom ( ascon_xofa_state_t state,
const char *  function_name,
const unsigned char *  custom,
size_t  customlen,
size_t  outlen 
)

Re-nitializes the state for an incremental ASCON-XOFA operation, with a named function, customization string, and output length.

Parameters
stateXOF state to be initialized.
function_nameName of the function; e.g. "KMAC". May be NULL or empty for no function name.
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_xofa_init_custom()

Definition at line 203 of file ascon-xofa.c.

◆ ascon_xofa_reinit_fixed()

void ascon_xofa_reinit_fixed ( ascon_xofa_state_t state,
size_t  outlen 
)

Re-initializes the state for an incremental ASCON-XOFA operation, with a fixed output length.

Parameters
stateXOF state to be re-initialized.
outlenThe desired output length in bytes, or 0 for arbitrary-length.

This function is equivalent to calling ascon_xofa_free() and then ascon_xofa_init_fixed() to restart the hashing process.

See also
ascon_xof_init_fixed()

Definition at line 192 of file ascon-xofa.c.

◆ ascon_xofa_squeeze()

void ascon_xofa_squeeze ( ascon_xofa_state_t state,
unsigned char *  out,
size_t  outlen 
)

Squeezes output data from an ASCON-XOFA state.

Parameters
stateXOF 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_xofa_init(), ascon_xofa_update()

Definition at line 276 of file ascon-xofa.c.