ASCON Suite
Functions
ascon-masked-state.c File Reference
#include "ascon-masked-state.h"
#include "ascon-masked-backend.h"
#include "core/ascon-util-snp.h"
#include <ascon/utility.h>
#include <string.h>

Go to the source code of this file.

Functions

void ascon_masked_state_init (ascon_masked_state_t *state)
 Initializes the words of a masked ASCON permutation state. More...
 
void ascon_masked_state_free (ascon_masked_state_t *state)
 Frees an ASCON-x2 permutation state and attempts to destroy any sensitive material. More...
 
void ascon_x2_randomize (ascon_masked_state_t *state, ascon_trng_state_t *trng)
 Randomizes an ASCON-x2 permutation state. More...
 
void ascon_x2_copy_from_x1 (ascon_masked_state_t *dest, const ascon_state_t *src, ascon_trng_state_t *trng)
 Copies the entire ASCON-x2 permutation state from a regular ASCON-x1 permutation state. More...
 
void ascon_x2_copy_to_x1 (ascon_state_t *dest, const ascon_masked_state_t *src)
 Copies the entire ASCON-x2 permutation state to a regular ASCON-x1 permutation state. More...
 
void ascon_x2_copy_from_x2 (ascon_masked_state_t *dest, const ascon_masked_state_t *src, ascon_trng_state_t *trng)
 Copies the entire ASCON-x2 permutation state from a source to a destination. More...
 
void ascon_x2_copy_from_x3 (ascon_masked_state_t *dest, const ascon_masked_state_t *src, ascon_trng_state_t *trng)
 Copies the entire ASCON-x3 permutation state to an ASCON-x2 permutation state. More...
 
void ascon_x2_copy_from_x4 (ascon_masked_state_t *dest, const ascon_masked_state_t *src, ascon_trng_state_t *trng)
 Copies the entire ASCON-x4 permutation state to an ASCON-x2 permutation state. More...
 
void ascon_x3_randomize (ascon_masked_state_t *state, ascon_trng_state_t *trng)
 Randomizes an ASCON-x3 permutation state. More...
 
void ascon_x3_copy_from_x1 (ascon_masked_state_t *dest, const ascon_state_t *src, ascon_trng_state_t *trng)
 Copies the entire ASCON-x3 permutation state from a regular ASCON-x1 permutation state. More...
 
void ascon_x3_copy_to_x1 (ascon_state_t *dest, const ascon_masked_state_t *src)
 Copies the entire ASCON-x3 permutation state to a regular ASCON-x1 permutation state. More...
 
void ascon_x3_copy_from_x2 (ascon_masked_state_t *dest, const ascon_masked_state_t *src, ascon_trng_state_t *trng)
 Copies the entire ASCON-x3 permutation state from an ASCON-x2 permutation state. More...
 
void ascon_x3_copy_from_x3 (ascon_masked_state_t *dest, const ascon_masked_state_t *src, ascon_trng_state_t *trng)
 Copies the entire ASCON-x3 permutation state from a source to a destination. More...
 
void ascon_x3_copy_from_x4 (ascon_masked_state_t *dest, const ascon_masked_state_t *src, ascon_trng_state_t *trng)
 Copies the entire ASCON-x3 permutation state from an ASCON-x4 permutation state. More...
 
void ascon_x4_randomize (ascon_masked_state_t *state, ascon_trng_state_t *trng)
 Randomizes an ASCON-x4 permutation state. More...
 
void ascon_x4_copy_from_x1 (ascon_masked_state_t *dest, const ascon_state_t *src, ascon_trng_state_t *trng)
 Copies the entire ASCON-x4 permutation state from a regular ASCON-x1 permutation state. More...
 
void ascon_x4_copy_to_x1 (ascon_state_t *dest, const ascon_masked_state_t *src)
 Copies the entire ASCON-x4 permutation state to a regular ASCON-x1 permutation state. More...
 
void ascon_x4_copy_from_x2 (ascon_masked_state_t *dest, const ascon_masked_state_t *src, ascon_trng_state_t *trng)
 Copies the entire ASCON-x4 permutation state from an ASCON-x2 permutation state. More...
 
void ascon_x4_copy_from_x3 (ascon_masked_state_t *dest, const ascon_masked_state_t *src, ascon_trng_state_t *trng)
 Copies the entire ASCON-x4 permutation state from an ASCON-x3 permutation state. More...
 
