ASCON Suite
Classes | Macros | Functions
ascon-masked-word.h File Reference

Utility functions for operating on masked words. More...

#include <ascon/masking.h>
#include "ascon-masked-backend.h"
#include "random/ascon-trng.h"
#include "core/ascon-util.h"

Go to the source code of this file.

Classes

union  ascon_masked_word_t
 Masked 64-bit word with up to ASCON_MASKED_MAX_SHARES shares. More...
 

Macros

#define ascon_mask64_rotate_share1_0(x)   (rightRotate11_64((x)))
 Rotates 64-bit masked share 1 with respect to share 0. More...
 
#define ascon_mask64_rotate_share2_0(x)   (rightRotate22_64((x)))
 Rotates 64-bit masked share 2 with respect to share 0. More...
 
#define ascon_mask64_rotate_share2_1(x)   (rightRotate11_64((x)))
 Rotates 64-bit masked share 2 with respect to share 1. More...
 
#define ascon_mask64_rotate_share3_0(x)   (rightRotate33_64((x)))
 Rotates 64-bit masked share 3 with respect to share 0. More...
 
#define ascon_mask64_rotate_share3_1(x)   (rightRotate22_64((x)))
 Rotates 64-bit masked share 3 with respect to share 1. More...
 
#define ascon_mask64_rotate_share3_2(x)   (rightRotate11_64((x)))
 Rotates 64-bit masked share 3 with respect to share 2. More...
 
#define ascon_mask64_unrotate_share1_0(x)   (rightRotate53_64((x)))
 Unrotates 64-bit masked share 1 with respect to share 0. More...
 
#define ascon_mask64_unrotate_share2_0(x)   (rightRotate42_64((x)))
 Unrotates 64-bit masked share 2 with respect to share 0. More...
 
#define ascon_mask64_unrotate_share2_1(x)   (rightRotate53_64((x)))
 Unrotates 64-bit masked share 2 with respect to share 1. More...
 
#define ascon_mask64_unrotate_share3_0(x)   (rightRotate31_64((x)))
 Unrotates 64-bit masked share 3 with respect to share 0. More...
 
#define ascon_mask64_unrotate_share3_1(x)   (rightRotate42_64((x)))
 Unrotates 64-bit masked share 3 with respect to share 1. More...
 
#define ascon_mask64_unrotate_share3_2(x)   (rightRotate53_64((x)))
 Unrotates 64-bit masked share 3 with respect to share 2. More...
 
#define ascon_mask32_rotate_share1_0(x)   (rightRotate5((x)))
 Rotates 32-bit masked share 1 with respect to share 0. More...
 
#define ascon_mask32_rotate_share2_0(x)   (rightRotate10((x)))
 Rotates 32-bit masked share 2 with respect to share 0. More...
 
#define ascon_mask32_rotate_share2_1(x)   (rightRotate5((x)))
 Rotates 32-bit masked share 2 with respect to share 1. More...
 
#define ascon_mask32_rotate_share3_0(x)   (rightRotate15((x)))
 Rotates 32-bit masked share 3 with respect to share 0. More...
 
#define ascon_mask32_rotate_share3_1(x)   (rightRotate10((x)))
 Rotates 32-bit masked share 3 with respect to share 1. More...
 
#define ascon_mask32_rotate_share3_2(x)   (rightRotate5((x)))
 Rotates 32-bit masked share 3 with respect to share 2. More...
 
#define ascon_mask32_unrotate_share1_0(x)   (rightRotate27((x)))
 Unrotates 32-bit masked share 1 with respect to share 0. More...
 
#define ascon_mask32_unrotate_share2_0(x)   (rightRotate22((x)))
 Unrotates 32-bit masked share 2 with respect to share 0. More...
 
#define ascon_mask32_unrotate_share2_1(x)   (rightRotate27((x)))
 Unrotates 32-bit masked share 2 with respect to share 1. More...
 
#define ascon_mask32_unrotate_share3_0(x)   (rightRotate17((x)))
 Unrotates 32-bit masked share 3 with respect to share 0. More...
 
#define ascon_mask32_unrotate_share3_1(x)   (rightRotate22((x)))
 Unrotates 32-bit masked share 3 with respect to share 1. More...
 
#define ascon_mask32_unrotate_share3_2(x)   (rightRotate27((x)))
 Unrotates 32-bit masked share 3 with respect to share 2. More...
 

Functions

void ascon_masked_word_x2_zero (ascon_masked_word_t *word, ascon_trng_state_t *trng)
 Sets a x2 masked word to zero. More...
 
