ASCON Suite
|
ASCON-Prf, ASCON-PrfShort, and ASCON-Mac algorithms. More...
#include <ascon/permutation.h>
Go to the source code of this file.
Classes | |
struct | ascon_prf_state_t |
State information for the ASCON-Prf incremental mode. More... | |
Macros | |
#define | ASCON_PRF_KEY_SIZE 16 |
Size of the key for ASCON-Prf in bytes. More... | |
#define | ASCON_PRF_TAG_SIZE 16 |
Default size of the ASCON-Prf output in bytes. More... | |
#define | ASCON_PRF_SHORT_KEY_SIZE ASCON_PRF_KEY_SIZE |
Size of the key for ASCON-PrfShort in bytes. More... | |
#define | ASCON_PRF_SHORT_MAX_INPUT_SIZE 16 |
Maximum number of bytes that can be input to ASCON-PrfShort. More... | |
#define | ASCON_PRF_SHORT_MAX_OUTPUT_SIZE 16 |
Maximum number of bytes that can be output from ASCON-PrfShort. More... | |
#define | ASCON_PRF_SHORT_TAG_SIZE ASCON_PRF_SHORT_MAX_OUTPUT_SIZE |
Default size of the ASCON-PrfShort output in bytes. More... | |
#define | ASCON_MAC_KEY_SIZE ASCON_PRF_KEY_SIZE |
Size of the key for ASCON-Mac in bytes. More... | |
#define | ASCON_MAC_TAG_SIZE ASCON_PRF_TAG_SIZE |
Size of the ASCON-Mac output in bytes. More... | |
Functions | |
void | ascon_prf (unsigned char *out, size_t outlen, const unsigned char *in, size_t inlen, const unsigned char *key) |
Processes a key and input data with ASCON-Prf to produce a tag. More... | |
void | ascon_prf_fixed (unsigned char *out, size_t outlen, const unsigned char *in, size_t inlen, const unsigned char *key) |
Processes a key and input data with ASCON-Prf to produce a fixed-length output tag. More... | |
int | ascon_prf_short (unsigned char *out, size_t outlen, const unsigned char *in, size_t inlen, const unsigned char *key) |
Processes a key and input data with ASCON-PrfShort to produce a tag. More... | |
void | ascon_mac (unsigned char *tag, const unsigned char *in, size_t inlen, const unsigned char *key) |
Processes a key and input data with ASCON-Mac to produce a tag. More... | |
int | ascon_mac_verify (const unsigned char *tag, const unsigned char *in, size_t inlen, const unsigned char *key) |
Verifies an ASCON-Mac tag value. More... | |
void | ascon_prf_init (ascon_prf_state_t *state, const unsigned char *key) |
Initializes the state for an incremental ASCON-Prf operation. More... | |
void | ascon_prf_fixed_init (ascon_prf_state_t *state, const unsigned char *key, size_t outlen) |
Initializes the state for an incremental ASCON-Prf operation with fixed-length output. More... | |
void | ascon_prf_reinit (ascon_prf_state_t *state, const unsigned char *key) |
Re-initializes the state for an incremental ASCON-Prf operation. More... | |
void | ascon_prf_fixed_reinit (ascon_prf_state_t *state, const unsigned char *key, size_t outlen) |
Re-initializes the state for an incremental ASCON-Prf operation with fixed-length output. More... | |
void | ascon_prf_free (ascon_prf_state_t *state) |
Frees the ASCON-Prf state and destroys any sensitive material. More... | |
void | ascon_prf_absorb (ascon_prf_state_t *state, const unsigned char *in, size_t inlen) |
Absorbs input data into an incremental ASCON-Prf state. More... | |
void | ascon_prf_squeeze (ascon_prf_state_t *state, unsigned char *out, size_t outlen) |
Squeezes output from an incremental ASCON-Prf operation. More... | |
ASCON-Prf, ASCON-PrfShort, and ASCON-Mac algorithms.
ASCON-Prf is a pseudorandom function (PRF) built around the ASCON permutation. It provides a method to combine a 128-bit key and an arbitary amount of input to produce an arbitrary amount of output.
ASCON-Prf can be used as a lightweight key derivation function (KDF) in place of other options like ASCON-HKDF or ASCON-KMAC when the key is 128 bits in size.
ASCON-Mac wraps ASCON-Prf to turn it into a message authentication code (MAC) with an arbitrary amount of input and a fixed 128 bits of output. ASCON-Mac is identical to ASCON-Prf with an output length of 128 bits and also provides an API to verify authentication tags.
ASCON-PrfShort is a cut-down version of ASCON-Prf that is limited to a single block of input of 128 bits or less in size, and a single block of output of 128 bits or less in size.
ASCON-PrfShort is suitable for authenticating very small amounts of data in a single ASCON permutation call. It can also be used as a key derivation function (KDF) in protocols that derive 128-bit symmetric keys from a 128-bit master key, with the input being used for domain separation between the different derived keys.
References: https://eprint.iacr.org/2021/1574
Definition in file prf.h.
#define ASCON_MAC_KEY_SIZE ASCON_PRF_KEY_SIZE |
#define ASCON_MAC_TAG_SIZE ASCON_PRF_TAG_SIZE |
#define ASCON_PRF_KEY_SIZE 16 |
#define ASCON_PRF_SHORT_KEY_SIZE ASCON_PRF_KEY_SIZE |
#define ASCON_PRF_SHORT_MAX_INPUT_SIZE 16 |
#define ASCON_PRF_SHORT_MAX_OUTPUT_SIZE 16 |
#define ASCON_PRF_SHORT_TAG_SIZE ASCON_PRF_SHORT_MAX_OUTPUT_SIZE |
#define ASCON_PRF_TAG_SIZE 16 |
void ascon_mac | ( | unsigned char * | tag, |
const unsigned char * | in, | ||
size_t | inlen, | ||
const unsigned char * | key | ||
) |
Processes a key and input data with ASCON-Mac to produce a tag.
tag | Buffer to receive the ASCON_PRF_TAG_SIZE bytes of the tag. |
in | Points to the input data to be processed. |
inlen | Length of the input data in bytes. |
key | Points to the ASCON_PRF_KEY_SIZE bytes of the key. |
This function operates ASCON-Prf in fixed-length output mode with the output length set to ASCON_PRF_TAG_SIZE.
Definition at line 85 of file ascon-prf.c.
int ascon_mac_verify | ( | const unsigned char * | tag, |
const unsigned char * | in, | ||
size_t | inlen, | ||
const unsigned char * | key | ||
) |
Verifies an ASCON-Mac tag value.
tag | Buffer that contains the ASCON_PRF_TAG_SIZE bytes of the tag. |
in | Points to the input data to be processed. |
inlen | Length of the input data in bytes. |
key | Points to the ASCON_PRF_KEY_SIZE bytes of the key. |
Definition at line 97 of file ascon-prf.c.
void ascon_prf | ( | unsigned char * | out, |
size_t | outlen, | ||
const unsigned char * | in, | ||
size_t | inlen, | ||
const unsigned char * | key | ||
) |
Processes a key and input data with ASCON-Prf to produce a tag.
out | Buffer to receive the PRF tag which must be at least outlen bytes in length. |
outlen | Length of the output buffer in bytes. Recommended to be ASCON_PRF_TAG_SIZE. |
in | Points to the input data to be processed. |
inlen | Length of the input data in bytes. |
key | Points to the ASCON_PRF_KEY_SIZE bytes of the key. |
This function operates ASCON-Prf in unlimited output mode, with the output truncated at outlen bytes.
Definition at line 38 of file ascon-prf.c.
void ascon_prf_absorb | ( | ascon_prf_state_t * | state, |
const unsigned char * | in, | ||
size_t | inlen | ||
) |
Absorbs input data into an incremental ASCON-Prf state.
state | PRF state to be absorb. |
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 156 of file ascon-prf.c.
void ascon_prf_fixed | ( | unsigned char * | out, |
size_t | outlen, | ||
const unsigned char * | in, | ||
size_t | inlen, | ||
const unsigned char * | key | ||
) |
Processes a key and input data with ASCON-Prf to produce a fixed-length output tag.
out | Buffer to receive the PRF tag which must be at least outlen bytes in length. |
outlen | Length of the output buffer in bytes. Recommended to be ASCON_PRF_TAG_SIZE. |
in | Points to the input data to be processed. |
inlen | Length of the input data in bytes. |
key | Points to the ASCON_PRF_KEY_SIZE bytes of the key. |
This function operates ASCON-Prf in fixed-length output mode, with the output length set at exactly outlen bytes.
Definition at line 50 of file ascon-prf.c.
void ascon_prf_fixed_init | ( | ascon_prf_state_t * | state, |
const unsigned char * | key, | ||
size_t | outlen | ||
) |
Initializes the state for an incremental ASCON-Prf operation with fixed-length output.
state | PRF state to be initialized. |
key | Points to the ASCON_PRF_KEY_SIZE bytes of the key. |
outlen | Number of bytes of output that is desired, or 0 for unlimited. |
This function will set ASCON-Prf into unlimited output mode.
Definition at line 115 of file ascon-prf.c.
void ascon_prf_fixed_reinit | ( | ascon_prf_state_t * | state, |
const unsigned char * | key, | ||
size_t | outlen | ||
) |
Re-initializes the state for an incremental ASCON-Prf operation with fixed-length output.
state | PRF state to be re-initialized. |
key | Points to the ASCON_PRF_KEY_SIZE bytes of the key. |
outlen | Number of bytes of output that is desired, or 0 for unlimited. |
This function is equivalent to calling ascon_prf_free() and then ascon_prf_init() to restart the hashing process.
Definition at line 139 of file ascon-prf.c.
void ascon_prf_free | ( | ascon_prf_state_t * | state | ) |
Frees the ASCON-Prf state and destroys any sensitive material.
state | PRF state to be freed. |
Definition at line 146 of file ascon-prf.c.
void ascon_prf_init | ( | ascon_prf_state_t * | state, |
const unsigned char * | key | ||
) |
Initializes the state for an incremental ASCON-Prf operation.
state | PRF state to be initialized. |
key | Points to the ASCON_PRF_KEY_SIZE bytes of the key. |
This function will set ASCON-Prf into unlimited output mode.
Definition at line 110 of file ascon-prf.c.
void ascon_prf_reinit | ( | ascon_prf_state_t * | state, |
const unsigned char * | key | ||
) |
Re-initializes the state for an incremental ASCON-Prf operation.
state | PRF state to be re-initialized. |
key | Points to the ASCON_PRF_KEY_SIZE bytes of the key. |
This function is equivalent to calling ascon_prf_free() and then ascon_prf_init() to restart the hashing process.
Definition at line 133 of file ascon-prf.c.
int ascon_prf_short | ( | unsigned char * | out, |
size_t | outlen, | ||
const unsigned char * | in, | ||
size_t | inlen, | ||
const unsigned char * | key | ||
) |
Processes a key and input data with ASCON-PrfShort to produce a tag.
out | Buffer to receive the PRF tag which must be at least outlen bytes in length. |
outlen | Length of the output buffer in bytes between 0 and ASCON_PRF_SHORT_MAX_OUTPUT_SIZE. |
in | Points to the input data to be processed. |
inlen | Length of the input data in bytes between 0 and ASCON_PRF_SHORT_MAX_INPUT_SIZE. |
key | Points to the ASCON_PRF_KEY_SIZE bytes of the key. |
Definition at line 62 of file ascon-prf.c.
void ascon_prf_squeeze | ( | ascon_prf_state_t * | state, |
unsigned char * | out, | ||
size_t | outlen | ||
) |
Squeezes output from an incremental ASCON-Prf operation.
state | PRF state to squeeze output from. |
out | Points to the output buffer to receive the output. |
outlen | Number of bytes of output that are required for this call. |
This function can be called any number of times until all desired output has been retrieved.
Definition at line 207 of file ascon-prf.c.