void ascon_x4_copy_from_x4 (ascon_masked_state_t *dest, const ascon_masked_state_t *src, ascon_trng_state_t *trng)
 Copies the entire ASCON-x4 permutation state from a source to a destination. More...
 

Function Documentation

◆ ascon_masked_state_free()

void ascon_masked_state_free ( ascon_masked_state_t state)

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

Parameters
stateThe ASCON-x2 state to be freed.
See also
ascon_masked_state_init()

Definition at line 34 of file ascon-masked-state.c.

◆ ascon_masked_state_init()

void ascon_masked_state_init ( ascon_masked_state_t state)

Initializes the words of a masked ASCON permutation state.

Parameters
stateThe masked ASCON state to initialize.

All words will be set to zero with no randomness. The application must use functions ascon_x2_overwrite_word() to populate the initial randomized state.

See also
ascon_masked_state_free()

Definition at line 29 of file ascon-masked-state.c.

◆ ascon_x2_copy_from_x1()

void ascon_x2_copy_from_x1 ( ascon_masked_state_t dest,
const ascon_state_t src,
ascon_trng_state_t trng 
)

Copies the entire ASCON-x2 permutation state from a regular ASCON-x1 permutation state.

Parameters
destThe destination to copy to.
srcThe source to copy from.
trngTRNG to use to mask the original ASCON-x1 state.

Definition at line 49 of file ascon-masked-state.c.

◆ ascon_x2_copy_from_x2()

void ascon_x2_copy_from_x2 ( ascon_masked_state_t dest,
const ascon_masked_state_t src,
ascon_trng_state_t trng 
)

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

Parameters
destThe destination to copy to.
srcThe source to copy from.
trngTRNG to use to re-randomize the source state.

Definition at line 85 of file ascon-masked-state.c.

◆ ascon_x2_copy_from_x3()

void ascon_x2_copy_from_x3 ( ascon_masked_state_t dest,
const ascon_masked_state_t src,
ascon_trng_state_t trng 
)

Copies the entire ASCON-x3 permutation state to an ASCON-x2 permutation state.

Parameters
destThe destination to copy to after unmasking it.
srcThe source to copy from.
trngTRNG to use to randomize the output state.

Definition at line 98 of file ascon-masked-state.c.

◆ ascon_x2_copy_from_x4()

void ascon_x2_copy_from_x4 ( ascon_masked_state_t dest,
const ascon_masked_state_t src,
ascon_trng_state_t trng 
)

Copies the entire ASCON-x4 permutation state to an ASCON-x2 permutation state.

Parameters
destThe destination to copy to after unmasking it.
srcThe source to copy from.
trngTRNG to use to randomize the output state.

Definition at line 111 of file ascon-masked-state.c.

◆ ascon_x2_copy_to_x1()

void ascon_x2_copy_to_x1 ( ascon_state_t dest,
const ascon_masked_state_t src 
)

Copies the entire ASCON-x2 permutation state to a regular ASCON-x1 permutation state.

Parameters
destThe destination to copy to after unmasking it.
srcThe source to copy from.

The dest must be released and freed before this operation as it will be initialized by the process.

Definition at line 68 of file ascon-masked-state.c.

◆ ascon_x2_randomize()

void ascon_x2_randomize ( ascon_masked_state_t state,
ascon_trng_state_t trng 
)

Randomizes an ASCON-x2 permutation state.

Parameters
stateThe ASCON-x2 state to be randomized.
trngTRNG to use to randomize the state.

The state will still have the same effective value, but this function will mix in fresh randomness to all words.

Definition at line 40 of file ascon-masked-state.c.

◆ ascon_x3_copy_from_x1()

void ascon_x3_copy_from_x1 ( ascon_masked_state_t dest,
const ascon_state_t src,
ascon_trng_state_t trng 
)

Copies the entire ASCON-x3 permutation state from a regular ASCON-x1 permutation state.

Parameters
destThe destination to copy to.
srcThe source to copy from.
trngTRNG to use to mask the original ASCON-x1 state.

Definition at line 133 of file ascon-masked-state.c.

◆ ascon_x3_copy_from_x2()

void ascon_x3_copy_from_x2 ( ascon_masked_state_t dest,
const ascon_masked_state_t src,
ascon_trng_state_t trng 
)

Copies the entire ASCON-x3 permutation state from an ASCON-x2 permutation state.

Parameters
destThe destination to copy to.
srcThe source to copy from.
trngTRNG to use to randomize the output state.

