Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
Data Structures | Macros | Functions
skinny-plus-bc.h File Reference

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...
 

Detailed Description

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.

Function Documentation

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+.

Parameters
ksPoints to the SKINNY-128-384+ key schedule.
outputOutput buffer which must be at least len bytes in length.
inputInput buffer which must be at least len bytes in length.
lenNumber 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.

See Also
skinny_128_384_plus_ecb_encrypt(), skinny_128_384_plus_setup_key()
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.

Parameters
ksPoints to the SKINNY-128-384+ key schedule.
outputOutput buffer which must be at least len bytes in length.
inputInput buffer which must be at least len bytes in length.
tk1Points to the TK1 values for the blocks, which must be at least len bytes in length.
lenNumber 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.

See Also
skinny_128_384_plus_ecb_decrypt()
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+.

Parameters
ksPoints to the SKINNY-128-384+ key schedule.
outputOutput buffer which must be at least len bytes in length.
inputInput buffer which must be at least len bytes in length.
lenNumber 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.

See Also
skinny_128_384_plus_ecb_decrypt(), skinny_128_384_plus_setup_key()
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.

Parameters
ksPoints to the SKINNY-128-384+ key schedule.
outputOutput buffer which must be at least len bytes in length.
inputInput buffer which must be at least len bytes in length.
tk1Points to the TK1 values for the blocks, which must be at least len bytes in length.
lenNumber 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.

See Also
skinny_128_384_plus_ecb_encrypt()
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+.

Parameters
kPoints to the SKINNY_128_384_PLUS_KEY_SIZE bytes of the key.
outputOutput buffer which must be at least len bytes in length.
inputInput buffer which must be at least len bytes in length.
lenNumber 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.

See Also
skinny_128_384_plus_expand_and_encrypt()
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+.

Parameters
kPoints to the SKINNY_128_384_PLUS_KEY_SIZE bytes of the key.
outputOutput buffer which must be at least len bytes in length.
inputInput buffer which must be at least len bytes in length.
lenNumber 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.

See Also
skinny_128_384_plus_expand_and_decrypt()
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.

Parameters
ksPoints 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.

See Also
skinny_128_384_plus_setup_key(), skinny_128_384_plus_setup_tk23()
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.

Returns
The actual size of the key schedule.
size_t skinny_128_384_plus_get_parallel_size ( void  )

Gets the best size to use for parallel encryption and decryption.

Returns
The best size in bytes to use for processing blocks in parallel. If the back end does not support parallel block processing, then this function will return SKINNY_128_384_PLUS_BLOCK_SIZE.
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+.

Parameters
ksPoints to the key schedule object to set up.
kPoints to the SKINNY_128_384_PLUS_KEY_SIZE bytes of the key.
See Also
skinny_128_384_plus_ecb_encrypt(), skinny_128_384_plus_ecb_decrypt(), skinny_128_384_plus_free_schedule(), skinny_128_384_plus_setup_tk23()
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.

Parameters
ksPoints to the key schedule to initialize.
tk2Points to the 16 bytes of key data for TK2.
tk3Points 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.

See Also
skinny_128_384_plus_ecb_encrypt(), skinny_128_384_plus_ecb_decrypt(), skinny_128_384_plus_free_schedule(), skinny_128_384_plus_setup_key()