ASCON Suite
masking.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_MASKING_H
24 #define ASCON_MASKING_H
25 
26 #include <stdint.h>
27 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
42 typedef union
43 {
44  uint64_t S[4];
45  uint32_t W[8];
46  uint8_t B[32];
49 
62 typedef struct
63 {
67 
84 typedef struct
85 {
89 
100  (ascon_masked_key_128_t *masked, const unsigned char *key);
101 
108 
117 
125  (const ascon_masked_key_128_t *masked, unsigned char *key);
126 
137  (ascon_masked_key_160_t *masked, const unsigned char *key);
138 
145 
154 
162  (const ascon_masked_key_160_t *masked, unsigned char *key);
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif
void ascon_masked_key_128_free(ascon_masked_key_128_t *masked)
Frees a masked 128-bit key and destroys all sensitive material.
void ascon_masked_key_160_free(ascon_masked_key_160_t *masked)
Frees a masked 160-bit key and destroys all sensitive material.
void ascon_masked_key_128_init(ascon_masked_key_128_t *masked, const unsigned char *key)
Initializes a masked 128-bit key for ASCON.
void ascon_masked_key_160_extract(const ascon_masked_key_160_t *masked, unsigned char *key)
Extracts the plain version of a 160-bit key from its masked version.
void ascon_masked_key_128_extract(const ascon_masked_key_128_t *masked, unsigned char *key)
Extracts the plain version of a 128-bit key from its masked version.
void ascon_masked_key_160_randomize(ascon_masked_key_160_t *masked)
Randomizes a masked 160-bit key by mixing in fresh random material.
void ascon_masked_key_128_randomize(ascon_masked_key_128_t *masked)
Randomizes a masked 128-bit key by mixing in fresh random material.
void ascon_masked_key_160_init(ascon_masked_key_160_t *masked, const unsigned char *key)
Initializes a masked 160-bit key for ASCON.
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
Masked 64-bit key word with up to four shares.
Definition: masking.h:43