Definition at line 169 of file ascon-masked-state.c.

◆ ascon_x3_copy_from_x3()

void ascon_x3_copy_from_x3 ( ascon_masked_state_t dest,
const ascon_masked_state_t src,
ascon_trng_state_t trng 
)

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

Parameters
destThe destination to copy to.
srcThe source to copy from.
trngTRNG to use to re-randomize the source state.

Definition at line 178 of file ascon-masked-state.c.

◆ ascon_x3_copy_from_x4()

void ascon_x3_copy_from_x4 ( ascon_masked_state_t dest,
const ascon_masked_state_t src,
ascon_trng_state_t trng 
)

Copies the entire ASCON-x3 permutation state from an ASCON-x4 permutation state.

Parameters
destThe destination to copy to.
srcThe source to copy from.
trngTRNG to use to randomize the output state.

Definition at line 191 of file ascon-masked-state.c.

◆ ascon_x3_copy_to_x1()

void ascon_x3_copy_to_x1 ( ascon_state_t dest,
const ascon_masked_state_t src 
)

Copies the entire ASCON-x3 permutation state to a regular ASCON-x1 permutation state.

Parameters
destThe destination to copy to after unmasking it.
srcThe source to copy from.

The dest must be released and freed before this operation as it will be initialized by the process.

Definition at line 152 of file ascon-masked-state.c.

◆ ascon_x3_randomize()

void ascon_x3_randomize ( ascon_masked_state_t state,
ascon_trng_state_t trng 
)

Randomizes an ASCON-x3 permutation state.

Parameters
stateThe ASCON-x3 state to be randomized.
trngTRNG to use to randomize the state.

The state will still have the same effective value, but this function will mix in fresh randomness to all words.

Definition at line 124 of file ascon-masked-state.c.

◆ ascon_x4_copy_from_x1()

void ascon_x4_copy_from_x1 ( ascon_masked_state_t dest,
const ascon_state_t src,
ascon_trng_state_t trng 
)

Copies the entire ASCON-x4 permutation state from a regular ASCON-x1 permutation state.

Parameters
destThe destination to copy to.
srcThe source to copy from.
trngTRNG to use to mask the original ASCON-x1 state.

Definition at line 215 of file ascon-masked-state.c.

◆ ascon_x4_copy_from_x2()

void ascon_x4_copy_from_x2 ( ascon_masked_state_t dest,
const ascon_masked_state_t src,
ascon_trng_state_t trng 
)

Copies the entire ASCON-x4 permutation state from an ASCON-x2 permutation state.

Parameters
destThe destination to copy to.
srcThe source to copy from.
trngTRNG to use to randomize the output state.

Definition at line 251 of file ascon-masked-state.c.

◆ ascon_x4_copy_from_x3()

void ascon_x4_copy_from_x3 ( ascon_masked_state_t dest,
const ascon_masked_state_t src,
ascon_trng_state_t trng 
)

Copies the entire ASCON-x4 permutation state from an ASCON-x3 permutation state.

Parameters
destThe destination to copy to.
srcThe source to copy from.
trngTRNG to use to randomize the output state.

Definition at line 260 of file ascon-masked-state.c.

◆ ascon_x4_copy_from_x4()

void ascon_x4_copy_from_x4 ( ascon_masked_state_t dest,
const ascon_masked_state_t src,
ascon_trng_state_t trng 
)

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

Parameters
destThe destination to copy to.
srcThe source to copy from.
trngTRNG to use to re-randomize the source state.

Definition at line 269 of file ascon-masked-state.c.

◆ ascon_x4_copy_to_x1()

void ascon_x4_copy_to_x1 ( ascon_state_t dest,
const ascon_masked_state_t src 
)

Copies the entire ASCON-x4 permutation state to a regular ASCON-x1 permutation state.

Parameters
destThe destination to copy to after unmasking it.
srcThe source to copy from.

The dest must be released and freed before this operation as it will be initialized by the process.

Definition at line 234 of file ascon-masked-state.c.

◆ ascon_x4_randomize()

void ascon_x4_randomize ( ascon_masked_state_t state,
ascon_trng_state_t trng 
)

Randomizes an ASCON-x4 permutation state.

Parameters
stateThe ASCON-x4 state to be randomized.
trngTRNG to use to randomize the state.

The state will still have the same effective value, but this function will mix in fresh randomness to all words.

Definition at line 206 of file ascon-masked-state.c.