void ascon_masked_word_x2_load (ascon_masked_word_t *word, const uint8_t *data, ascon_trng_state_t *trng)
 Loads a 64-bit big endian value from buffer, masks it, and writes it to a x2 masked word structure. More...
 
void ascon_masked_word_x2_load_partial (ascon_masked_word_t *word, const uint8_t *data, unsigned size, ascon_trng_state_t *trng)
 Loads a 8-bit to 56-bit big endian value from buffer, masks it, and writes it to a x2 masked word structure. More...
 
void ascon_masked_word_x2_load_32 (ascon_masked_word_t *word, const uint8_t *data1, const uint8_t *data2, ascon_trng_state_t *trng)
 Loads two 32-bit big endian values from buffers, masks them, and writes the result to a x2 masked word structure. More...
 
void ascon_masked_word_x2_store (uint8_t *data, const ascon_masked_word_t *word)
 Unmasks and stores the contents of a x2 masked word structure. More...
 
void ascon_masked_word_x2_store_partial (uint8_t *data, unsigned size, const ascon_masked_word_t *word)
 Unmasks and stores the contents of a x2 masked word structure to a partial buffer. More...
 
void ascon_masked_word_x2_randomize (ascon_masked_word_t *dest, const ascon_masked_word_t *src, ascon_trng_state_t *trng)
 Randomizes a x2 masked word by incorporating fresh randomness. More...
 
void ascon_masked_word_x2_xor (ascon_masked_word_t *dest, const ascon_masked_word_t *src)
 XOR's a source x2 masked word against a destination x2 masked word. More...
 
void ascon_masked_word_x2_replace (ascon_masked_word_t *dest, const ascon_masked_word_t *src, unsigned size)
 Replace part of a destination x2 masked word with part of a source. More...
 
void ascon_masked_word_x2_from_x3 (ascon_masked_word_t *dest, const ascon_masked_word_t *src, ascon_trng_state_t *trng)
 Converts a x3 masked word into a x2 masked word. More...
 
void ascon_masked_word_x2_from_x4 (ascon_masked_word_t *dest, const ascon_masked_word_t *src, ascon_trng_state_t *trng)
 Converts a x4 masked word into a x2 masked word. More...
 
void ascon_masked_word_x3_zero (ascon_masked_word_t *word, ascon_trng_state_t *trng)
 Sets a x3 masked word to zero. More...
 
void ascon_masked_word_x3_load (ascon_masked_word_t *word, const uint8_t *data, ascon_trng_state_t *trng)
 Loads a 64-bit big endian value from buffer, masks it, and writes it to a x3 masked word structure. More...
 
void ascon_masked_word_x3_load_partial (ascon_masked_word_t *word, const uint8_t *data, unsigned size, ascon_trng_state_t *trng)
 Loads a 8-bit to 56-bit big endian value from buffer, masks it, and writes it to a x3 masked word structure. More...
 
void ascon_masked_word_x3_load_32 (ascon_masked_word_t *word, const uint8_t *data1, const uint8_t *data2, ascon_trng_state_t *trng)
 Loads two 32-bit big endian values from buffers, masks them, and writes the result to a x3 masked word structure. More...
 
void ascon_masked_word_x3_store (uint8_t *data, const ascon_masked_word_t *word)
 Unmasks and stores the contents of a x3 masked word structure. More...
 
void ascon_masked_word_x3_store_partial (uint8_t *data, unsigned size, const ascon_masked_word_t *word)
 Unmasks and stores the contents of a x3 masked word structure to a partial buffer. More...
 
void ascon_masked_word_x3_randomize (ascon_masked_word_t *dest, const ascon_masked_word_t *src, ascon_trng_state_t *trng)
 Randomizes a x3 masked word by incorporating fresh randomness. More...
 
void ascon_masked_word_x3_xor (ascon_masked_word_t *dest, const ascon_masked_word_t *src)
 XOR's a source x3 masked word against a destination x3 masked word. More...
 
void ascon_masked_word_x3_replace (ascon_masked_word_t *dest, const ascon_masked_word_t *src, unsigned size)
 Replace part of a destination x3 masked word with part of a source. More...
 
void ascon_masked_word_x3_from_x2 (ascon_masked_word_t *dest, const ascon_masked_word_t *src, ascon_trng_state_t *trng)
 Converts a x2 masked word into a x3 masked word. More...
 
void ascon_masked_word_x3_from_x4 (ascon_masked_word_t *dest, const ascon_masked_word_t *src, ascon_trng_state_t *trng)
 Converts a x4 masked word into a x3 masked word. More...
 
