Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
gift-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_GIFT_BC_H
24 #define LWCRYPTO_GIFT_BC_H
25 
26 #include <stddef.h>
27 #include <stdint.h>
28 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
67 #define GIFT128_KEY_SIZE 16
68 
72 #define GIFT128_BLOCK_SIZE 16
73 
83 typedef struct
84 {
85  uint32_t k[80];
88 
95 
103 size_t gift128_get_parallel_size(void);
104 
114  (gift128_key_schedule_t *ks, const unsigned char *k);
115 
131  (const gift128_key_schedule_t *ks, unsigned char *output,
132  const unsigned char *input, size_t len);
133 
149  (const gift128_key_schedule_t *ks, unsigned char *output,
150  const unsigned char *input, size_t len);
151 
162  (gift128_key_schedule_t *ks, const unsigned char *k);
163 
179  (const gift128_key_schedule_t *ks, unsigned char *output,
180  const unsigned char *input, size_t len);
181 
197  (const gift128_key_schedule_t *ks, unsigned char *output,
198  const unsigned char *input, size_t len);
199 
209  (gift128_key_schedule_t *ks, const unsigned char *k);
210 
226  (const gift128_key_schedule_t *ks, unsigned char *output,
227  const unsigned char *input, size_t len);
228 
244  (const gift128_key_schedule_t *ks, unsigned char *output,
245  const unsigned char *input, size_t len);
246 
261 
262 #ifdef __cplusplus
263 }
264 #endif
265 
266 #endif
void gift128_setup_key(gift128_key_schedule_t *ks, const unsigned char *k)
Sets up a key schedule for the original version of GIFT-128.
Definition: gift-bc.c:38
void gift128_le_ecb_encrypt(const gift128_key_schedule_t *ks, unsigned char *output, const unsigned char *input, size_t len)
Encrypts a 128-bit block with the little-endian version of GIFT-128.
Definition: gift-bc.c:104
Structure of an expanded GIFT-128 key schedule.
Definition: gift-bc.h:83
void gift128_le_setup_key(gift128_key_schedule_t *ks, const unsigned char *k)
Sets up a key schedule for the little-endian version of GIFT-128.
Definition: gift-bc.c:92
void gift128_ecb_decrypt(const gift128_key_schedule_t *ks, unsigned char *output, const unsigned char *input, size_t len)
Decrypts a 128-bit block with the original version of GIFT-128.
Definition: gift-bc.c:68
void gift128b_setup_key(gift128_key_schedule_t *ks, const unsigned char *k)
Sets up a key schedule for the bit-sliced version of GIFT-128.
Definition: gift-bc.c:152
void gift128_free_schedule(gift128_key_schedule_t *ks)
Frees a GIFT-128 key schedule and destroys any sensitive data.
Definition: gift-bc.c:201
void gift128_ecb_encrypt(const gift128_key_schedule_t *ks, unsigned char *output, const unsigned char *input, size_t len)
Encrypts a 128-bit block with the original version of GIFT-128.
Definition: gift-bc.c:44
void gift128_le_ecb_decrypt(const gift128_key_schedule_t *ks, unsigned char *output, const unsigned char *input, size_t len)
Decrypts a 128-bit block with the little-endian version of GIFT-128.
Definition: gift-bc.c:128
void gift128b_ecb_decrypt(const gift128_key_schedule_t *ks, unsigned char *output, const unsigned char *input, size_t len)
Decrypts a 128-bit block with the bit-sliced version of GIFT-128.
Definition: gift-bc.c:180
size_t gift128_get_parallel_size(void)
Gets the best size to use for parallel encryption and decryption.
Definition: gift-bc.c:32
void gift128b_ecb_encrypt(const gift128_key_schedule_t *ks, unsigned char *output, const unsigned char *input, size_t len)
Encrypts a 128-bit block with the bit-sliced version of GIFT-128.
Definition: gift-bc.c:158
size_t gift128_get_key_schedule_size(void)
Gets the actual size of the GIFT-128 key schedule in the back end.
Definition: gift-bc.c:27