Skinny-C
|
SKINNY tweakable block cipher with 128-bit blocks. More...
Data Structures | |
union | Skinny128Cells_t |
Union that describes a 128-bit 4x4 array of cells. More... | |
union | Skinny128HalfCells_t |
Union that describes a 64-bit 2x4 array of cells. More... | |
struct | Skinny128Key_t |
Key schedule for Skinny128 block ciphers. More... | |
struct | Skinny128TweakedKey_t |
Key schedule for Skinny128 block ciphers when a tweak is in use. More... | |
struct | Skinny128CTR_t |
State information for Skinny-128 in CTR mode. More... | |
struct | Skinny128ParallelECB_t |
State information for Skinny-128 in parallel ECB mode. More... | |
Macros | |
#define | SKINNY128_BLOCK_SIZE 16 |
Size of a block for Skinny128 block ciphers. | |
#define | SKINNY128_MAX_ROUNDS 56 |
Maximum number of rounds for Skinny128 block ciphers. | |
Functions | |
int | skinny128_set_key (Skinny128Key_t *ks, const void *key, unsigned size) |
Sets the key schedule for a Skinny128 block cipher. More... | |
int | skinny128_set_tweaked_key (Skinny128TweakedKey_t *ks, const void *key, unsigned key_size) |
Sets the key schedule for a Skinny128 block cipher, and prepare for tweaked encryption. More... | |
int | skinny128_set_tweak (Skinny128TweakedKey_t *ks, const void *tweak, unsigned tweak_size) |
Changes the tweak value for a previously-initialized key schedule. More... | |
void | skinny128_ecb_encrypt (void *output, const void *input, const Skinny128Key_t *ks) |
Encrypts a single block using the Skinny128 block cipher in ECB mode. More... | |
void | skinny128_ecb_decrypt (void *output, const void *input, const Skinny128Key_t *ks) |
Decrypts a single block using the Skinny128 block cipher in ECB mode. More... | |
int | skinny128_ctr_init (Skinny128CTR_t *ctr) |
Initializes Skinny-128 in CTR mode. More... | |
void | skinny128_ctr_cleanup (Skinny128CTR_t *ctr) |
Cleans up a CTR control block for Skinny-128. More... | |
int | skinny128_ctr_set_key (Skinny128CTR_t *ctr, const void *key, unsigned size) |
Sets the key schedule for a Skinny128 block cipher in CTR mode. More... | |
int | skinny128_ctr_set_tweaked_key (Skinny128CTR_t *ctr, const void *key, unsigned key_size) |
Sets the key schedule for a Skinny128 block cipher in CTR mode, and prepare for tweaked encryption. More... | |
int | skinny128_ctr_set_tweak (Skinny128CTR_t *ctr, const void *tweak, unsigned tweak_size) |
Changes the tweak value for a previously-initialized key schedule. More... | |
int | skinny128_ctr_set_counter (Skinny128CTR_t *ctr, const void *counter, unsigned size) |
Sets the counter value in a Skinny-128 CTR control block. More... | |
int | skinny128_ctr_encrypt (void *output, const void *input, size_t size, Skinny128CTR_t *ctr) |
Encrypt a block of data using Skinny-128 in CTR mode. More... | |
int | skinny128_parallel_ecb_init (Skinny128ParallelECB_t *ecb) |
Initializes Skinny-128 in parallel ECB mode. More... | |
void | skinny128_parallel_ecb_cleanup (Skinny128ParallelECB_t *ecb) |
Cleans up a parallel ECB control block for Skinny-128. More... | |
int | skinny128_parallel_ecb_set_key (Skinny128ParallelECB_t *ecb, const void *key, unsigned size) |
Sets the key schedule for a Skinny128 block cipher in parallel ECB mode. More... | |
int | skinny128_parallel_ecb_encrypt (void *output, const void *input, size_t size, const Skinny128ParallelECB_t *ecb) |
Encrypt a block of data using Skinny-128 in parallel ECB mode. More... | |
int | skinny128_parallel_ecb_decrypt (void *output, const void *input, size_t size, const Skinny128ParallelECB_t *ecb) |
Decrypt a block of data using Skinny-128 in parallel ECB mode. More... | |
SKINNY tweakable block cipher with 128-bit blocks.
Skinny-128 is a block cipher with 128-bit blocks and a choice of key sizes between 128-bit and 384-bit. Alternatively, Skinny-128 can be used as a tweakable block cipher with a 128-bit tweak and between 128-bit and 256-bit keys.
void skinny128_ctr_cleanup | ( | Skinny128CTR_t * | ctr | ) |
Cleans up a CTR control block for Skinny-128.
ctr | Points to the CTR control block to clean up. |
Definition at line 228 of file skinny128-ctr.c.
int skinny128_ctr_encrypt | ( | void * | output, |
const void * | input, | ||
size_t | size, | ||
Skinny128CTR_t * | ctr | ||
) |
Encrypt a block of data using Skinny-128 in CTR mode.
output | The output buffer for the ciphertext. |
input | The input buffer containing the plaintext. |
size | The number of bytes to be encrypted. |
ctr | The CTR control block to use and update. |
This function can also be used for CTR mode decryption.
Definition at line 277 of file skinny128-ctr.c.
int skinny128_ctr_init | ( | Skinny128CTR_t * | ctr | ) |
Initializes Skinny-128 in CTR mode.
ctr | Points to the CTR control block to initialize. |
The counter block is initially set to all-zeroes.
Definition at line 208 of file skinny128-ctr.c.
int skinny128_ctr_set_counter | ( | Skinny128CTR_t * | ctr, |
const void * | counter, | ||
unsigned | size | ||
) |
Sets the counter value in a Skinny-128 CTR control block.
ctr | The CTR control block to modify. |
counter | The counter value to set, which may be NULL to specify an all-zeroes counter. |
size | The size of the counter in bytes, between 0 and SKINNY128_BLOCK_SIZE. Short counter blocks are padded on the left with zeroes to make up a full SKINNY128_BLOCK_SIZE bytes. |
The counter is assumed to be in big-endian order, incremented from the right-most byte forward, as in the standard AES-CTR mode. Often the counter block will contain a packet sequence number or equivalent in the left-most bytes with the right-most bytes used to count blocks within the specified packet.
Calling this function will also reset the keystream position so that the next call to skinny128_ctr_encrypt() will start with the new counter value. Usually this occurs at the start of a packet.
Definition at line 267 of file skinny128-ctr.c.
int skinny128_ctr_set_key | ( | Skinny128CTR_t * | ctr, |
const void * | key, | ||
unsigned | size | ||
) |
Sets the key schedule for a Skinny128 block cipher in CTR mode.
ctr | The CTR control block to set the key on. |
key | Points to the key. |
size | Size of the key, between 16 and 48 bytes. |
The primary key sizes are 16, 32, and 48. In-between sizes will be padded with zero bytes to the next primary key size.
Calling this function will also reset the keystream position so that the next call to skinny128_ctr_encrypt() will start with the new key. Usually this occurs at the start of a packet.
Definition at line 237 of file skinny128-ctr.c.
int skinny128_ctr_set_tweak | ( | Skinny128CTR_t * | ctr, |
const void * | tweak, | ||
unsigned | tweak_size | ||
) |
Changes the tweak value for a previously-initialized key schedule.
ctr | The CTR control block to set the tweak on. |
tweak | The new tweak value, or NULL for a zero tweak. |
tweak_size | Size of the new tweak value; between 1 and 16 bytes. |
This function modifies the key schedule to change the tweak from its previous value to the new value given by tweak.
Calling this function will also reset the keystream position so that the next call to skinny128_ctr_encrypt() will start with the new counter value. Usually this occurs at the start of a packet.
Definition at line 257 of file skinny128-ctr.c.
int skinny128_ctr_set_tweaked_key | ( | Skinny128CTR_t * | ctr, |
const void * | key, | ||
unsigned | key_size | ||
) |
Sets the key schedule for a Skinny128 block cipher in CTR mode, and prepare for tweaked encryption.
ctr | The CTR control block to set the key on. |
key | Points to the key. |
key_size | Size of the key, between 16 and 32 bytes. |
The primary key sizes are 16 and 32. In-between sizes will be padded with zero bytes to the next primary key size. The initial tweak will be all-zeroes.
Once the initial key and tweak have been set, the tweak can be changed later by calling skinny128_ctr_set_tweak().
Calling this function will also reset the keystream position so that the next call to skinny128_ctr_encrypt() will start with the new tweak. Usually this occurs at the start of a packet.
Definition at line 247 of file skinny128-ctr.c.
void skinny128_ecb_decrypt | ( | void * | output, |
const void * | input, | ||
const Skinny128Key_t * | ks | ||
) |
Decrypts a single block using the Skinny128 block cipher in ECB mode.
output | The output block, which must contain at least SKINNY128_BLOCK_SIZE bytes of space for the plaintext. |
input | The input block, which must contain at least SKINNY128_BLOCK_SIZE bytes of ciphertext data. |
ks | The key schedule that was set up by skinny128_set_key(). |
The input and output blocks are allowed to overlap.
Definition at line 593 of file skinny128-cipher.c.
void skinny128_ecb_encrypt | ( | void * | output, |
const void * | input, | ||
const Skinny128Key_t * | ks | ||
) |
Encrypts a single block using the Skinny128 block cipher in ECB mode.
output | The output block, which must contain at least SKINNY128_BLOCK_SIZE bytes of space for the ciphertext. |
input | The input block, which must contain at least SKINNY128_BLOCK_SIZE bytes of plaintext data. |
ks | The key schedule that was set up by skinny128_set_key(). |
The input and output blocks are allowed to overlap.
Definition at line 533 of file skinny128-cipher.c.
void skinny128_parallel_ecb_cleanup | ( | Skinny128ParallelECB_t * | ecb | ) |
Cleans up a parallel ECB control block for Skinny-128.
ecb | Points to the parallel ECB control block to clean up. |
Definition at line 79 of file skinny128-parallel.c.
int skinny128_parallel_ecb_decrypt | ( | void * | output, |
const void * | input, | ||
size_t | size, | ||
const Skinny128ParallelECB_t * | ecb | ||
) |
Decrypt a block of data using Skinny-128 in parallel ECB mode.
output | The output buffer for the plaintext. |
input | The input buffer containing the ciphertext. |
size | The number of bytes to be decrypted, which must be a multiple of SKINNY128_BLOCK_SIZE. |
ecb | The parallel ECB control block to use and update. |
For best performance, size should be a multiple of the parallel_size value in to the ecb structure.
Definition at line 133 of file skinny128-parallel.c.
int skinny128_parallel_ecb_encrypt | ( | void * | output, |
const void * | input, | ||
size_t | size, | ||
const Skinny128ParallelECB_t * | ecb | ||
) |
Encrypt a block of data using Skinny-128 in parallel ECB mode.
output | The output buffer for the ciphertext. |
input | The input buffer containing the plaintext. |
size | The number of bytes to be encrypted, which must be a multiple of SKINNY128_BLOCK_SIZE. |
ecb | The parallel ECB control block to use and update. |
For best performance, size should be a multiple of the parallel_size value in to the ecb structure.
Definition at line 99 of file skinny128-parallel.c.
int skinny128_parallel_ecb_init | ( | Skinny128ParallelECB_t * | ecb | ) |
Initializes Skinny-128 in parallel ECB mode.
ecb | Points to the parallel ECB control block to initialize. |
Definition at line 62 of file skinny128-parallel.c.
int skinny128_parallel_ecb_set_key | ( | Skinny128ParallelECB_t * | ecb, |
const void * | key, | ||
unsigned | size | ||
) |
Sets the key schedule for a Skinny128 block cipher in parallel ECB mode.
ecb | The parallel ECB control block to set the key on. |
key | Points to the key. |
size | Size of the key, between 8 and 24 bytes. |
The primary key sizes are 8, 16, and 24. In-between sizes will be padded with zero bytes to the next primary key size.
Definition at line 89 of file skinny128-parallel.c.
int skinny128_set_key | ( | Skinny128Key_t * | ks, |
const void * | key, | ||
unsigned | size | ||
) |
Sets the key schedule for a Skinny128 block cipher.
ks | The key schedule structure to populate. |
key | Points to the key. |
size | Size of the key, between 16 and 48 bytes. |
The primary key sizes are 16, 32, and 48. In-between sizes will be padded with zero bytes to the next primary key size.
Definition at line 310 of file skinny128-cipher.c.
int skinny128_set_tweak | ( | Skinny128TweakedKey_t * | ks, |
const void * | tweak, | ||
unsigned | tweak_size | ||
) |
Changes the tweak value for a previously-initialized key schedule.
ks | The key schedule to change. |
tweak | The new tweak value, or NULL for a zero tweak. |
tweak_size | Size of the new tweak value; between 1 and 16 bytes. |
This function modifies the key schedule to change the tweak from its previous value to the new value given by tweak.
Definition at line 341 of file skinny128-cipher.c.
int skinny128_set_tweaked_key | ( | Skinny128TweakedKey_t * | ks, |
const void * | key, | ||
unsigned | key_size | ||
) |
Sets the key schedule for a Skinny128 block cipher, and prepare for tweaked encryption.
ks | The key schedule structure to populate. |
key | Points to the key. |
key_size | Size of the key, between 16 and 32 bytes. |
The primary key sizes are 16 and 32. In-between sizes will be padded with zero bytes to the next primary key size. The initial tweak will be all-zeroes.
Once the initial key and tweak have been set, the tweak can be changed later by calling skinny128_set_tweak().
Definition at line 324 of file skinny128-cipher.c.