void ascon_masked_word_x4_zero (ascon_masked_word_t *word, ascon_trng_state_t *trng)
 Sets a x4 masked word to zero. More...
 
void ascon_masked_word_x4_load (ascon_masked_word_t *word, const uint8_t *data, ascon_trng_state_t *trng)
 Loads a 64-bit big endian value from buffer, masks it, and writes it to a x4 masked word structure. More...
 
void ascon_masked_word_x4_load_partial (ascon_masked_word_t *word, const uint8_t *data, unsigned size, ascon_trng_state_t *trng)
 Loads a 8-bit to 56-bit big endian value from buffer, masks it, and writes it to a x4 masked word structure. More...
 
void ascon_masked_word_x4_load_32 (ascon_masked_word_t *word, const uint8_t *data1, const uint8_t *data2, ascon_trng_state_t *trng)
 Loads two 32-bit big endian values from buffers, masks them, and writes the result to a x4 masked word structure. More...
 
void ascon_masked_word_x4_store (uint8_t *data, const ascon_masked_word_t *word)
 Unmasks and stores the contents of a x4 masked word structure. More...
 
void ascon_masked_word_x4_store_partial (uint8_t *data, unsigned size, const ascon_masked_word_t *word)
 Unmasks and stores the contents of a x4 masked word structure to a partial buffer. More...
 
void ascon_masked_word_x4_randomize (ascon_masked_word_t *dest, const ascon_masked_word_t *src, ascon_trng_state_t *trng)
 Randomizes a x4 masked word by incorporating fresh randomness. More...
 
void ascon_masked_word_x4_xor (ascon_masked_word_t *dest, const ascon_masked_word_t *src)
 XOR's a source x4 masked word against a destination x4 masked word. More...
 
void ascon_masked_word_x4_replace (ascon_masked_word_t *dest, const ascon_masked_word_t *src, unsigned size)
 Replace part of a destination x4 masked word with part of a source. More...
 
void ascon_masked_word_x4_from_x2 (ascon_masked_word_t *dest, const ascon_masked_word_t *src, ascon_trng_state_t *trng)
 Converts a x2 masked word into a x4 masked word. More...
 
void ascon_masked_word_x4_from_x3 (ascon_masked_word_t *dest, const ascon_masked_word_t *src, ascon_trng_state_t *trng)
 Converts a x3 masked word into a x4 masked word. More...
 
void ascon_masked_word_pad (ascon_masked_word_t *word, unsigned offset)
 Adds a padding marker to a masked word. More...
 
void ascon_masked_word_separator (ascon_masked_word_t *word)
 Adds a separator marker to a masked word. More...
 

Detailed Description

Utility functions for operating on masked words.

Masked words may be stored in two different representations depending upon the backend.

The 64-bit masked word representation stores the 4 shares as regular 64-bit words. The shares are stored in a rotated form where shares 1, 2, 3, and 4 are rotated right by 0, 11, 22, and 33 bits respectively. The "real" value of a 64-bit masked word can be recovered as follows:

* value = share1 ^ (share2 <<< 11) ^ (share3 <<< 22) ^ (share <<< 33)
* 

The 32-bit masked representation splits each of the 64-bit words into two bit-sliced halves. The even bits are in one half and the odd bits are in the other half. This can be more efficient on 32-bit platforms that lack a funnel shift instruction.

The shares of a 32-bit masked word are stored in a rotated form where shares 1, 2, 3, and 4 are rotated right by 0, 5, 10, and 15 bits respectively.

Definition in file ascon-masked-word.h.

Macro Definition Documentation

◆ ascon_mask32_rotate_share1_0

#define ascon_mask32_rotate_share1_0 (   x)    (rightRotate5((x)))

Rotates 32-bit masked share 1 with respect to share 0.

Parameters
xValue of share 1 in the same bit positions as share 0.
Returns
Value of share 1 after rotation with respect to share 0.

Definition at line 196 of file ascon-masked-word.h.

◆ ascon_mask32_rotate_share2_0

#define ascon_mask32_rotate_share2_0 (   x)    (rightRotate10((x)))

Rotates 32-bit masked share 2 with respect to share 0.

Parameters
xValue of share 2 in the same bit positions as share 0.
Returns
Value of share 2 after rotation with respect to share 0.

Definition at line 205 of file ascon-masked-word.h.

◆ ascon_mask32_rotate_share2_1

#define ascon_mask32_rotate_share2_1 (   x)    (rightRotate5((x)))

Rotates 32-bit masked share 2 with respect to share 1.

