ASCON Suite
ascon-masked-backend.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_BACKEND_H
24 #define ASCON_MASKED_BACKEND_H
25 
27 #include "ascon-masked-config.h"
28 
29 /* Select the default back end to use for the masked ASCON permutation,
30  * and any properties we can use to optimize use of the permutation. */
31 
32 #if defined(ASCON_BACKEND_AVR5)
33 
34 /* Masked backend for AVR5 based systems */
35 #define ASCON_MASKED_X2_BACKEND_AVR5 1
36 #define ASCON_MASKED_X3_BACKEND_AVR5 1
37 #define ASCON_MASKED_WORD_BACKEND_DIRECT_XOR 1
38 
39 #elif defined(ASCON_BACKEND_X86_64)
40 
41 /* Masked backend for x86-64 based systems */
42 #define ASCON_MASKED_X2_BACKEND_X86_64 1
43 #define ASCON_MASKED_X3_BACKEND_X86_64 1
44 #define ASCON_MASKED_X4_BACKEND_X86_64 1
45 #define ASCON_MASKED_WORD_BACKEND_X86_64 1
46 #define ASCON_MASKED_BACKEND_SLICED64 1
47 
48 #elif defined(ASCON_BACKEND_SLICED32)
49 
50 /* Use the 32-bit sliced backend for masking if we were using the
51  * 32-bit sliced backend for the regular permutation as then it is
52  * easier to convert between masked and unmasked representations. */
53 #define ASCON_MASKED_X2_BACKEND_C32 1
54 #define ASCON_MASKED_X3_BACKEND_C32 1
55 #define ASCON_MASKED_X4_BACKEND_C32 1
56 #define ASCON_MASKED_WORD_BACKEND_C32 1
57 #define ASCON_MASKED_BACKEND_SLICED32 1
58 
59 #else
60 
61 /* Fall back to the 64-bit version of the masked backend if nothing better */
62 #define ASCON_MASKED_X2_BACKEND_C64 1
63 #define ASCON_MASKED_X3_BACKEND_C64 1
64 #define ASCON_MASKED_X4_BACKEND_C64 1
65 #define ASCON_MASKED_WORD_BACKEND_C64 1
66 #define ASCON_MASKED_BACKEND_SLICED64 1
67 
68 #endif
69 
70 #endif
Configures the number of shares to use for masked AEAD modes.