Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
internal-gift128.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 LW_INTERNAL_GIFT128_H
24 #define LW_INTERNAL_GIFT128_H
25 
42 #include <stddef.h>
43 #include <stdint.h>
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
53 #define GIFT128_BLK_SIZE 16
54 
59 #if GIFT128_VARIANT == GIFT128_VARIANT_TINY
60 #define GIFT128_ROUND_KEYS 4
61 #elif GIFT128_VARIANT == GIFT128_VARIANT_SMALL
62 #define GIFT128_ROUND_KEYS 20
63 #else
64 #define GIFT128_ROUND_KEYS 80
65 #endif
66 
70 typedef struct
71 {
73  uint32_t k[GIFT128_ROUND_KEYS];
74 
76 
83 void gift128b_init(gift128b_key_schedule_t *ks, const unsigned char *key);
84 
100  (const gift128b_key_schedule_t *ks, uint32_t output[4],
101  const uint32_t input[4]);
102 
118  (const gift128b_key_schedule_t *ks, uint32_t output[4],
119  const uint32_t input[4]);
120 
128 void gift128_nibbles_to_words(uint32_t block[4]);
129 
137 void gift128_words_to_nibbles(uint32_t block[4]);
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 
143 #endif
Structure of the key schedule for GIFT-128 (bit-sliced).
Definition: internal-gift128.h:70
#define GIFT128_ROUND_KEYS
Number of round keys for the GIFT-128 key schedule.
Definition: internal-gift128.h:64
void gift128b_init(gift128b_key_schedule_t *ks, const unsigned char *key)
Initializes the key schedule for GIFT-128 (bit-sliced).
Definition: internal-gift128.c:218
void gift128b_decrypt_preloaded(const gift128b_key_schedule_t *ks, uint32_t output[4], const uint32_t input[4])
Decrypts a 128-bit block with GIFT-128 (bit-sliced and pre-loaded).
Definition: internal-gift128.c:703
Configures the variant of GIFT-128 to use.
void gift128_nibbles_to_words(uint32_t block[4])
Converts the GIFT-128 nibble-based representation into word-based.
Definition: internal-gift128.c:952
void gift128_words_to_nibbles(uint32_t block[4])
Converts the GIFT-128 word-based representation into nibble-based.
Definition: internal-gift128.c:994
void gift128b_encrypt_preloaded(const gift128b_key_schedule_t *ks, uint32_t output[4], const uint32_t input[4])
Encrypts a 128-bit block with GIFT-128 (bit-sliced and pre-loaded).
Definition: internal-gift128.c:674