ASCON Suite
ascon-masked-word-direct.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Southern Storm Software, Pty Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #include "ascon-masked-word.h"
24 
25 #if defined(ASCON_MASKED_WORD_BACKEND_DIRECT_XOR)
26 
27 /* Direct XOR of the key and plaintext data with the random data.
28  * No rotation of the shares is performed. This is used by AVR. */
29 
30 typedef union { uint64_t w; uint8_t b[8]; } random_bytes_t;
31 
34 {
35  unsigned index;
36  word->S[0] = ascon_trng_generate_64(trng);
37  for (index = 0; index < 8; ++index)
38  word->B[index + 8] = word->B[index];
40  word->S[2] = 0;
41 #endif
43  word->S[3] = 0;
44 #endif
45 }
46 
48  (ascon_masked_word_t *word, const uint8_t *data,
49  ascon_trng_state_t *trng)
50 {
51  unsigned index;
52  word->S[1] = ascon_trng_generate_64(trng);
53  for (index = 0; index < 8; ++index)
54  word->B[index] = data[index] ^ word->B[index + 8];
56  word->S[2] = 0;
57 #endif
59  word->S[3] = 0;
60 #endif
61 }
62 
64  (ascon_masked_word_t *word, const uint8_t *data, unsigned size,
65  ascon_trng_state_t *trng)
66 {
67  unsigned index;
68  word->S[1] = ascon_trng_generate_64(trng);
69  for (index = 0; index < size; ++index)
70  word->B[index] = data[index] ^ word->B[index + 8];
71  for (; index < 8; ++index)
72  word->B[index] = word->B[index + 8];
74  word->S[2] = 0;
75 #endif
77  word->S[3] = 0;
78 #endif
79 }
80 
82  (ascon_masked_word_t *word, const uint8_t *data1,
83  const uint8_t *data2, ascon_trng_state_t *trng)
84 {
85  unsigned index;
86  word->S[1] = ascon_trng_generate_64(trng);
87  for (index = 0; index < 4; ++index) {
88  word->B[index] = data1[index] ^ word->B[index + 8];
89  word->B[index + 4] = data2[index] ^ word->B[index + 12];
90  }
91 #if ASCON_MASKED_MAX_SHARES >= 3
92  word->S[2] = 0;
93 #endif
94 #if ASCON_MASKED_MAX_SHARES >= 4
95  word->S[3] = 0;
96 #endif
97 }
98 
100  (uint8_t *data, const ascon_masked_word_t *word)
101 {
102  unsigned index;
103  for (index = 0; index < 8; ++index)
104  data[index] = word->B[index] ^ word->B[index + 8];
105 }
106 
108  (uint8_t *data, unsigned size, const ascon_masked_word_t *word)
109 {
110  unsigned index;
111  for (index = 0; index < size; ++index)
112  data[index] = word->B[index] ^ word->B[index + 8];
113 }
114 
116  (ascon_masked_word_t *dest, const ascon_masked_word_t *src,
117  ascon_trng_state_t *trng)
118 {
119  random_bytes_t random;
120  unsigned index;
121  random.w = ascon_trng_generate_64(trng);
122  for (index = 0; index < 8; ++index) {
123  dest->B[index] = src->B[index] ^ random.b[index];
124  dest->B[index + 8] = src->B[index + 8] ^ random.b[index];
125  }
126 }
127 
129  (ascon_masked_word_t *dest, const ascon_masked_word_t *src)
130 {
131  unsigned index;
132  for (index = 0; index < 8; ++index) {
133  dest->B[index] ^= src->B[index];
134  dest->B[index + 8] ^= src->B[index + 8];
135  }
136 }
137 
139  (ascon_masked_word_t *dest, const ascon_masked_word_t *src, unsigned size)
140 {
141  unsigned index;
142  for (index = 0; index < size; ++index) {
143  dest->B[index] = src->B[index];
144  dest->B[index + 8] = src->B[index + 8];
145  }
146 }
147 
148 #if ASCON_MASKED_MAX_SHARES >= 3
149 
151  (ascon_masked_word_t *dest, const ascon_masked_word_t *src,
152  ascon_trng_state_t *trng)
153 {
154  random_bytes_t random;
155  unsigned index;
156  random.w = ascon_trng_generate_64(trng);
157  for (index = 0; index < 8; ++index) {
158  dest->B[index] = random.b[index] ^ src->B[index];
159  dest->B[index + 8] =
160  (random.b[index] ^ src->B[index + 8]) ^ src->B[index + 16];
161  }
162  dest->S[2] = 0;
163 #if ASCON_MASKED_MAX_SHARES >= 4
164  dest->S[3] = 0;
165 #endif
166 }
167 
168 #endif /* ASCON_MASKED_MAX_SHARES >= 3 */
169 
170 #if ASCON_MASKED_MAX_SHARES >= 4
171 
173  (ascon_masked_word_t *dest, const ascon_masked_word_t *src,
174  ascon_trng_state_t *trng)
175 {
176  random_bytes_t random;
177  unsigned index;
178  random.w = ascon_trng_generate_64(trng);
179  for (index = 0; index < 8; ++index) {
180  dest->B[index] =
181  (random.b[index] ^ src->B[index]) ^ src->B[index + 16];
182  dest->B[index + 8] =
183  (random.b[index] ^ src->B[index + 8]) ^ src->B[index + 24];
184  }
185  dest->S[2] = 0;
186  dest->S[3] = 0;
187 }
188 
189 #endif /* ASCON_MASKED_MAX_SHARES >= 4 */
190 
191 #if ASCON_MASKED_MAX_SHARES >= 3
192 
195 {
196  unsigned index;
197  word->S[1] = ascon_trng_generate_64(trng);
198  word->S[2] = ascon_trng_generate_64(trng);
199  for (index = 0; index < 8; ++index)
200  word->B[index] = word->B[index + 8] ^ word->B[index + 16];
202  word->S[3] = 0;
203 #endif
204 }
205 
207  (ascon_masked_word_t *word, const uint8_t *data,
208  ascon_trng_state_t *trng)
209 {
210  unsigned index;
211  word->S[1] = ascon_trng_generate_64(trng);
212  word->S[2] = ascon_trng_generate_64(trng);
213  for (index = 0; index < 8; ++index) {
214  word->B[index] =
215  (word->B[index + 8] ^ data[index]) ^ word->B[index + 16];
216  }
217 #if ASCON_MASKED_MAX_SHARES >= 4
218  word->S[3] = 0;
219 #endif
220 }
221 
223  (ascon_masked_word_t *word, const uint8_t *data, unsigned size,
224  ascon_trng_state_t *trng)
225 {
226  unsigned index;
227  word->S[1] = ascon_trng_generate_64(trng);
228  word->S[2] = ascon_trng_generate_64(trng);
229  for (index = 0; index < size; ++index) {
230  word->B[index] =
231  (word->B[index + 8] ^ data[index]) ^ word->B[index + 16];
232  }
233  for (; index < 8; ++index)
234  word->B[index] = word->B[index + 8] ^ word->B[index + 16];
236  word->S[3] = 0;
237 #endif
238 }
239 
241  (ascon_masked_word_t *word, const uint8_t *data1,
242  const uint8_t *data2, ascon_trng_state_t *trng)
243 {
244  unsigned index;
245  word->S[1] = ascon_trng_generate_64(trng);
246  word->S[2] = ascon_trng_generate_64(trng);
247  for (index = 0; index < 4; ++index) {
248  word->B[index] =
249  (word->B[index + 8] ^ data1[index]) ^ word->B[index + 16];
250  word->B[index + 4] =
251  (word->B[index + 12] ^ data2[index]) ^ word->B[index + 20];
252  }
253 #if ASCON_MASKED_MAX_SHARES >= 4
254  word->S[3] = 0;
255 #endif
256 }
257 
259  (uint8_t *data, const ascon_masked_word_t *word)
260 {
261  unsigned index;
262  for (index = 0; index < 8; ++index)
263  data[index] = word->B[index] ^ word->B[index + 8] ^ word->B[index + 16];
264 }
265 
267  (uint8_t *data, unsigned size, const ascon_masked_word_t *word)
268 {
269  unsigned index;
270  for (index = 0; index < size; ++index)
271  data[index] = word->B[index] ^ word->B[index + 8] ^ word->B[index + 16];
272 }
273 
275  (ascon_masked_word_t *dest, const ascon_masked_word_t *src,
276  ascon_trng_state_t *trng)
277 {
278  random_bytes_t random1;
279  random_bytes_t random2;
280  unsigned index;
281  random1.w = ascon_trng_generate_64(trng);
282  random2.w = ascon_trng_generate_64(trng);
283  for (index = 0; index < 8; ++index) {
284  dest->B[index]
285  = (random1.b[index] ^ src->B[index]) ^ random2.b[index];
286  dest->B[index + 8] = src->B[index + 8] ^ random1.b[index];
287  dest->B[index + 16] = src->B[index + 16] ^ random2.b[index];
288  }
289 }
290 
292  (ascon_masked_word_t *dest, const ascon_masked_word_t *src)
293 {
294  unsigned index;
295  for (index = 0; index < 8; ++index) {
296  dest->B[index] ^= src->B[index];
297  dest->B[index + 8] ^= src->B[index + 8];
298  dest->B[index + 16] ^= src->B[index + 16];
299  }
300 }
301 
303  (ascon_masked_word_t *dest, const ascon_masked_word_t *src, unsigned size)
304 {
305  unsigned index;
306  for (index = 0; index < size; ++index) {
307  dest->B[index] = src->B[index];
308  dest->B[index + 8] = src->B[index + 8];
309  dest->B[index + 16] = src->B[index + 16];
310  }
311 }
312 
314  (ascon_masked_word_t *dest, const ascon_masked_word_t *src,
315  ascon_trng_state_t *trng)
316 {
317  random_bytes_t random1;
318  random_bytes_t random2;
319  unsigned index;
320  random1.w = ascon_trng_generate_64(trng);
321  random2.w = ascon_trng_generate_64(trng);
322  for (index = 0; index < 8; ++index) {
323  dest->B[index] = (random1.b[index] ^ src->B[index]) ^ random2.b[index];
324  dest->B[index + 8] = (random1.b[index] ^ src->B[index + 8]);
325  dest->B[index + 16] = random2.b[index];
326  }
327 #if ASCON_MASKED_MAX_SHARES >= 4
328  dest->S[3] = 0;
329 #endif
330 }
331 
332 #if ASCON_MASKED_MAX_SHARES >= 4
333 
335  (ascon_masked_word_t *dest, const ascon_masked_word_t *src,
336  ascon_trng_state_t *trng)
337 {
338  random_bytes_t random1;
339  random_bytes_t random2;
340  unsigned index;
341  random1.w = ascon_trng_generate_64(trng);
342  random2.w = ascon_trng_generate_64(trng);
343  for (index = 0; index < 8; ++index) {
344  dest->B[index] =
345  ((random1.b[index] ^ src->B[index]) ^ random2.b[index]) ^
346  src->B[index + 24];
347  dest->B[index + 8] = (random1.b[index] ^ src->B[index + 8]);
348  dest->B[index + 16] = (random2.b[index] ^ src->B[index + 16]);
349  }
350  dest->S[3] = 0;
351 }
352 
353 #endif /* ASCON_MASKED_MAX_SHARES >= 4 */
354 
355 #endif /* ASCON_MASKED_MAX_SHARES >= 3 */
356 
357 #if ASCON_MASKED_MAX_SHARES >= 4
358 
361 {
362  unsigned index;
363  word->S[1] = ascon_trng_generate_64(trng);
364  word->S[2] = ascon_trng_generate_64(trng);
365  word->S[3] = ascon_trng_generate_64(trng);
366  for (index = 0; index < 8; ++index) {
367  word->B[index] =
368  word->B[index + 8] ^ word->B[index + 16] ^ word->B[index + 24];
369  }
370 }
371 
373  (ascon_masked_word_t *word, const uint8_t *data,
374  ascon_trng_state_t *trng)
375 {
376  unsigned index;
377  word->S[1] = ascon_trng_generate_64(trng);
378  word->S[2] = ascon_trng_generate_64(trng);
379  word->S[3] = ascon_trng_generate_64(trng);
380  for (index = 0; index < 8; ++index) {
381  word->B[index] =
382  (word->B[index + 8] ^ data[index]) ^ word->B[index + 16] ^
383  word->B[index + 24];
384  }
385 }
386 
388  (ascon_masked_word_t *word, const uint8_t *data, unsigned size,
389  ascon_trng_state_t *trng)
390 {
391  unsigned index;
392  word->S[1] = ascon_trng_generate_64(trng);
393  word->S[2] = ascon_trng_generate_64(trng);
394  word->S[3] = ascon_trng_generate_64(trng);
395  for (index = 0; index < size; ++index) {
396  word->B[index] =
397  (word->B[index + 8] ^ data[index]) ^ word->B[index + 16] ^
398  word->B[index + 24];
399  }
400  for (; index < 8; ++index) {
401  word->B[index] =
402  word->B[index + 8] ^ word->B[index + 16] ^ word->B[index + 24];
403  }
404 }
405 
407  (ascon_masked_word_t *word, const uint8_t *data1,
408  const uint8_t *data2, ascon_trng_state_t *trng)
409 {
410  unsigned index;
411  word->S[1] = ascon_trng_generate_64(trng);
412  word->S[2] = ascon_trng_generate_64(trng);
413  word->S[3] = ascon_trng_generate_64(trng);
414  for (index = 0; index < 4; ++index) {
415  word->B[index] =
416  (word->B[index + 8] ^ data1[index]) ^ word->B[index + 16] ^
417  word->B[index + 24];
418  word->B[index + 4] =
419  (word->B[index + 12] ^ data2[index]) ^ word->B[index + 20] ^
420  word->B[index + 28];
421  }
422 }
423 
425  (uint8_t *data, const ascon_masked_word_t *word)
426 {
427  unsigned index;
428  for (index = 0; index < 8; ++index) {
429  data[index] =
430  word->B[index] ^ word->B[index + 8] ^
431  word->B[index + 16] ^ word->B[index + 24];
432  }
433 }
434 
436  (uint8_t *data, unsigned size, const ascon_masked_word_t *word)
437 {
438  unsigned index;
439  for (index = 0; index < size; ++index) {
440  data[index] =
441  word->B[index] ^ word->B[index + 8] ^
442  word->B[index + 16] ^ word->B[index + 24];
443  }
444 }
445 
447  (ascon_masked_word_t *dest, const ascon_masked_word_t *src,
448  ascon_trng_state_t *trng)
449 {
450  random_bytes_t random1;
451  random_bytes_t random2;
452  random_bytes_t random3;
453  unsigned index;
454  random1.w = ascon_trng_generate_64(trng);
455  random2.w = ascon_trng_generate_64(trng);
456  random3.w = ascon_trng_generate_64(trng);
457  for (index = 0; index < 8; ++index) {
458  dest->B[index]
459  = (random1.b[index] ^ src->B[index]) ^ random2.b[index] ^
460  random3.b[index];
461  dest->B[index + 8] = src->B[index + 8] ^ random1.b[index];
462  dest->B[index + 16] = src->B[index + 16] ^ random2.b[index];
463  dest->B[index + 24] = src->B[index + 24] ^ random3.b[index];
464  }
465 }
466 
468  (ascon_masked_word_t *dest, const ascon_masked_word_t *src)
469 {
470  unsigned index;
471  for (index = 0; index < 8; ++index) {
472  dest->B[index] ^= src->B[index];
473  dest->B[index + 8] ^= src->B[index + 8];
474  dest->B[index + 16] ^= src->B[index + 16];
475  dest->B[index + 24] ^= src->B[index + 24];
476  }
477 }
478 
480  (ascon_masked_word_t *dest, const ascon_masked_word_t *src, unsigned size)
481 {
482  unsigned index;
483  for (index = 0; index < size; ++index) {
484  dest->B[index] = src->B[index];
485  dest->B[index + 8] = src->B[index + 8];
486  dest->B[index + 16] = src->B[index + 16];
487  dest->B[index + 24] = src->B[index + 24];
488  }
489 }
490 
492  (ascon_masked_word_t *dest, const ascon_masked_word_t *src,
493  ascon_trng_state_t *trng)
494 {
495  random_bytes_t random1;
496  random_bytes_t random2;
497  random_bytes_t random3;
498  unsigned index;
499  random1.w = ascon_trng_generate_64(trng);
500  random2.w = ascon_trng_generate_64(trng);
501  random3.w = ascon_trng_generate_64(trng);
502  for (index = 0; index < 8; ++index) {
503  dest->B[index] =
504  (random1.b[index] ^ src->B[index]) ^
505  random2.b[index] ^ random3.b[index];
506  dest->B[index + 8] = (random1.b[index] ^ src->B[index + 8]);
507  dest->B[index + 16] = random2.b[index];
508  dest->B[index + 24] = random3.b[index];
509  }
510 }
511 
513  (ascon_masked_word_t *dest, const ascon_masked_word_t *src,
514  ascon_trng_state_t *trng)
515 {
516  random_bytes_t random1;
517  random_bytes_t random2;
518  random_bytes_t random3;
519  unsigned index;
520  random1.w = ascon_trng_generate_64(trng);
521  random2.w = ascon_trng_generate_64(trng);
522  random3.w = ascon_trng_generate_64(trng);
523  for (index = 0; index < 8; ++index) {
524  dest->B[index] =
525  (random1.b[index] ^ src->B[index]) ^
526  random2.b[index] ^ random3.b[index];
527  dest->B[index + 8] = (random1.b[index] ^ src->B[index + 8]);
528  dest->B[index + 16] = (random2.b[index] ^ src->B[index + 16]);
529  dest->B[index + 24] = random3.b[index];
530  }
531 }
532 
533 #endif /* ASCON_MASKED_MAX_SHARES >= 4 */
534 
535 void ascon_masked_word_pad(ascon_masked_word_t *word, unsigned offset)
536 {
537  word->B[offset] ^= 0x80;
538 }
539 
541 {
542  word->B[7] ^= 1;
543 }
544 
545 #endif /* ASCON_MASKED_WORD_BACKEND_DIRECT_XOR */
#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.
Utility functions for operating on masked words.
uint64_t ascon_trng_generate_64(ascon_trng_state_t *state)
Generates a 64-bit random value for masking operations.
unsigned char data[8]
[snippet_key]
Definition: snippets.c:14
State of the random number source.
Definition: ascon-trng.h:64
Masked 64-bit word with up to ASCON_MASKED_MAX_SHARES shares.
uint64_t S[ASCON_MASKED_MAX_SHARES]
uint8_t B[ASCON_MASKED_MAX_SHARES *8]