23 #ifndef ASCON_MASKED_WORD_H
24 #define ASCON_MASKED_WORD_H
79 #if !defined(ASCON_MASKED_WORD_BACKEND_DIRECT_XOR)
88 #define ascon_mask64_rotate_share1_0(x) (rightRotate11_64((x)))
97 #define ascon_mask64_rotate_share2_0(x) (rightRotate22_64((x)))
106 #define ascon_mask64_rotate_share2_1(x) (rightRotate11_64((x)))
115 #define ascon_mask64_rotate_share3_0(x) (rightRotate33_64((x)))
124 #define ascon_mask64_rotate_share3_1(x) (rightRotate22_64((x)))
133 #define ascon_mask64_rotate_share3_2(x) (rightRotate11_64((x)))
142 #define ascon_mask64_unrotate_share1_0(x) (rightRotate53_64((x)))
151 #define ascon_mask64_unrotate_share2_0(x) (rightRotate42_64((x)))
160 #define ascon_mask64_unrotate_share2_1(x) (rightRotate53_64((x)))
169 #define ascon_mask64_unrotate_share3_0(x) (rightRotate31_64((x)))
178 #define ascon_mask64_unrotate_share3_1(x) (rightRotate42_64((x)))
187 #define ascon_mask64_unrotate_share3_2(x) (rightRotate53_64((x)))
196 #define ascon_mask32_rotate_share1_0(x) (rightRotate5((x)))
205 #define ascon_mask32_rotate_share2_0(x) (rightRotate10((x)))
214 #define ascon_mask32_rotate_share2_1(x) (rightRotate5((x)))
223 #define ascon_mask32_rotate_share3_0(x) (rightRotate15((x)))
232 #define ascon_mask32_rotate_share3_1(x) (rightRotate10((x)))
241 #define ascon_mask32_rotate_share3_2(x) (rightRotate5((x)))
250 #define ascon_mask32_unrotate_share1_0(x) (rightRotate27((x)))
259 #define ascon_mask32_unrotate_share2_0(x) (rightRotate22((x)))
268 #define ascon_mask32_unrotate_share2_1(x) (rightRotate27((x)))
277 #define ascon_mask32_unrotate_share3_0(x) (rightRotate17((x)))
286 #define ascon_mask32_unrotate_share3_1(x) (rightRotate22((x)))
295 #define ascon_mask32_unrotate_share3_2(x) (rightRotate27((x)))
300 #define ascon_mask64_rotate_share1_0(x) (x)
301 #define ascon_mask64_rotate_share2_0(x) (x)
302 #define ascon_mask64_rotate_share2_1(x) (x)
303 #define ascon_mask64_rotate_share3_0(x) (x)
304 #define ascon_mask64_rotate_share3_1(x) (x)
305 #define ascon_mask64_rotate_share3_2(x) (x)
306 #define ascon_mask64_unrotate_share1_0(x) (x)
307 #define ascon_mask64_unrotate_share2_0(x) (x)
308 #define ascon_mask64_unrotate_share2_1(x) (x)
309 #define ascon_mask64_unrotate_share3_0(x) (x)
310 #define ascon_mask64_unrotate_share3_1(x) (x)
311 #define ascon_mask64_unrotate_share3_2(x) (x)
312 #define ascon_mask32_rotate_share1_0(x) (x)
313 #define ascon_mask32_rotate_share2_0(x) (x)
314 #define ascon_mask32_rotate_share2_1(x) (x)
315 #define ascon_mask32_rotate_share3_0(x) (x)
316 #define ascon_mask32_rotate_share3_1(x) (x)
317 #define ascon_mask32_rotate_share3_2(x) (x)
318 #define ascon_mask32_unrotate_share1_0(x) (x)
319 #define ascon_mask32_unrotate_share2_0(x) (x)
320 #define ascon_mask32_unrotate_share2_1(x) (x)
321 #define ascon_mask32_unrotate_share3_0(x) (x)
322 #define ascon_mask32_unrotate_share3_1(x) (x)
323 #define ascon_mask32_unrotate_share3_2(x) (x)
#define ASCON_MASKED_MAX_SHARES
Maximum number of shares to use in the library.
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 wor...
void ascon_masked_word_pad(ascon_masked_word_t *word, unsigned offset)
Adds a padding marker to a masked word.
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.
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.
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.
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.
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.
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.
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.
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.
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.
void ascon_masked_word_x2_zero(ascon_masked_word_t *word, ascon_trng_state_t *trng)
Sets a x2 masked word to zero.
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 str...
void ascon_masked_word_separator(ascon_masked_word_t *word)
Adds a separator marker to a masked word.
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.
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.
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 wor...
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.
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.
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.
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 str...
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.
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 wor...
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.
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.
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.
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 str...
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.
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.
void ascon_masked_word_x4_zero(ascon_masked_word_t *word, ascon_trng_state_t *trng)
Sets a x4 masked word to zero.
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.
void ascon_masked_word_x3_zero(ascon_masked_word_t *word, ascon_trng_state_t *trng)
Sets a x3 masked word to zero.
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.
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.
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.
Access to the system's random number source.
Definitions to support masked ASCON ciphers.
unsigned char data[8]
[snippet_key]
State of the random number source.
Masked 64-bit word with up to ASCON_MASKED_MAX_SHARES shares.