Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
internal-skinny128.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_SKINNY128_H
24 #define LW_INTERNAL_SKINNY128_H
25 
34 #include <stddef.h>
35 #include <stdint.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
45 #if defined(__AVR__)
46 #define SKINNY_128_SMALL_SCHEDULE 1
47 #else
48 #define SKINNY_128_SMALL_SCHEDULE 0
49 #endif
50 
54 #define SKINNY_128_BLOCK_SIZE 16
55 
59 #define SKINNY_128_384_ROUNDS 56
60 
64 typedef struct
65 {
67  uint8_t TK1[16];
68 
69 #if SKINNY_128_SMALL_SCHEDULE
70 
71  uint8_t TK2[16];
72 
74  uint8_t TK3[16];
75 #else
76 
77  uint32_t k[SKINNY_128_384_ROUNDS * 2];
78 #endif
79 
81 
89  (skinny_128_384_key_schedule_t *ks, const unsigned char key[48]);
90 
102  (const skinny_128_384_key_schedule_t *ks, unsigned char *output,
103  const unsigned char *input);
104 
116  (const skinny_128_384_key_schedule_t *ks, unsigned char *output,
117  const unsigned char *input);
118 
139  (skinny_128_384_key_schedule_t *ks, unsigned char *output,
140  const unsigned char *input, const unsigned char *tk2);
141 
158  (const unsigned char key[48], unsigned char *output,
159  const unsigned char *input);
160 
164 #define SKINNY_128_256_ROUNDS 48
165 
169 typedef struct
170 {
172  uint8_t TK1[16];
173 
174 #if SKINNY_128_SMALL_SCHEDULE
175 
176  uint8_t TK2[16];
177 #else
178 
179  uint32_t k[SKINNY_128_256_ROUNDS * 2];
180 #endif
181 
183 
191  (skinny_128_256_key_schedule_t *ks, const unsigned char key[32]);
192 
204  (const skinny_128_256_key_schedule_t *ks, unsigned char *output,
205  const unsigned char *input);
206 
218  (const skinny_128_256_key_schedule_t *ks, unsigned char *output,
219  const unsigned char *input);
220 
237  (const unsigned char key[32], unsigned char *output,
238  const unsigned char *input);
239 
240 #ifdef __cplusplus
241 }
242 #endif
243 
244 #endif
void skinny_128_256_encrypt(const skinny_128_256_key_schedule_t *ks, unsigned char *output, const unsigned char *input)
Encrypts a 128-bit block with SKINNY-128-256.
Definition: internal-skinny128.c:716
Structure of the key schedule for SKINNY-128-256.
Definition: internal-skinny128.h:169
void skinny_128_384_encrypt_tk2(skinny_128_384_key_schedule_t *ks, unsigned char *output, const unsigned char *input, const unsigned char *tk2)
Encrypts a 128-bit block with SKINNY-128-384 and an explicitly provided TK2 value.
Definition: internal-skinny128.c:498
void skinny_128_256_init(skinny_128_256_key_schedule_t *ks, const unsigned char key[32])
Initializes the key schedule for SKINNY-128-256.
Definition: internal-skinny128.c:599
void skinny_128_384_decrypt(const skinny_128_384_key_schedule_t *ks, unsigned char *output, const unsigned char *input)
Decrypts a 128-bit block with SKINNY-128-384.
Definition: internal-skinny128.c:369
void skinny_128_384_encrypt(const skinny_128_384_key_schedule_t *ks, unsigned char *output, const unsigned char *input)
Encrypts a 128-bit block with SKINNY-128-384.
Definition: internal-skinny128.c:222
void skinny_128_384_encrypt_tk_full(const unsigned char key[48], unsigned char *output, const unsigned char *input)
Encrypts a 128-bit block with SKINNY-128-384 and a fully specified tweakey value. ...
Definition: internal-skinny128.c:553
#define SKINNY_128_256_ROUNDS
Number of rounds for SKINNY-128-256.
Definition: internal-skinny128.h:164
#define SKINNY_128_384_ROUNDS
Number of rounds for SKINNY-128-384.
Definition: internal-skinny128.h:59
Structure of the key schedule for SKINNY-128-384.
Definition: internal-skinny128.h:64
void skinny_128_256_decrypt(const skinny_128_256_key_schedule_t *ks, unsigned char *output, const unsigned char *input)
Decrypts a 128-bit block with SKINNY-128-256.
Definition: internal-skinny128.c:828
void skinny_128_256_encrypt_tk_full(const unsigned char key[32], unsigned char *output, const unsigned char *input)
Encrypts a 128-bit block with SKINNY-128-256 and a fully specified tweakey value. ...
Definition: internal-skinny128.c:892
void skinny_128_384_init(skinny_128_384_key_schedule_t *ks, const unsigned char key[48])
Initializes the key schedule for SKINNY-128-384.
Definition: internal-skinny128.c:61