ASCON Suite
Functions
ascon-sliced32.c File Reference
#include "ascon-sliced32.h"
#include "ascon-util.h"
#include "ascon-util-snp.h"
#include <ascon/utility.h>

Go to the source code of this file.

Functions

void ascon_init (ascon_state_t *state)
 Initializes the words of the ASCON permutation state to zero. More...
 
void ascon_free (ascon_state_t *state)
 Frees an ASCON permutation state and attempts to destroy any sensitive material. More...
 
void ascon_add_bytes (ascon_state_t *state, const uint8_t *data, unsigned offset, unsigned size)
 Adds bytes to the ASCON state by XOR'ing them with existing bytes. More...
 
void ascon_overwrite_bytes (ascon_state_t *state, const uint8_t *data, unsigned offset, unsigned size)
 Overwrites existing bytes in the ASCON state. More...
 
void ascon_overwrite_with_zeroes (ascon_state_t *state, unsigned offset, unsigned size)
 Overwrites a part of the ASCON state with zeroes. More...
 
void ascon_extract_bytes (const ascon_state_t *state, uint8_t *data, unsigned offset, unsigned size)
 Extracts bytes from the ASCON state. More...
 
void ascon_extract_and_add_bytes (const ascon_state_t *state, const uint8_t *input, uint8_t *output, unsigned offset, unsigned size)
 Extracts bytes from the ASCON state and XOR's them with input bytes to produce output bytes. More...
 
void ascon_extract_and_overwrite_bytes (ascon_state_t *state, const uint8_t *input, uint8_t *output, unsigned offset, unsigned size)
 Extracts bytes from the ASCON state and XOR's them with input bytes to produce output bytes. Also write the original input bytes into the ASCON state. More...
 
void ascon_release (ascon_state_t *state)
 Temporarily releases access to any shared hardware resources that a permutation state was using. More...
 
void ascon_acquire (ascon_state_t *state)
 Re-acquires access to any shared hardware resources that a permutation state was using. More...
 
void ascon_copy (ascon_state_t *dest, const ascon_state_t *src)
 Copies the entire ASCON permutation state from a source to a destination. More...
 

Function Documentation

◆ ascon_acquire()

void ascon_acquire ( ascon_state_t state)

Re-acquires access to any shared hardware resources that a permutation state was using.

Parameters
stateThe ASCON state to be re-acquired.
See also
ascon_release()

Definition at line 267 of file ascon-sliced32.c.

◆ ascon_add_bytes()

void ascon_add_bytes ( ascon_state_t state,
const uint8_t *  data,
unsigned  offset,
unsigned  size 
)

Adds bytes to the ASCON state by XOR'ing them with existing bytes.

Parameters
stateThe ASCON state in "operational" form.
dataPoints to the data to add to the state.
offsetOffset into the state between 0 and 40 - size.
sizeNumber of bytes to add to the state between 0 and 40.

Definition at line 50 of file ascon-sliced32.c.

◆ ascon_copy()

void ascon_copy ( ascon_state_t dest,
const ascon_state_t src 
)

Copies the entire ASCON permutation state from a source to a destination.

Parameters
destThe destination to copy to.
srcThe source to copy from.

The destination must be acquired and the source must be released.

Definition at line 273 of file ascon-sliced32.c.

◆ ascon_extract_and_add_bytes()

void ascon_extract_and_add_bytes ( const ascon_state_t state,
const uint8_t *  input,
uint8_t *  output,
unsigned  offset,
unsigned  size 
)

Extracts bytes from the ASCON state and XOR's them with input bytes to produce output bytes.

Parameters
stateThe ASCON state in "operational" form.
inputPoints to the input buffer.
outputPoints to the output buffer.
offsetOffset into the state between 0 and 40 - size.
sizeNumber of bytes to extract from the state between 0 and 40.

Definition at line 182 of file ascon-sliced32.c.