Parameters
xValue of share 2 in the same bit positions as share 1.
Returns
Value of share 2 after rotation with respect to share 1.

Definition at line 214 of file ascon-masked-word.h.

◆ ascon_mask32_rotate_share3_0

#define ascon_mask32_rotate_share3_0 (   x)    (rightRotate15((x)))

Rotates 32-bit masked share 3 with respect to share 0.

Parameters
xValue of share 3 in the same bit positions as share 0.
Returns
Value of share 3 after rotation with respect to share 0.

Definition at line 223 of file ascon-masked-word.h.

◆ ascon_mask32_rotate_share3_1

#define ascon_mask32_rotate_share3_1 (   x)    (rightRotate10((x)))

Rotates 32-bit masked share 3 with respect to share 1.

Parameters
xValue of share 3 in the same bit positions as share 1.
Returns
Value of share 3 after rotation with respect to share 1.

Definition at line 232 of file ascon-masked-word.h.

◆ ascon_mask32_rotate_share3_2

#define ascon_mask32_rotate_share3_2 (   x)    (rightRotate5((x)))

Rotates 32-bit masked share 3 with respect to share 2.

Parameters
xValue of share 3 in the same bit positions as share 2.
Returns
Value of share 3 after rotation with respect to share 2.

Definition at line 241 of file ascon-masked-word.h.

◆ ascon_mask32_unrotate_share1_0

#define ascon_mask32_unrotate_share1_0 (   x)    (rightRotate27((x)))

Unrotates 32-bit masked share 1 with respect to share 0.

Parameters
xValue of share 1, rotated with respect to share 0.
Returns
Value of share 1 in the same bit positions as share 0.

Definition at line 250 of file ascon-masked-word.h.

◆ ascon_mask32_unrotate_share2_0

#define ascon_mask32_unrotate_share2_0 (   x)    (rightRotate22((x)))

Unrotates 32-bit masked share 2 with respect to share 0.

Parameters
xValue of share 2, rotated with respect to share 0.
Returns
Value of share 2 in the same bit positions as share 0.

Definition at line 259 of file ascon-masked-word.h.

◆ ascon_mask32_unrotate_share2_1

#define ascon_mask32_unrotate_share2_1 (   x)    (rightRotate27((x)))

Unrotates 32-bit masked share 2 with respect to share 1.

Parameters
xValue of share 2, rotated with respect to share 1.
Returns
Value of share 2 in the same bit positions as share 1.

Definition at line 268 of file ascon-masked-word.h.

◆ ascon_mask32_unrotate_share3_0

#define ascon_mask32_unrotate_share3_0 (   x)    (rightRotate17((x)))

Unrotates 32-bit masked share 3 with respect to share 0.

Parameters
xValue of share 3, rotated with respect to share 0.
Returns
Value of share 3 in the same bit positions as share 0.

Definition at line 277 of file ascon-masked-word.h.

◆ ascon_mask32_unrotate_share3_1

#define ascon_mask32_unrotate_share3_1 (   x)    (rightRotate22((x)))

Unrotates 32-bit masked share 3 with respect to share 1.

Parameters
xValue of share 3, rotated with respect to share 1.
Returns
Value of share 3 in the same bit positions as share 1.

Definition at line 286 of file ascon-masked-word.h.

◆ ascon_mask32_unrotate_share3_2

#define ascon_mask32_unrotate_share3_2 (   x)    (rightRotate27((x)))

Unrotates 32-bit masked share 3 with respect to share 2.

Parameters
xValue of share 3, rotated with respect to share 2.
Returns
Value of share 3 in the same bit positions as share 2.

Definition at line 295 of file ascon-masked-word.h.

◆ ascon_mask64_rotate_share1_0

#define ascon_mask64_rotate_share1_0 (   x)    (rightRotate11_64((x)))

Rotates 64-bit masked share 1 with respect to share 0.

Parameters
xValue of share 1 in the same bit positions as share 0.
Returns
Value of share 1 after rotation with respect to share 0.

Definition at line 88 of file ascon-masked-word.h.

◆ ascon_mask64_rotate_share2_0

#define ascon_mask64_rotate_share2_0 (   x)    (rightRotate22_64((x)))

Rotates 64-bit masked share 2 with respect to share 0.

Parameters
xValue of share 2 in the same bit positions as share 0.
Returns
Value of share 2 after rotation with respect to share 0.

Definition at line 97 of file ascon-masked-word.h.

◆ ascon_mask64_rotate_share2_1

#define ascon_mask64_rotate_share2_1 (   x)    (rightRotate11_64((x)))

