25 #if defined(ASCON_MASKED_WORD_BACKEND_C64)
36 #if ASCON_MASKED_MAX_SHARES >= 3
39 #if ASCON_MASKED_MAX_SHARES >= 4
51 #if ASCON_MASKED_MAX_SHARES >= 3
54 #if ASCON_MASKED_MAX_SHARES >= 4
64 uint64_t masked = random;
85 #if ASCON_MASKED_MAX_SHARES >= 3
88 #if ASCON_MASKED_MAX_SHARES >= 4
101 #if ASCON_MASKED_MAX_SHARES >= 3
104 #if ASCON_MASKED_MAX_SHARES >= 4
119 uint64_t masked1 = word->
S[0];
138 data[0] = (uint8_t)(masked1 ^ masked2);
147 dest->
S[0] = src->
S[0] ^ random;
154 dest->
S[0] ^= src->
S[0];
155 dest->
S[1] ^= src->
S[1];
161 uint64_t mask1 = (~((uint64_t)0)) >> (size * 8U);
162 uint64_t mask2 = ~mask1;
163 dest->
S[0] = (dest->
S[0] & mask1) | (src->
S[0] & mask2);
168 #if ASCON_MASKED_MAX_SHARES >= 3
175 dest->
S[0] = random ^ src->
S[0];
179 #if ASCON_MASKED_MAX_SHARES >= 4
186 #if ASCON_MASKED_MAX_SHARES >= 4
193 dest->
S[0] = (random ^ src->
S[0]) ^
203 #if ASCON_MASKED_MAX_SHARES >= 3
210 word->
S[0] = random1 ^ random2;
214 #if ASCON_MASKED_MAX_SHARES >= 4
228 #if ASCON_MASKED_MAX_SHARES >= 4
239 uint64_t masked = random1;
258 word->
S[0] = masked ^ random2;
259 word->
S[1] = random1;
261 #if ASCON_MASKED_MAX_SHARES >= 4
276 #if ASCON_MASKED_MAX_SHARES >= 4
292 uint64_t masked1 = word->
S[0];
315 data[0] = (uint8_t)(masked1 ^ masked2 ^ masked3);
325 dest->
S[0] = src->
S[0] ^ random1 ^ random2;
333 dest->
S[0] ^= src->
S[0];
334 dest->
S[1] ^= src->
S[1];
335 dest->
S[2] ^= src->
S[2];
341 uint64_t mask1 = (~((uint64_t)0)) >> (size * 8U);
342 uint64_t mask2 = ~mask1;
343 dest->
S[0] = (dest->
S[0] & mask1) | (src->
S[0] & mask2);
356 dest->
S[0] = random1 ^ random2 ^ src->
S[0];
359 #if ASCON_MASKED_MAX_SHARES >= 4
364 #if ASCON_MASKED_MAX_SHARES >= 4
372 dest->
S[0] = (random1 ^ random2 ^ src->
S[0]) ^
383 #if ASCON_MASKED_MAX_SHARES >= 4
391 word->
S[0] = random1 ^ random2 ^ random3;
417 uint64_t masked = random1;
436 word->
S[0] = masked ^ random2 ^ random3;
437 word->
S[1] = random1;
449 word->
S[0] = random1 ^ random2 ^ ((uint64_t)
be_load_word32(data1)) << 32;
468 uint64_t masked1 = word->
S[0];
495 data[0] = (uint8_t)(masked1 ^ masked2 ^ masked3 ^ masked4);
506 dest->
S[0] = src->
S[0] ^ random1 ^ random2 ^ random3;
515 dest->
S[0] ^= src->
S[0];
516 dest->
S[1] ^= src->
S[1];
517 dest->
S[2] ^= src->
S[2];
518 dest->
S[3] ^= src->
S[3];
524 uint64_t mask1 = (~((uint64_t)0)) >> (size * 8U);
525 uint64_t mask2 = ~mask1;
526 dest->
S[0] = (dest->
S[0] & mask1) | (src->
S[0] & mask2);
542 dest->
S[0] = random1 ^ random2 ^ random3 ^ src->
S[0];
555 dest->
S[0] = random1 ^ random2 ^ random3 ^ src->
S[0];
565 word->
S[0] ^= (0x8000000000000000ULL >> (offset * 8U));
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.
Utility functions for operating on masked words.
#define ascon_mask64_rotate_share2_0(x)
Rotates 64-bit masked share 2 with respect to share 0.
#define ascon_mask64_unrotate_share2_0(x)
Unrotates 64-bit masked share 2 with respect to share 0.
#define ascon_mask64_unrotate_share3_1(x)
Unrotates 64-bit masked share 3 with respect to share 1.
#define ascon_mask64_rotate_share3_0(x)
Rotates 64-bit masked share 3 with respect to share 0.
#define ascon_mask64_rotate_share1_0(x)
Rotates 64-bit masked share 1 with respect to share 0.
#define ascon_mask64_unrotate_share1_0(x)
Unrotates 64-bit masked share 1 with respect to share 0.
#define ascon_mask64_unrotate_share3_0(x)
Unrotates 64-bit masked share 3 with respect to share 0.
#define ascon_mask64_unrotate_share2_1(x)
Unrotates 64-bit masked share 2 with respect to share 1.
uint64_t ascon_trng_generate_64(ascon_trng_state_t *state)
Generates a 64-bit random value for masking operations.
#define be_load_word16(ptr)
#define leftRotate16_64(a)
#define be_store_word16(ptr, x)
#define rightRotate8_64(a)
#define be_load_word32(ptr)
#define be_store_word64(ptr, x)
#define rightRotate16_64(a)
#define leftRotate32_64(a)
#define rightRotate32_64(a)
#define leftRotate8_64(a)
#define be_store_word32(ptr, x)
#define be_load_word64(ptr)
unsigned char data[8]
[snippet_key]
State of the random number source.
Masked 64-bit word with up to ASCON_MASKED_MAX_SHARES shares.
uint64_t S[ASCON_MASKED_MAX_SHARES]