Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
internal-spook.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_SPOOK_H
24 #define LW_INTERNAL_SPOOK_H
25 
26 #include "internal-util.h"
27 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
40 #define CLYDE128_BLOCK_SIZE 16
41 
45 #define CLYDE128_KEY_SIZE 16
46 
50 #define CLYDE128_TWEAK_SIZE 16
51 
58 #define CLYDE128_STEPS 6
59 
63 #define SHADOW512_STATE_SIZE 64
64 
68 #define SHADOW512_RATE 32
69 
73 #define SHADOW384_STATE_SIZE 48
74 
78 #define SHADOW384_RATE 16
79 
83 typedef union
84 {
85  uint32_t W[SHADOW512_STATE_SIZE / 4];
86  uint8_t B[SHADOW512_STATE_SIZE];
89 
93 typedef union
94 {
95  uint32_t W[SHADOW384_STATE_SIZE / 4];
96  uint8_t B[SHADOW384_STATE_SIZE];
99 
110 void clyde128_encrypt(const unsigned char key[CLYDE128_KEY_SIZE],
111  uint32_t output[CLYDE128_BLOCK_SIZE / 4],
112  const uint32_t input[CLYDE128_BLOCK_SIZE / 4],
113  const uint32_t tweak[CLYDE128_TWEAK_SIZE / 4]);
114 
125 void clyde128_decrypt(const unsigned char key[CLYDE128_KEY_SIZE],
126  uint32_t output[CLYDE128_BLOCK_SIZE / 4],
127  const unsigned char input[CLYDE128_BLOCK_SIZE],
128  const uint32_t tweak[CLYDE128_TWEAK_SIZE / 4]);
129 
140 void clyde128_encrypt_masked(const unsigned char key[CLYDE128_KEY_SIZE],
141  uint32_t output[CLYDE128_BLOCK_SIZE / 4],
142  const uint32_t input[CLYDE128_BLOCK_SIZE / 4],
143  const uint32_t tweak[CLYDE128_TWEAK_SIZE / 4]);
144 
155 void clyde128_decrypt_masked(const unsigned char key[CLYDE128_KEY_SIZE],
156  uint32_t output[CLYDE128_BLOCK_SIZE / 4],
157  const unsigned char input[CLYDE128_BLOCK_SIZE],
158  const uint32_t tweak[CLYDE128_TWEAK_SIZE / 4]);
159 
168 void shadow512(shadow512_state_t *state);
169 
178 void shadow384(shadow384_state_t *state);
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif
#define CLYDE128_BLOCK_SIZE
Size of the block for the Clyde-128 block cipher.
Definition: internal-spook.h:40
#define SHADOW384_STATE_SIZE
Size of the state for Shadow-384.
Definition: internal-spook.h:73
Internal state of the Shadow-512 permutation.
Definition: internal-spook.h:83
void clyde128_decrypt(const unsigned char key[CLYDE128_KEY_SIZE], uint32_t output[CLYDE128_BLOCK_SIZE/4], const unsigned char input[CLYDE128_BLOCK_SIZE], const uint32_t tweak[CLYDE128_TWEAK_SIZE/4])
Decrypts a block with the Clyde-128 block cipher.
Definition: internal-spook.c:150
void clyde128_encrypt(const unsigned char key[CLYDE128_KEY_SIZE], uint32_t output[CLYDE128_BLOCK_SIZE/4], const uint32_t input[CLYDE128_BLOCK_SIZE/4], const uint32_t tweak[CLYDE128_TWEAK_SIZE/4])
Encrypts a block with the Clyde-128 block cipher.
Definition: internal-spook.c:39
void clyde128_encrypt_masked(const unsigned char key[CLYDE128_KEY_SIZE], uint32_t output[CLYDE128_BLOCK_SIZE/4], const uint32_t input[CLYDE128_BLOCK_SIZE/4], const uint32_t tweak[CLYDE128_TWEAK_SIZE/4])
Encrypts a block with the Clyde-128 block cipher in masked mode.
Definition: internal-spook-m.c:187
void shadow384(shadow384_state_t *state)
Performs the Shadow-384 permutation on a state.
Definition: internal-spook.c:424
Internal state of the Shadow-384 permutation.
Definition: internal-spook.h:93
#define CLYDE128_KEY_SIZE
Size of the key for the Clyde-128 block cipher.
Definition: internal-spook.h:45
void clyde128_decrypt_masked(const unsigned char key[CLYDE128_KEY_SIZE], uint32_t output[CLYDE128_BLOCK_SIZE/4], const unsigned char input[CLYDE128_BLOCK_SIZE], const uint32_t tweak[CLYDE128_TWEAK_SIZE/4])
Decrypts a block with the Clyde-128 block cipher in masked mode.
Definition: internal-spook-m.c:277
#define CLYDE128_TWEAK_SIZE
Size of the tweak for the Clyde-128 block cipher.
Definition: internal-spook.h:50
#define SHADOW512_STATE_SIZE
Size of the state for Shadow-512.
Definition: internal-spook.h:63
void shadow512(shadow512_state_t *state)
Performs the Shadow-512 permutation on a state.
Definition: internal-spook.c:260