Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
skinny-plus-bc.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 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 LWCRYPTO_SKINNY_PLUS_BC_H
24 #define LWCRYPTO_SKINNY_PLUS_BC_H
25 
26 #include <stddef.h>
27 #include <stdint.h>
28 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
52 #define SKINNY_128_384_PLUS_KEY_SIZE 48
53 
57 #define SKINNY_128_384_PLUS_BLOCK_SIZE 16
58 
72 typedef struct
73 {
74  uint8_t TK1[16];
75  uint32_t k[160];
78 
86 
95 
107  const unsigned char k[SKINNY_128_384_PLUS_KEY_SIZE]);
108 
124  (skinny_128_384_plus_key_schedule_t *ks, const unsigned char *tk2,
125  const unsigned char *tk3);
126 
143  (const skinny_128_384_plus_key_schedule_t *ks, unsigned char *output,
144  const unsigned char *input, size_t len);
145 
162  (const skinny_128_384_plus_key_schedule_t *ks, unsigned char *output,
163  const unsigned char *input, size_t len);
164 
189  (skinny_128_384_plus_key_schedule_t *ks, unsigned char *output,
190  const unsigned char *input, const unsigned char *tk1, size_t len);
191 
216  (skinny_128_384_plus_key_schedule_t *ks, unsigned char *output,
217  const unsigned char *input, const unsigned char *tk1, size_t len);
218 
233 
251  (const unsigned char k[SKINNY_128_384_PLUS_KEY_SIZE],
252  unsigned char *output, const unsigned char *input, size_t len);
253 
271  (const unsigned char k[SKINNY_128_384_PLUS_KEY_SIZE],
272  unsigned char *output, const unsigned char *input, size_t len);
273 
274 #ifdef __cplusplus
275 }
276 #endif
277 
278 #endif
size_t skinny_128_384_plus_get_parallel_size(void)
Gets the best size to use for parallel encryption and decryption.
Definition: skinny-plus-bc.c:33
void skinny_128_384_plus_setup_tk23(skinny_128_384_plus_key_schedule_t *ks, const unsigned char *tk2, const unsigned char *tk3)
Sets up the TK2 and TK3 parts of the key schedule for SKINNY-128-384+ without TK1.
Definition: skinny-plus-bc.c:46
void skinny_128_384_plus_ecb_encrypt_tk1(skinny_128_384_plus_key_schedule_t *ks, unsigned char *output, const unsigned char *input, const unsigned char *tk1, size_t len)
Encrypts an array of 128-bit blocks with SKINNY-128-384+ where the TK1 values vary from block to bloc...
Definition: skinny-plus-bc.c:79
void skinny_128_384_plus_free_schedule(skinny_128_384_plus_key_schedule_t *ks)
Frees a SKINNY-128-384+ key schedule and destroys any sensitive data.
Definition: skinny-plus-bc.c:108
void skinny_128_384_plus_ecb_encrypt(const skinny_128_384_plus_key_schedule_t *ks, unsigned char *output, const unsigned char *input, size_t len)
Encrypts an array of 128-bit blocks with SKINNY-128-384+.
Definition: skinny-plus-bc.c:53
void skinny_128_384_plus_expand_and_decrypt(const unsigned char k[SKINNY_128_384_PLUS_KEY_SIZE], unsigned char *output, const unsigned char *input, size_t len)
Expands the key schedule and decrypts an array of blocks with SKINNY-128-384+.
Definition: skinny-plus-bc.c:127
Structure of an expanded SKINNY-128-384+ key schedule.
Definition: skinny-plus-bc.h:72
void skinny_128_384_plus_expand_and_encrypt(const unsigned char k[SKINNY_128_384_PLUS_KEY_SIZE], unsigned char *output, const unsigned char *input, size_t len)
Expands the key schedule and encrypts an array of blocks with SKINNY-128-384+.
Definition: skinny-plus-bc.c:115
void skinny_128_384_plus_setup_key(skinny_128_384_plus_key_schedule_t *ks, const unsigned char k[SKINNY_128_384_PLUS_KEY_SIZE])
Sets up a key schedule for SKINNY-128-384+.
Definition: skinny-plus-bc.c:39
size_t skinny_128_384_plus_get_key_schedule_size(void)
Gets the actual size of the SKINNY-128-384+ key schedule in the back end.
Definition: skinny-plus-bc.c:28
void skinny_128_384_plus_ecb_decrypt_tk1(skinny_128_384_plus_key_schedule_t *ks, unsigned char *output, const unsigned char *input, const unsigned char *tk1, size_t len)
Decrypts an array of 128-bit blocks with SKINNY-128-384+ where the TK1 values vary from block to bloc...
Definition: skinny-plus-bc.c:94
#define SKINNY_128_384_PLUS_KEY_SIZE
Size of the key for SKINNY-128-384+.
Definition: skinny-plus-bc.h:52
void skinny_128_384_plus_ecb_decrypt(const skinny_128_384_plus_key_schedule_t *ks, unsigned char *output, const unsigned char *input, size_t len)
Encrypts an array of 128-bit blocks with SKINNY-128-384+.
Definition: skinny-plus-bc.c:66