◆ ascon_extract_and_overwrite_bytes()

void ascon_extract_and_overwrite_bytes ( ascon_state_t state,
const uint8_t *  input,
uint8_t *  output,
unsigned  offset,
unsigned  size 
)

Extracts bytes from the ASCON state and XOR's them with input bytes to produce output bytes. Also write the original input bytes into the ASCON state.

Parameters
stateThe ASCON state in "operational" form.
inputPoints to the input buffer.
outputPoints to the output buffer.
offsetOffset into the state between 0 and 40 - size.
sizeNumber of bytes to extract from the state between 0 and 40.

This function has the effect of calling ascon_extract_and_add_bytes() and then ascon_overwrite_bytes(), but it also works for the case where input and output are the same buffer. This combination is typically used for AEAD decryption where the input ciphertext needs to be incorporated into the state to authenticate it.

Definition at line 217 of file ascon-sliced32.c.

◆ ascon_extract_bytes()

void ascon_extract_bytes ( const ascon_state_t state,
uint8_t *  data,
unsigned  offset,
unsigned  size 
)

Extracts bytes from the ASCON state.

Parameters
stateThe ASCON state in "operational" form.
dataPoints to the buffer to receive the extracted bytes.
offsetOffset into the state between 0 and 40 - size.
sizeNumber of bytes to extract from the state between 0 and 40.

Definition at line 150 of file ascon-sliced32.c.

◆ ascon_free()

void ascon_free ( ascon_state_t state)

Frees an ASCON permutation state and attempts to destroy any sensitive material.

Parameters
stateThe ASCON state to be freed.

If ascon_init() had to allocate internal structures to interface with a platform-specific acceleration module, then this function will deallocate those structures.

There is no guarantee that all traces of the sensitive material will be gone. Fragments may be left on the stack or in registers from previous permutation calls. This function will make a best effort given the constraints of the platform.

See also
ascon_init()

Definition at line 42 of file ascon-sliced32.c.

◆ ascon_init()

void ascon_init ( ascon_state_t state)

Initializes the words of the ASCON permutation state to zero.

Parameters
stateThe ASCON state to initialize.

This function might allocate internal state to hold more information than will fit in the ascon_state_t structure to interface with a platform-specific acceleration module.

It is always a good idea to call this before using the permutation state. Also make sure to call ascon_free() when the permutation state is no longer required to deallocate the internal state.

See also
ascon_free()

Definition at line 32 of file ascon-sliced32.c.

◆ ascon_overwrite_bytes()

void ascon_overwrite_bytes ( ascon_state_t state,
const uint8_t *  data,
unsigned  offset,
unsigned  size 
)

Overwrites existing bytes in the ASCON state.

Parameters
stateThe ASCON state in "operational" form.
dataPoints to the data to write to the state.
offsetOffset into the state between 0 and 40 - size.
sizeNumber of bytes to overwrite between 0 and 40.

Definition at line 84 of file ascon-sliced32.c.

◆ ascon_overwrite_with_zeroes()

void ascon_overwrite_with_zeroes ( ascon_state_t state,
unsigned  offset,
unsigned  size 
)

Overwrites a part of the ASCON state with zeroes.

Parameters
stateThe ASCON state in "operational" form.
offsetOffset into the state between 0 and 40 - size.
sizeNumber of bytes to overwrite between 0 and 40.

Definition at line 121 of file ascon-sliced32.c.

◆ ascon_release()

void ascon_release ( ascon_state_t state)

Temporarily releases access to any shared hardware resources that a permutation state was using.

Parameters
stateThe ASCON state to be released.

Operation on the state will resume the next time ascon_acquire() is called.

The ascon_free() function implicitly releases the state so it usually isn't necessary to release the state explicitly. However, if the application will not be using the state for some time then it should call ascon_release() to allow other tasks on the system to access the shared hardware.

See also
ascon_acquire()

Definition at line 261 of file ascon-sliced32.c.