Rotates 64-bit masked share 2 with respect to share 1.

Parameters
xValue of share 2 in the same bit positions as share 1.
Returns
Value of share 2 after rotation with respect to share 1.

Definition at line 106 of file ascon-masked-word.h.

◆ ascon_mask64_rotate_share3_0

#define ascon_mask64_rotate_share3_0 (   x)    (rightRotate33_64((x)))

Rotates 64-bit masked share 3 with respect to share 0.

Parameters
xValue of share 3 in the same bit positions as share 0.
Returns
Value of share 3 after rotation with respect to share 0.

Definition at line 115 of file ascon-masked-word.h.

◆ ascon_mask64_rotate_share3_1

#define ascon_mask64_rotate_share3_1 (   x)    (rightRotate22_64((x)))

Rotates 64-bit masked share 3 with respect to share 1.

Parameters
xValue of share 3 in the same bit positions as share 1.
Returns
Value of share 3 after rotation with respect to share 1.

Definition at line 124 of file ascon-masked-word.h.

◆ ascon_mask64_rotate_share3_2

#define ascon_mask64_rotate_share3_2 (   x)    (rightRotate11_64((x)))

Rotates 64-bit masked share 3 with respect to share 2.

Parameters
xValue of share 3 in the same bit positions as share 2.
Returns
Value of share 3 after rotation with respect to share 2.

Definition at line 133 of file ascon-masked-word.h.

◆ ascon_mask64_unrotate_share1_0

#define ascon_mask64_unrotate_share1_0 (   x)    (rightRotate53_64((x)))

Unrotates 64-bit masked share 1 with respect to share 0.

Parameters
xValue of share 1, rotated with respect to share 0.
Returns
Value of share 1 in the same bit positions as share 0.

Definition at line 142 of file ascon-masked-word.h.

◆ ascon_mask64_unrotate_share2_0

#define ascon_mask64_unrotate_share2_0 (   x)    (rightRotate42_64((x)))

Unrotates 64-bit masked share 2 with respect to share 0.

Parameters
xValue of share 2, rotated with respect to share 0.
Returns
Value of share 2 in the same bit positions as share 0.

Definition at line 151 of file ascon-masked-word.h.

◆ ascon_mask64_unrotate_share2_1

#define ascon_mask64_unrotate_share2_1 (   x)    (rightRotate53_64((x)))

Unrotates 64-bit masked share 2 with respect to share 1.

Parameters
xValue of share 2, rotated with respect to share 1.
Returns
Value of share 2 in the same bit positions as share 1.

Definition at line 160 of file ascon-masked-word.h.

◆ ascon_mask64_unrotate_share3_0

#define ascon_mask64_unrotate_share3_0 (   x)    (rightRotate31_64((x)))

Unrotates 64-bit masked share 3 with respect to share 0.

Parameters
xValue of share 3, rotated with respect to share 0.
Returns
Value of share 3 in the same bit positions as share 0.

Definition at line 169 of file ascon-masked-word.h.

◆ ascon_mask64_unrotate_share3_1

#define ascon_mask64_unrotate_share3_1 (   x)    (rightRotate42_64((x)))

Unrotates 64-bit masked share 3 with respect to share 1.

Parameters
xValue of share 3, rotated with respect to share 1.
Returns
Value of share 3 in the same bit positions as share 1.

Definition at line 178 of file ascon-masked-word.h.

◆ ascon_mask64_unrotate_share3_2

#define ascon_mask64_unrotate_share3_2 (   x)    (rightRotate53_64((x)))

Unrotates 64-bit masked share 3 with respect to share 2.

Parameters
xValue of share 3, rotated with respect to share 2.
Returns
Value of share 3 in the same bit positions as share 2.

Definition at line 187 of file ascon-masked-word.h.

Function Documentation

◆ ascon_masked_word_pad()

void ascon_masked_word_pad ( ascon_masked_word_t word,
unsigned  offset 
)

Adds a padding marker to a masked word.

Parameters
wordThe masked word to be padded.
offsetOffset of the padding marker (0 to 7).

Definition at line 563 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_separator()

void ascon_masked_word_separator ( ascon_masked_word_t word)

Adds a separator marker to a masked word.

Parameters
wordThe masked word to add the separator marker to.

Definition at line 568 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x2_from_x3()

void ascon_masked_word_x2_from_x3 ( ascon_masked_word_t dest,
const ascon_masked_word_t src,
ascon_trng_state_t trng 
)

Converts a x3 masked word into a x2 masked word.

Parameters
destThe destination x2 masked word.
srcThe source x3 masked word. May be the same as dest.
trngTRNG to use to randomize the state.

