Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
internal-sliscp-light-m.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 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 LW_INTERNAL_SLISCP_LIGHT_M_H
24 #define LW_INTERNAL_SLISCP_LIGHT_M_H
25 
31 #include "internal-masking.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
39 /* Load a big-endian 24-bit word from a byte buffer */
40 #define be_load_word24(ptr) \
41  ((((uint32_t)((ptr)[0])) << 16) | \
42  (((uint32_t)((ptr)[1])) << 8) | \
43  ((uint32_t)((ptr)[2])))
44 
45 /* Store a big-endian 24-bit word into a byte buffer */
46 #define be_store_word24(ptr, x) \
47  do { \
48  uint32_t _x = (x); \
49  (ptr)[0] = (uint8_t)(_x >> 16); \
50  (ptr)[1] = (uint8_t)(_x >> 8); \
51  (ptr)[2] = (uint8_t)_x; \
52  } while (0)
53 
62 
69 
77  (mask_uint32_t output[8], const unsigned char input[24]);
78 
86  (unsigned char output[24], const mask_uint32_t input[8]);
87 
94 void sliscp_light256_permute_masked(mask_uint32_t block[8], unsigned rounds);
95 
103  (mask_uint32_t output[8], const unsigned char input[32]);
104 
112  (unsigned char output[32], const mask_uint32_t input[8]);
113 
120 
128  (mask_uint32_t output[10], const unsigned char input[40]);
129 
137  (unsigned char output[40], const mask_uint32_t input[10]);
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 
143 #endif
void sliscp_light320_mask(mask_uint32_t output[10], const unsigned char input[40])
Converts an unmasked sLiSCP-light-320 state into a masked state.
Definition: internal-sliscp-light-m.c:419
void sliscp_light192_mask(mask_uint32_t output[8], const unsigned char input[24])
Converts an unmasked sLiSCP-light-192 state into a masked state.
Definition: internal-sliscp-light-m.c:259
void sliscp_light256_unmask(unsigned char output[32], const mask_uint32_t input[8])
Converts a masked sLiSCP-light-256 state into an unmasked state.
Definition: internal-sliscp-light-m.c:347
void sliscp_light320_unmask(unsigned char output[40], const mask_uint32_t input[10])
Converts a masked sLiSCP-light-320 state into an unmasked state.
Definition: internal-sliscp-light-m.c:434
void sliscp_light192_permute_masked(mask_uint32_t block[8])
Performs the masked sLiSCP-light permutation on a 192-bit block.
Definition: internal-sliscp-light-m.c:197
void sliscp_light192_unmask(unsigned char output[24], const mask_uint32_t input[8])
Converts a masked sLiSCP-light-192 state into an unmasked state.
Definition: internal-sliscp-light-m.c:273
Utilities that help to implement masked ciphers.
Masked 32-bit word with four shares.
Definition: internal-masking.h:152
void sliscp_light192_reduce_masked(mask_uint32_t block[8])
Reduces masked 32-bit words into 24-bit words for sLiSCP-light-192.
Definition: internal-sliscp-light-m.c:246
void sliscp_light320_permute_masked(mask_uint32_t block[10])
Performs the masked sLiSCP-light permutation on a 320-bit block.
Definition: internal-sliscp-light-m.c:359
void sliscp_light256_mask(mask_uint32_t output[8], const unsigned char input[32])
Converts an unmasked sLiSCP-light-256 state into a masked state.
Definition: internal-sliscp-light-m.c:334
void sliscp_light256_permute_masked(mask_uint32_t block[8], unsigned rounds)
Performs the masked sLiSCP-light permutation on a 256-bit block.
Definition: internal-sliscp-light-m.c:285