ASCON Suite
|
#include <ascon/xof.h>
#include "core/ascon-util-snp.h"
#include "hash/ascon-xof-internal.h"
#include <string.h>
Go to the source code of this file.
Functions | |
void | ascon_xof (unsigned char *out, const unsigned char *in, size_t inlen) |
Hashes a block of input data with ASCON-XOF and generates a fixed-length 32 byte output. More... | |
void | ascon_xof_init (ascon_xof_state_t *state) |
Initializes the state for an ASCON-XOF hashing operation. More... | |
void | ascon_xof_init_fixed (ascon_xof_state_t *state, size_t outlen) |
Initializes the state for an incremental ASCON-XOF operation, with a fixed output length. More... | |
void | ascon_xof_absorb_custom (ascon_xof_state_t *state, const unsigned char *custom, size_t customlen) |
Absorbs a customization string into an ASCON-XOF state. More... | |
void | ascon_xof_init_custom (ascon_xof_state_t *state, const char *function_name, const unsigned char *custom, size_t customlen, size_t outlen) |
Initializes the state for an incremental ASCON-XOF operation, with a named function, customization string, and output length. More... | |
void | ascon_xof_reinit (ascon_xof_state_t *state) |
Re-initializes the state for an ASCON-XOF hashing operation. More... | |
void | ascon_xof_reinit_fixed (ascon_xof_state_t *state, size_t outlen) |
Re-initializes the state for an incremental ASCON-XOF operation, with a fixed output length. More... | |
void | ascon_xof_reinit_custom (ascon_xof_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-XOF operation, with a named function, customization string, and output length. More... | |
void | ascon_xof_free (ascon_xof_state_t *state) |
Frees the ASCON-XOF state and destroys any sensitive material. More... | |
void | ascon_xof_absorb (ascon_xof_state_t *state, const unsigned char *in, size_t inlen) |
Absorbs more input data into an ASCON-XOF state. More... | |
void | ascon_xof_squeeze (ascon_xof_state_t *state, unsigned char *out, size_t outlen) |
Squeezes output data from an ASCON-XOF state. More... | |
void | ascon_xof_pad (ascon_xof_state_t *state) |
Absorbs enough zeroes into an ASCON-XOF state to pad the input to the next multiple of the block rate. More... | |
void | ascon_xof_copy (ascon_xof_state_t *dest, const ascon_xof_state_t *src) |
Clones a copy of an ASCON-XOF state. More... | |
void ascon_xof | ( | unsigned char * | out, |
const unsigned char * | in, | ||
size_t | inlen | ||
) |
Hashes a block of input data with ASCON-XOF and generates a fixed-length 32 byte output.
out | Buffer to receive the hash output which must be at least 32 bytes in length. |
in | Points to the input data to be hashed. |
inlen | Length of the input data in bytes. |
Use ascon_xof_squeeze() instead if you need variable-length XOF ouutput.
Definition at line 28 of file ascon-xof.c.
void ascon_xof_absorb | ( | ascon_xof_state_t * | state, |
const unsigned char * | in, | ||
size_t | inlen | ||
) |
Absorbs more input data into an ASCON-XOF state.
state | XOF state to be updated. |
in | Points to the input data to be absorbed into the state. |
inlen | Length of the input data to be absorbed into the state. |
Definition at line 228 of file ascon-xof.c.
void ascon_xof_absorb_custom | ( | ascon_xof_state_t * | state, |
const unsigned char * | custom, | ||
size_t | customlen | ||
) |
Absorbs a customization string into an ASCON-XOF state.
state | XOF state to be updated. |
custom | Points to the customization string. |
customlen | Number of bytes in the customization string. |
Definition at line 131 of file ascon-xof.c.
void ascon_xof_copy | ( | ascon_xof_state_t * | dest, |
const ascon_xof_state_t * | src | ||
) |
Clones a copy of an ASCON-XOF state.
dest | Destination XOF state to copy into. |
src | Source 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 344 of file ascon-xof.c.
void ascon_xof_free | ( | ascon_xof_state_t * | state | ) |
Frees the ASCON-XOF state and destroys any sensitive material.
state | XOF state to be freed. |
Definition at line 218 of file ascon-xof.c.
void ascon_xof_init | ( | ascon_xof_state_t * | state | ) |
Initializes the state for an ASCON-XOF hashing operation.
state | XOF state to be initialized. |
Definition at line 37 of file ascon-xof.c.
void ascon_xof_init_custom | ( | ascon_xof_state_t * | state, |
const char * | function_name, | ||
const unsigned char * | custom, | ||
size_t | customlen, | ||
size_t | outlen | ||
) |
Initializes the state for an incremental ASCON-XOF operation, with a named function, customization string, and output length.
state | XOF state to be initialized. |
function_name | Name of the function; e.g. "KMAC". May be NULL or empty for no function name. |
custom | Points to the customization string. |
customlen | Number of bytes in the customization string. |
outlen | The 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.
Definition at line 145 of file ascon-xof.c.
void ascon_xof_init_fixed | ( | ascon_xof_state_t * | state, |
size_t | outlen | ||
) |
Initializes the state for an incremental ASCON-XOF operation, with a fixed output length.
state | XOF state to be initialized. |
outlen | The 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.
Definition at line 74 of file ascon-xof.c.
void ascon_xof_pad | ( | ascon_xof_state_t * | state | ) |
Absorbs enough zeroes into an ASCON-XOF state to pad the input to the next multiple of the block rate.
state | XOF 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 329 of file ascon-xof.c.
void ascon_xof_reinit | ( | ascon_xof_state_t * | state | ) |
Re-initializes the state for an ASCON-XOF hashing operation.
state | XOF state to be re-initialized. |
This function is equivalent to calling ascon_xof_free() and then ascon_xof_init() to restart the hashing process.
Definition at line 183 of file ascon-xof.c.
void ascon_xof_reinit_custom | ( | ascon_xof_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-XOF operation, with a named function, customization string, and output length.
state | XOF state to be initialized. |
function_name | Name of the function; e.g. "KMAC". May be NULL or empty for no function name. |
custom | Points to the customization string. |
customlen | Number of bytes in the customization string. |
outlen | The desired output length in bytes, or 0 for arbitrary-length. |
Definition at line 205 of file ascon-xof.c.
void ascon_xof_reinit_fixed | ( | ascon_xof_state_t * | state, |
size_t | outlen | ||
) |
Re-initializes the state for an incremental ASCON-XOF operation, with a fixed output length.
state | XOF state to be re-initialized. |
outlen | The desired output length in bytes, or 0 for arbitrary-length. |
This function is equivalent to calling ascon_xof_free() and then ascon_xof_init_fixed() to restart the hashing process.
Definition at line 194 of file ascon-xof.c.
void ascon_xof_squeeze | ( | ascon_xof_state_t * | state, |
unsigned char * | out, | ||
size_t | outlen | ||
) |
Squeezes output data from an ASCON-XOF state.
state | XOF state to squeeze the output data from. |
out | Points to the output buffer to receive the squeezed data. |
outlen | Number of bytes of data to squeeze out of the state. |
Definition at line 278 of file ascon-xof.c.