Definition at line 170 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x2_from_x4()

void ascon_masked_word_x2_from_x4 ( ascon_masked_word_t dest,
const ascon_masked_word_t src,
ascon_trng_state_t trng 
)

Converts a x4 masked word into a x2 masked word.

Parameters
destThe destination x2 masked word.
srcThe source x4 masked word. May be the same as dest.
trngTRNG to use to randomize the state.

Definition at line 188 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x2_load()

void ascon_masked_word_x2_load ( ascon_masked_word_t word,
const uint8_t *  data,
ascon_trng_state_t trng 
)

Loads a 64-bit big endian value from buffer, masks it, and writes it to a x2 masked word structure.

Parameters
wordThe x2 masked word to write to.
dataPoints to the 64 bits of data to be loaded.
trngTRNG to use to generate masking material.
See also
ascon_masked_word_x2_store()

Definition at line 44 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x2_load_32()

void ascon_masked_word_x2_load_32 ( ascon_masked_word_t word,
const uint8_t *  data1,
const uint8_t *  data2,
ascon_trng_state_t trng 
)

Loads two 32-bit big endian values from buffers, masks them, and writes the result to a x2 masked word structure.

Parameters
wordThe x2 masked word to write to.
data1Points to the high 32 bits of data to be loaded.
data2Points to the low 32 bits of data to be loaded.
trngTRNG to use to generate masking material.

Normally ascon_masked_word_x2_load() should be used instead of this, but ASCON-80pq mixes IV and key data in the same 64-bit word.

Definition at line 93 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x2_load_partial()

void ascon_masked_word_x2_load_partial ( ascon_masked_word_t word,
const uint8_t *  data,
unsigned  size,
ascon_trng_state_t trng 
)

Loads a 8-bit to 56-bit big endian value from buffer, masks it, and writes it to a x2 masked word structure.

Parameters
wordThe x2 masked word to write to.
dataPoints to the data to be loaded.
sizeNumber of bytes to load between 1 and 7.
trngTRNG to use to generate masking material.

Definition at line 59 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x2_randomize()

void ascon_masked_word_x2_randomize ( ascon_masked_word_t dest,
const ascon_masked_word_t src,
ascon_trng_state_t trng 
)

Randomizes a x2 masked word by incorporating fresh randomness.

Parameters
destPoints to the destination for the randomized version.
srcPoints to the source to randomize, can be the same as dest.
trngTRNG to use to randomize the state.

The word will still have the same effective value, but this function will mix in fresh randomness.

Definition at line 142 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x2_replace()

void ascon_masked_word_x2_replace ( ascon_masked_word_t dest,
const ascon_masked_word_t src,
unsigned  size 
)

Replace part of a destination x2 masked word with part of a source.

Parameters
destDestination masked word.
srcSource masked word.
sizeNumber of bytes from the top of the masked word to copy.

Definition at line 158 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x2_store()

void ascon_masked_word_x2_store ( uint8_t *  data,
const ascon_masked_word_t word 
)

Unmasks and stores the contents of a x2 masked word structure.

Parameters
dataPoints to the buffer to receive the 64 bits of unmasked data.
wordThe x2 masked word to read from.
See also
ascon_masked_word_x2_load()

Definition at line 109 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x2_store_partial()

void ascon_masked_word_x2_store_partial ( uint8_t *  data,
unsigned  size,
const ascon_masked_word_t word 
)

Unmasks and stores the contents of a x2 masked word structure to a partial buffer.

Parameters
dataPoints to the buffer to receive the unmasked data.
sizeNumber of bytes to unmask.
wordThe x2 masked word to read from.
See also
ascon_masked_word_x2_load()

Definition at line 116 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x2_xor()

void ascon_masked_word_x2_xor ( ascon_masked_word_t dest,
const ascon_masked_word_t src 
)

XOR's a source x2 masked word against a destination x2 masked word.

Parameters
destThe destination masked word.
srcThe source masked word.

Definition at line 151 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x2_zero()

void ascon_masked_word_x2_zero ( ascon_masked_word_t word,
ascon_trng_state_t trng 
)

Sets a x2 masked word to zero.

Parameters
wordThe x2 masked word to set to zero.
trngTRNG to use to generate masking material.

Definition at line 30 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x3_from_x2()

void ascon_masked_word_x3_from_x2 ( ascon_masked_word_t dest,
const ascon_masked_word_t src,
ascon_trng_state_t trng 
)

Converts a x2 masked word into a x3 masked word.

