Lightweight Cryptography Primitives
|
SKINNY-128-384+ block cipher. More...
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | skinny_128_384_plus_key_schedule_t |
Structure of an expanded SKINNY-128-384+ key schedule. More... | |
Macros | |
#define | SKINNY_128_384_PLUS_KEY_SIZE 48 |
Size of the key for SKINNY-128-384+. | |
#define | SKINNY_128_384_PLUS_BLOCK_SIZE 16 |
Size of a single message block for SKINNY-128-384+. | |
Functions | |
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. More... | |
size_t | skinny_128_384_plus_get_parallel_size (void) |
Gets the best size to use for parallel encryption and decryption. More... | |
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+. More... | |
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. More... | |
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+. More... | |
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+. More... | |
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 block. More... | |
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 block. More... | |
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. More... | |
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+. More... | |
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+. More... | |
SKINNY-128-384+ block cipher.
This API provides access to the raw SKINNY-128-384+ block cipher ECB operation to help applications implement higher-level modes around the cipher.
The ECB encryption and decryption functions can take multiple blocks as input which allows the back end to process multiple blocks in parallel on architectures with SIMD instructions. The function skinny_128_384_plus_get_parallel_size() returns the best number of bytes to process in a parallel request. The input should be divided up into blocks of this size if possible.
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+.
ks | Points to the SKINNY-128-384+ key schedule. |
output | Output buffer which must be at least len bytes in length. |
input | Input buffer which must be at least len bytes in length. |
len | Number of bytes to decrypt, which should be a multiple of SKINNY_128_384_PLUS_BLOCK_SIZE bytes. If not, the last partial block will be ignored. |
The input and output buffers can be the same buffer for in-place decryption.
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 block.
ks | Points to the SKINNY-128-384+ key schedule. |
output | Output buffer which must be at least len bytes in length. |
input | Input buffer which must be at least len bytes in length. |
tk1 | Points to the TK1 values for the blocks, which must be at least len bytes in length. |
len | Number of bytes to encrypt, which should be a multiple of SKINNY_128_384_PLUS_BLOCK_SIZE bytes. If not, the last partial block will be ignored. |
The input and output buffers can be the same buffer for in-place decryption.
This function may modify the TK1 field of ks by copying successive blocks from tk1 to ks during decryption. The application should assume that the TK1 field of ks has been destroyed after this function is called.
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+.
ks | Points to the SKINNY-128-384+ key schedule. |
output | Output buffer which must be at least len bytes in length. |
input | Input buffer which must be at least len bytes in length. |
len | Number of bytes to encrypt, which should be a multiple of SKINNY_128_384_PLUS_BLOCK_SIZE bytes. If not, the last partial block will be ignored. |
The input and output buffers can be the same buffer for in-place encryption.
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 block.
ks | Points to the SKINNY-128-384+ key schedule. |
output | Output buffer which must be at least len bytes in length. |
input | Input buffer which must be at least len bytes in length. |
tk1 | Points to the TK1 values for the blocks, which must be at least len bytes in length. |
len | Number of bytes to encrypt, which should be a multiple of SKINNY_128_384_PLUS_BLOCK_SIZE bytes. If not, the last partial block will be ignored. |
The input and output buffers can be the same buffer for in-place encryption.
This function may modify the TK1 field of ks by copying successive blocks from tk1 to ks during encryption. The application should assume that the TK1 field of ks has been destroyed after this function is called.
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+.
k | Points to the SKINNY_128_384_PLUS_KEY_SIZE bytes of the key. |
output | Output buffer which must be at least len bytes in length. |
input | Input buffer which must be at least len bytes in length. |
len | Number of bytes to encrypt, which should be a multiple of SKINNY_128_384_PLUS_BLOCK_SIZE bytes. If not, the last partial block will be ignored. |
This function is intended for decrypting blocks where the entire 48 bytes of the key change from request to request.
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+.
k | Points to the SKINNY_128_384_PLUS_KEY_SIZE bytes of the key. |
output | Output buffer which must be at least len bytes in length. |
input | Input buffer which must be at least len bytes in length. |
len | Number of bytes to encrypt, which should be a multiple of SKINNY_128_384_PLUS_BLOCK_SIZE bytes. If not, the last partial block will be ignored. |
This function is intended for encrypting blocks where the entire 48 bytes of the key change from request to request.
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.
ks | Points to the key schedule object. |
Normally this will simply clear the ks object to all zeroes as the caller is responsible for deallocating the memory used by ks. It is still a good idea to call this function when the key schedule is no longer required because future back ends might allocate dynamic memory for large key schedules in the key setup functions.
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.
size_t skinny_128_384_plus_get_parallel_size | ( | void | ) |
Gets the best size to use for parallel encryption and decryption.
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+.
ks | Points to the key schedule object to set up. |
k | Points to the SKINNY_128_384_PLUS_KEY_SIZE bytes of the key. |
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.
ks | Points to the key schedule to initialize. |
tk2 | Points to the 16 bytes of key data for TK2. |
tk3 | Points to the 16 bytes of key data for TK3. |
It is assumed that the application will fill in the TK1 field within ks when it needs to encrypt or decrypt.