Skinny-C
 All Data Structures Files Functions Variables Groups Pages
Data Structures | Macros | Functions
Skinny-64 API

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

Detailed Description

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.

Function Documentation

void skinny64_ctr_cleanup ( Skinny64CTR_t ctr)

Cleans up a CTR control block for Skinny-64.

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

Parameters
outputThe output buffer for the ciphertext.
inputThe input buffer containing the plaintext.
sizeThe number of bytes to be encrypted.
ctrThe CTR control block to use and update.
Returns
Zero if there is something wrong with the parameters, or 1 if the data was encrypted.

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.

Parameters
ctrPoints to the CTR control block to initialize.
Returns
Zero if ctr is NULL or there is insufficient memory to create internal data structures, or non-zero if everything is OK.

The counter block is initially set to all-zeroes.

See Also
skinny64_ctr_set_counter(), skinny64_ctr_encrypt()

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.

Parameters
ctrThe CTR control block to modify.
counterThe counter value to set, which may be NULL to specify an all-zeroes counter.
sizeThe 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.
Returns
Zero if there is something wrong with the parameters, or 1 if the counter has been set.

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.

Parameters
ctrThe CTR control block to set the key on.
keyPoints to the key.
sizeSize of the key, between 8 and 24 bytes.
Returns
Zero if there is something wrong with the parameters, or 1 if the key has been set.

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.

Parameters
ctrThe CTR control block to set the tweak on.
tweakThe new tweak value, or NULL for a zero tweak.
tweak_sizeSize of the new tweak value; between 1 and 16 bytes.
Returns
Zero if there is something wrong with the parameters, or 1 if the tweak was changed.

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.

See Also
skinny64_ctr_set_tweaked_key()

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.

Parameters
ctrThe CTR control block to set the key on.
keyPoints to the key.
key_sizeSize of the key, between 8 and 16 bytes.
Returns
Zero if there is something wrong with the parameters, or 1 if the key and tweak were set.

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.

See Also
skinny64_ctr_set_tweak()

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.

Parameters
outputThe output block, which must contain at least SKINNY64_BLOCK_SIZE bytes of space for the plaintext.
inputThe input block, which must contain at least SKINNY64_BLOCK_SIZE bytes of ciphertext data.
ksThe 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.

Parameters
outputThe output block, which must contain at least SKINNY64_BLOCK_SIZE bytes of space for the ciphertext.
inputThe input block, which must contain at least SKINNY64_BLOCK_SIZE bytes of plaintext data.
ksThe 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.

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

Parameters
outputThe output buffer for the plaintext.
inputThe input buffer containing the ciphertext.
sizeThe number of bytes to be decrypted, which must be a multiple of SKINNY64_BLOCK_SIZE.
ecbThe parallel ECB control block to use and update.
Returns
Zero if there is something wrong with the parameters, or 1 if the data was encrypted.

For best performance, size should be a multiple of the parallel_size value in to the ecb structure.

See Also
skinny64_parallel_ecb_encrypt()

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.

Parameters
outputThe output buffer for the ciphertext.
inputThe input buffer containing the plaintext.
sizeThe number of bytes to be encrypted, which must be a multiple of SKINNY64_BLOCK_SIZE.
ecbThe parallel ECB control block to use and update.
Returns
Zero if there is something wrong with the parameters, or 1 if the data was encrypted.

For best performance, size should be a multiple of the parallel_size value in to the ecb structure.

See Also
skinny64_parallel_ecb_decrypt()

Definition at line 85 of file skinny64-parallel.c.

int skinny64_parallel_ecb_init ( Skinny64ParallelECB_t ecb)

Initializes Skinny-64 in parallel ECB mode.

Parameters
ecbPoints to the parallel ECB control block to initialize.
Returns
Zero if ecb is NULL or there is insufficient memory to create internal data structures, or non-zero if everything is OK.
See Also
skinny64_ecb_set_key(), skinny64_ecb_encrypt()

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.

Parameters
ecbThe parallel ECB control block to set the key on.
keyPoints to the key.
sizeSize of the key, between 8 and 24 bytes.
Returns
Zero if there is something wrong with the parameters, or 1 if the key has been set.

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.

Parameters
ksThe key schedule structure to populate.
keyPoints to the key.
sizeSize of the key, between 8 and 24 bytes.
Returns
Zero if there is something wrong with the parameters, or 1 if the key has been set.

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.

Parameters
ksThe key schedule to change.
tweakThe new tweak value, or NULL for a zero tweak.
tweak_sizeSize of the new tweak value; between 1 and 8 bytes.
Returns
Zero if there is something wrong with the parameters, or 1 if the tweak was changed.

This function modifies the key schedule to change the tweak from its previous value to the new value given by tweak.

See Also
skinny64_set_tweaked_key()

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.

Parameters
ksThe key schedule structure to populate.
keyPoints to the key.
key_sizeSize of the key, between 8 and 16 bytes.
Returns
Zero if there is something wrong with the parameters, or 1 if the key and tweak were set.

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

See Also
skinny64_set_tweak()

Definition at line 292 of file skinny64-cipher.c.