Parameters
destThe destination x3 masked word.
srcThe source x2 masked word. May be the same as dest.
trngTRNG to use to randomize the state.

Definition at line 350 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x3_from_x4()

void ascon_masked_word_x3_from_x4 ( ascon_masked_word_t dest,
const ascon_masked_word_t src,
ascon_trng_state_t trng 
)

Converts a x4 masked word into a x3 masked word.

Parameters
destThe destination x3 masked word.
srcThe source x4 masked word. May be the same as dest.
trngTRNG to use to randomize the state.

Definition at line 366 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x3_load()

void ascon_masked_word_x3_load ( ascon_masked_word_t word,
const uint8_t *  data,
ascon_trng_state_t trng 
)

Loads a 64-bit big endian value from buffer, masks it, and writes it to a x3 masked word structure.

Parameters
wordThe x3 masked word to write to.
dataPoints to the 64 bits of data to be loaded.
trngTRNG to use to generate masking material.
See also
ascon_masked_word_x3_store()

Definition at line 219 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x3_load_32()

void ascon_masked_word_x3_load_32 ( ascon_masked_word_t word,
const uint8_t *  data1,
const uint8_t *  data2,
ascon_trng_state_t trng 
)

Loads two 32-bit big endian values from buffers, masks them, and writes the result to a x3 masked word structure.

Parameters
wordThe x3 masked word to write to.
data1Points to the high 32 bits of data to be loaded.
data2Points to the low 32 bits of data to be loaded.
trngTRNG to use to generate masking material.

Normally ascon_masked_word_x3_load() should be used instead of this, but ASCON-80pq mixes IV and key data in the same 64-bit word.

Definition at line 266 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x3_load_partial()

void ascon_masked_word_x3_load_partial ( ascon_masked_word_t word,
const uint8_t *  data,
unsigned  size,
ascon_trng_state_t trng 
)

Loads a 8-bit to 56-bit big endian value from buffer, masks it, and writes it to a x3 masked word structure.

Parameters
wordThe x3 masked word to write to.
dataPoints to the data to be loaded.
sizeNumber of bytes to load between 1 and 7.
trngTRNG to use to generate masking material.

Definition at line 233 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x3_randomize()

void ascon_masked_word_x3_randomize ( ascon_masked_word_t dest,
const ascon_masked_word_t src,
ascon_trng_state_t trng 
)

Randomizes a x3 masked word by incorporating fresh randomness.

Parameters
destPoints to the destination for the randomized version.
srcPoints to the source to randomize, can be the same as dest.
trngTRNG to use to randomize the state.

The word will still have the same effective value, but this function will mix in fresh randomness.

Definition at line 319 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x3_replace()

void ascon_masked_word_x3_replace ( ascon_masked_word_t dest,
const ascon_masked_word_t src,
unsigned  size 
)

Replace part of a destination x3 masked word with part of a source.

Parameters
destDestination masked word.
srcSource masked word.
sizeNumber of bytes from the top of the masked word to copy.

Definition at line 338 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x3_store()

void ascon_masked_word_x3_store ( uint8_t *  data,
const ascon_masked_word_t word 
)

Unmasks and stores the contents of a x3 masked word structure.

Parameters
dataPoints to the buffer to receive the 64 bits of unmasked data.
wordThe x3 masked word to read from.
See also
ascon_masked_word_x3_load()

Definition at line 281 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x3_store_partial()

void ascon_masked_word_x3_store_partial ( uint8_t *  data,
unsigned  size,
const ascon_masked_word_t word 
)

Unmasks and stores the contents of a x3 masked word structure to a partial buffer.

Parameters
dataPoints to the buffer to receive the unmasked data.
sizeNumber of bytes to unmask.
wordThe x3 masked word to read from.
See also
ascon_masked_word_x3_load()

Definition at line 289 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x3_xor()

void ascon_masked_word_x3_xor ( ascon_masked_word_t dest,
const ascon_masked_word_t src 
)

XOR's a source x3 masked word against a destination x3 masked word.

Parameters
destThe destination masked word.
srcThe source masked word.

Definition at line 330 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x3_zero()

void ascon_masked_word_x3_zero ( ascon_masked_word_t word,
ascon_trng_state_t trng 
)

Sets a x3 masked word to zero.

Parameters
wordThe x3 masked word to set to zero.
trngTRNG to use to generate masking material.

Definition at line 205 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x4_from_x2()

void ascon_masked_word_x4_from_x2 ( ascon_masked_word_t dest,
const ascon_masked_word_t src,
ascon_trng_state_t trng 
)

