Skinny-C
|
SKINNY tweakable block cipher with 64-bit blocks. More...
Data Structures | |
union | Skinny64Cells_t |
Union that describes a 64-bit 4x4 array of cells. More... | |
union | Skinny64HalfCells_t |
Union that describes a 32-bit 2x4 array of cells. More... | |
struct | Skinny64Key_t |
Key schedule for Skinny64 block ciphers. More... | |
struct | Skinny64TweakedKey_t |
Key schedule for Skinny64 block ciphers when a tweak is in use. More... | |
struct | Skinny64CTR_t |
State information for Skinny-64 in CTR mode. More... | |
struct | Skinny64ParallelECB_t |
State information for Skinny-64 in parallel ECB mode. More... | |
Macros | |
#define | SKINNY64_BLOCK_SIZE 8 |
Size of a block for Skinny64 block ciphers. | |
#define | SKINNY64_MAX_ROUNDS 40 |
Maximum number of rounds for Skinny64 block ciphers. | |
Functions | |
int | skinny64_set_key (Skinny64Key_t *ks, const void *key, unsigned size) |
Sets the key schedule for a Skinny64 block cipher. More... | |
int | skinny64_set_tweaked_key (Skinny64TweakedKey_t *ks, const void *key, unsigned key_size) |
Sets the key schedule for a Skinny64 block cipher, and prepare for tweaked encryption. More... | |
int | skinny64_set_tweak (Skinny64TweakedKey_t *ks, const void *tweak, unsigned tweak_size) |
Changes the tweak value for a previously-initialized key schedule. More... | |
void | skinny64_ecb_encrypt (void *output, const void *input, const Skinny64Key_t *ks) |
Encrypts a single block using the Skinny64 block cipher in ECB mode. More... | |
void | skinny64_ecb_decrypt (void *output, const void *input, const Skinny64Key_t *ks) |
Decrypts a single block using the Skinny64 block cipher in ECB mode. More... | |
int | skinny64_ctr_init (Skinny64CTR_t *ctr) |
Initializes Skinny-64 in CTR mode. More... | |
void | skinny64_ctr_cleanup (Skinny64CTR_t *ctr) |
Cleans up a CTR control block for Skinny-64. More... | |
int | skinny64_ctr_set_key (Skinny64CTR_t *ctr, const void *key, unsigned size) |
Sets the key schedule for a Skinny64 block cipher in CTR mode. More... | |
int | skinny64_ctr_set_tweaked_key (Skinny64CTR_t *ctr, const void *key, unsigned key_size) |
Sets the key schedule for a Skinny64 block cipher in CTR mode, and prepare for tweaked encryption. More... | |
int | skinny64_ctr_set_tweak (Skinny64CTR_t *ctr, const void *tweak, unsigned tweak_size) |
Changes the tweak value for a previously-initialized key schedule. More... | |
int | skinny64_ctr_set_counter (Skinny64CTR_t *ctr, const void *counter, unsigned size) |
Sets the counter value in a Skinny-64 CTR control block. More... | |
int | skinny64_ctr_encrypt (void *output, const void *input, size_t size, Skinny64CTR_t *ctr) |
Encrypt a block of data using Skinny-64 in CTR mode. More... | |
int | skinny64_parallel_ecb_init (Skinny64ParallelECB_t *ecb) |
Initializes Skinny-64 in parallel ECB mode. More... | |
void | skinny64_parallel_ecb_cleanup (Skinny64ParallelECB_t *ecb) |
Cleans up a parallel ECB control block for Skinny-64. More... | |
int | skinny64_parallel_ecb_set_key (Skinny64ParallelECB_t *ecb, const void *key, unsigned size) |
Sets the key schedule for a Skinny64 block cipher in parallel ECB mode. More... | |
int | skinny64_parallel_ecb_encrypt (void *output, const void *input, size_t size, const Skinny64ParallelECB_t *ecb) |
Encrypt a block of data using Skinny-64 in parallel ECB mode. More... | |
int | skinny64_parallel_ecb_decrypt (void *output, const void *input, size_t size, const Skinny64ParallelECB_t *ecb) |
Decrypt a block of data using Skinny-64 in parallel ECB mode. More... | |
SKINNY tweakable block cipher with 64-bit blocks.
Skinny-64 is a block cipher with 64-bit blocks and a choice of key sizes between 64-bit and 192-bit. Alternatively, Skinny-64 can be used as a tweakable block cipher with a 64-bit tweak and between 64-bit and 128-bit keys.
void skinny64_ctr_cleanup | ( | Skinny64CTR_t * | ctr | ) |
Cleans up a CTR control block for Skinny-64.
ctr | Points to the CTR control block to clean up. |
Definition at line 227 of file skinny64-ctr.c.
int skinny64_ctr_encrypt | ( | void * | output, |
const void * | input, | ||
size_t | size, | ||
Skinny64CTR_t * | ctr | ||
) |
Encrypt a block of data using Skinny-64 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 276 of file skinny64-ctr.c.
int skinny64_ctr_init | ( | Skinny64CTR_t * | ctr | ) |
Initializes Skinny-64 in CTR mode.
ctr | Points to the CTR control block to initialize. |
The counter block is initially set to all-zeroes.
Definition at line 209 of file skinny64-ctr.c.
int skinny64_ctr_set_counter | ( | Skinny64CTR_t * | ctr, |
const void * | counter, | ||
unsigned | size | ||
) |
Sets the counter value in a Skinny-64 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 SKINNY64_BLOCK_SIZE. Short counter blocks are padded on the left with zeroes to make up a full SKINNY64_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 skinny64_ctr_encrypt() will start with the new counter value. Usually this occurs at the start of a packet.
Definition at line 266 of file skinny64-ctr.c.
int skinny64_ctr_set_key | ( | Skinny64CTR_t * | ctr, |
const void * | key, | ||
unsigned | size | ||
) |
Sets the key schedule for a Skinny64 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 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.
Calling this function will also reset the keystream position so that the next call to skinny64_ctr_encrypt() will start with the new key. Usually this occurs at the start of a packet.
Definition at line 236 of file skinny64-ctr.c.
int skinny64_ctr_set_tweak | ( | Skinny64CTR_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 skinny64_ctr_encrypt() will start with the new counter value. Usually this occurs at the start of a packet.
Definition at line 256 of file skinny64-ctr.c.
int skinny64_ctr_set_tweaked_key | ( | Skinny64CTR_t * | ctr, |
const void * | key, | ||
unsigned | key_size | ||
) |
Sets the key schedule for a Skinny64 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 8 and 16 bytes. |
The primary key sizes are 8 and 16. 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 skinny64_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 246 of file skinny64-ctr.c.
void skinny64_ecb_decrypt | ( | void * | output, |
const void * | input, | ||
const Skinny64Key_t * | ks | ||
) |
Decrypts a single block using the Skinny64 block cipher in ECB mode.
output | The output block, which must contain at least SKINNY64_BLOCK_SIZE bytes of space for the plaintext. |
input | The input block, which must contain at least SKINNY64_BLOCK_SIZE bytes of ciphertext data. |
ks | The key schedule that was set up by skinny64_set_key(). |
The input and output blocks are allowed to overlap.
Definition at line 517 of file skinny64-cipher.c.
void skinny64_ecb_encrypt | ( | void * | output, |
const void * | input, | ||
const Skinny64Key_t * | ks | ||
) |
Encrypts a single block using the Skinny64 block cipher in ECB mode.
output | The output block, which must contain at least SKINNY64_BLOCK_SIZE bytes of space for the ciphertext. |
input | The input block, which must contain at least SKINNY64_BLOCK_SIZE bytes of plaintext data. |
ks | The key schedule that was set up by skinny64_set_key(). |
The input and output blocks are allowed to overlap.
Definition at line 448 of file skinny64-cipher.c.
void skinny64_parallel_ecb_cleanup | ( | Skinny64ParallelECB_t * | ecb | ) |
Cleans up a parallel ECB control block for Skinny-64.
ecb | Points to the parallel ECB control block to clean up. |
Definition at line 65 of file skinny64-parallel.c.
int skinny64_parallel_ecb_decrypt | ( | void * | output, |
const void * | input, | ||
size_t | size, | ||
const Skinny64ParallelECB_t * | ecb | ||
) |
Decrypt a block of data using Skinny-64 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 SKINNY64_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 119 of file skinny64-parallel.c.
int skinny64_parallel_ecb_encrypt | ( | void * | output, |
const void * | input, | ||
size_t | size, | ||
const Skinny64ParallelECB_t * | ecb | ||
) |
Encrypt a block of data using Skinny-64 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 SKINNY64_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 85 of file skinny64-parallel.c.
int skinny64_parallel_ecb_init | ( | Skinny64ParallelECB_t * | ecb | ) |
Initializes Skinny-64 in parallel ECB mode.
ecb | Points to the parallel ECB control block to initialize. |
Definition at line 52 of file skinny64-parallel.c.
int skinny64_parallel_ecb_set_key | ( | Skinny64ParallelECB_t * | ecb, |
const void * | key, | ||
unsigned | size | ||
) |
Sets the key schedule for a Skinny64 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 75 of file skinny64-parallel.c.
int skinny64_set_key | ( | Skinny64Key_t * | ks, |
const void * | key, | ||
unsigned | size | ||
) |
Sets the key schedule for a Skinny64 block cipher.
ks | The key schedule structure to populate. |
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 278 of file skinny64-cipher.c.
int skinny64_set_tweak | ( | Skinny64TweakedKey_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 8 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 309 of file skinny64-cipher.c.
int skinny64_set_tweaked_key | ( | Skinny64TweakedKey_t * | ks, |
const void * | key, | ||
unsigned | key_size | ||
) |
Sets the key schedule for a Skinny64 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 8 and 16 bytes. |
The primary key sizes are 8 and 16. 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 skinny64_set_tweak().
Definition at line 292 of file skinny64-cipher.c.