ASCON Suite
ascon-masked-state.h
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 #ifndef ASCON_MASKED_STATE_H
24 #define ASCON_MASKED_STATE_H
25 
26 #include "ascon-masked-word.h"
27 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif
82 
89 typedef struct
90 {
94 
107 
117 
128 
138 void ascon_x2_permute
139  (ascon_masked_state_t *state, uint8_t first_round, uint64_t *preserve);
140 
150  (ascon_masked_state_t *dest, const ascon_state_t *src,
151  ascon_trng_state_t *trng);
152 
164 
174  (ascon_masked_state_t *dest, const ascon_masked_state_t *src,
175  ascon_trng_state_t *trng);
176 
186  (ascon_masked_state_t *dest, const ascon_masked_state_t *src,
187  ascon_trng_state_t *trng);
188 
198  (ascon_masked_state_t *dest, const ascon_masked_state_t *src,
199  ascon_trng_state_t *trng);
200 
211 
222  (ascon_masked_state_t *state, uint8_t first_round, uint64_t *preserve);
223 
233  (ascon_masked_state_t *dest, const ascon_state_t *src,
234  ascon_trng_state_t *trng);
235 
247 
257  (ascon_masked_state_t *dest, const ascon_masked_state_t *src,
258  ascon_trng_state_t *trng);
259 
269  (ascon_masked_state_t *dest, const ascon_masked_state_t *src,
270  ascon_trng_state_t *trng);
271 
281  (ascon_masked_state_t *dest, const ascon_masked_state_t *src,
282  ascon_trng_state_t *trng);
283 
294 
305  (ascon_masked_state_t *state, uint8_t first_round, uint64_t *preserve);
306 
316  (ascon_masked_state_t *dest, const ascon_state_t *src,
317  ascon_trng_state_t *trng);
318 
330 
340  (ascon_masked_state_t *dest, const ascon_masked_state_t *src,
341  ascon_trng_state_t *trng);
342 
352  (ascon_masked_state_t *dest, const ascon_masked_state_t *src,
353  ascon_trng_state_t *trng);
354 
364  (ascon_masked_state_t *dest, const ascon_masked_state_t *src,
365  ascon_trng_state_t *trng);
366 
378 
390 
391 #ifdef __cplusplus
392 }
393 #endif
394 
395 #endif
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.
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.
void ascon_x2_permute(ascon_masked_state_t *state, uint8_t first_round, uint64_t *preserve)
Permutes the ASCON-x2 state with a specified number of rounds.
Definition: ascon-x2-c64.c:50
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.
void ascon_x4_randomize(ascon_masked_state_t *state, ascon_trng_state_t *trng)
Randomizes an ASCON-x4 permutation state.
void ascon_x4_permute(ascon_masked_state_t *state, uint8_t first_round, uint64_t *preserve)
Permutes the ASCON-x4 state with a specified number of rounds.
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.
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.
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.
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.
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.
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.
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.
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.
void ascon_masked_state_free(ascon_masked_state_t *state)
Frees an ASCON-x2 permutation state and attempts to destroy any sensitive material.
void ascon_masked_state_init(ascon_masked_state_t *state)
Initializes the words of a masked ASCON permutation state.
void ascon_x2_randomize(ascon_masked_state_t *state, ascon_trng_state_t *trng)
Randomizes an ASCON-x2 permutation state.
void ascon_x3_randomize(ascon_masked_state_t *state, ascon_trng_state_t *trng)
Randomizes an ASCON-x3 permutation state.
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.
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.
void ascon_masked_key_128_randomize_with_trng(ascon_masked_key_128_t *masked, ascon_trng_state_t *trng)
Randomizes a masked 128-bit key by mixing in fresh random material from a caller-supplied TRNG.
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.
void ascon_masked_key_160_randomize_with_trng(ascon_masked_key_160_t *masked, ascon_trng_state_t *trng)
Randomizes a masked 160-bit key by mixing in fresh random material from a caller-supplied TRNG.
void ascon_x3_permute(ascon_masked_state_t *state, uint8_t first_round, uint64_t *preserve)
Permutes the ASCON-x3 state with a specified number of rounds.
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.
Utility functions for operating on masked words.
ascon_state_t state
[snippet_key]
Definition: snippets.c:2
128-bit key that has been masked to hide its value when the code is operating on it.
Definition: masking.h:63
160-bit key that has been masked to hide its value when the code is operating on it.
Definition: masking.h:85
State of the ASCON permutation which has been masked with up to 4 shares.
State of the random number source.
Definition: ascon-trng.h:64
Masked 64-bit word with up to ASCON_MASKED_MAX_SHARES shares.
Structure of the internal state of the ASCON permutation.
Definition: permutation.h:63