Converts a x2 masked word into a x4 masked word.

Parameters
destThe destination x4 masked word.
srcThe source x2 masked word. May be the same as dest.
trngTRNG to use to randomize the state.

Definition at line 535 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x4_from_x3()

void ascon_masked_word_x4_from_x3 ( ascon_masked_word_t dest,
const ascon_masked_word_t src,
ascon_trng_state_t trng 
)

Converts a x3 masked word into a x4 masked word.

Parameters
destThe destination x4 masked word.
srcThe source x3 masked word. May be the same as dest.
trngTRNG to use to randomize the state.

Definition at line 548 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x4_load()

void ascon_masked_word_x4_load ( ascon_masked_word_t word,
const uint8_t *  data,
ascon_trng_state_t trng 
)

Loads a 64-bit big endian value from buffer, masks it, and writes it to a x4 masked word structure.

Parameters
wordThe x4 masked word to write to.
dataPoints to the 64 bits of data to be loaded.
trngTRNG to use to generate masking material.
See also
ascon_masked_word_x4_store()

Definition at line 397 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x4_load_32()

void ascon_masked_word_x4_load_32 ( ascon_masked_word_t word,
const uint8_t *  data1,
const uint8_t *  data2,
ascon_trng_state_t trng 
)

Loads two 32-bit big endian values from buffers, masks them, and writes the result to a x4 masked word structure.

Parameters
wordThe x4 masked word to write to.
data1Points to the high 32 bits of data to be loaded.
data2Points to the low 32 bits of data to be loaded.
trngTRNG to use to generate masking material.

Normally ascon_masked_word_x4_load() should be used instead of this, but ASCON-80pq mixes IV and key data in the same 64-bit word.

Definition at line 442 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x4_load_partial()

void ascon_masked_word_x4_load_partial ( ascon_masked_word_t word,
const uint8_t *  data,
unsigned  size,
ascon_trng_state_t trng 
)

Loads a 8-bit to 56-bit big endian value from buffer, masks it, and writes it to a x4 masked word structure.

Parameters
wordThe x4 masked word to write to.
dataPoints to the data to be loaded.
sizeNumber of bytes to load between 1 and 7.
trngTRNG to use to generate masking material.
See also
ascon_masked_word_x4_store()

Definition at line 410 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x4_randomize()

void ascon_masked_word_x4_randomize ( ascon_masked_word_t dest,
const ascon_masked_word_t src,
ascon_trng_state_t trng 
)

Randomizes a x4 masked word by incorporating fresh randomness.

Parameters
destPoints to the destination for the randomized version.
srcPoints to the source to randomize, can be the same as dest.
trngTRNG to use to randomize the state.

The word will still have the same effective value, but this function will mix in fresh randomness.

Definition at line 499 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x4_replace()

void ascon_masked_word_x4_replace ( ascon_masked_word_t dest,
const ascon_masked_word_t src,
unsigned  size 
)

Replace part of a destination x4 masked word with part of a source.

Parameters
destDestination masked word.
srcSource masked word.
sizeNumber of bytes from the top of the masked word to copy.

Definition at line 521 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x4_store()

void ascon_masked_word_x4_store ( uint8_t *  data,
const ascon_masked_word_t word 
)

Unmasks and stores the contents of a x4 masked word structure.

Parameters
dataPoints to the buffer to receive the 64 bits of unmasked data.
wordThe x4 masked word to read from.
See also
ascon_masked_word_x4_load()

Definition at line 456 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x4_store_partial()

void ascon_masked_word_x4_store_partial ( uint8_t *  data,
unsigned  size,
const ascon_masked_word_t word 
)

Unmasks and stores the contents of a x4 masked word structure to a partial buffer.

Parameters
dataPoints to the buffer to receive the unmasked data.
sizeNumber of bytes to unmask.
wordThe x4 masked word to read from.
See also
ascon_masked_word_x4_load()

Definition at line 465 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x4_xor()

void ascon_masked_word_x4_xor ( ascon_masked_word_t dest,
const ascon_masked_word_t src 
)

XOR's a source x4 masked word against a destination x4 masked word.

Parameters
destThe destination masked word.
srcThe source masked word.

Definition at line 512 of file ascon-masked-word-c64.c.

◆ ascon_masked_word_x4_zero()

void ascon_masked_word_x4_zero ( ascon_masked_word_t word,
ascon_trng_state_t trng 
)

Sets a x4 masked word to zero.

Parameters
wordThe x4 masked word to set to zero.
trngTRNG to use to generate masking material.

Definition at line 385 of file ascon-masked-word-c64.c.