Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
Data Structures | Macros | Functions
internal-gift128.h File Reference

GIFT-128 block cipher. More...

#include <stddef.h>
#include <stdint.h>
#include "internal-gift128-config.h"

Go to the source code of this file.

Data Structures

struct  gift128b_key_schedule_t
 Structure of the key schedule for GIFT-128 (bit-sliced). More...
 

Macros

#define GIFT128_BLK_SIZE   16
 Size of a GIFT-128 block in bytes.
 
#define GIFT128_ROUND_KEYS   80
 Number of round keys for the GIFT-128 key schedule.
 

Functions

void gift128b_init (gift128b_key_schedule_t *ks, const unsigned char *key)
 Initializes the key schedule for GIFT-128 (bit-sliced). More...
 
void gift128b_encrypt_preloaded (const gift128b_key_schedule_t *ks, uint32_t output[4], const uint32_t input[4])
 Encrypts a 128-bit block with GIFT-128 (bit-sliced and pre-loaded). More...
 
void gift128b_decrypt_preloaded (const gift128b_key_schedule_t *ks, uint32_t output[4], const uint32_t input[4])
 Decrypts a 128-bit block with GIFT-128 (bit-sliced and pre-loaded). More...
 
void gift128_nibbles_to_words (uint32_t block[4])
 Converts the GIFT-128 nibble-based representation into word-based. More...
 
void gift128_words_to_nibbles (uint32_t block[4])
 Converts the GIFT-128 word-based representation into nibble-based. More...
 

Detailed Description

GIFT-128 block cipher.

This version of GIFT-128 implements a cutdown form of the bit-sliced representation of GIFT-128 that is used by GIFT-COFB.

Only initialization and block encryption are supported, and the encryption function assumes that the input data was already converted from big endian to host byte order by the caller.

References: https://eprint.iacr.org/2017/622.pdf, https://eprint.iacr.org/2020/412.pdf, https://giftcipher.github.io/gift/

Function Documentation

void gift128_nibbles_to_words ( uint32_t  block[4])

Converts the GIFT-128 nibble-based representation into word-based.

Parameters
blockBlock to convert from nibble-based to word-based.
See Also
gift128_words_to_nibbles()
void gift128_words_to_nibbles ( uint32_t  block[4])

Converts the GIFT-128 word-based representation into nibble-based.

Parameters
blockBlock to convert from word-based to nibble-based.
See Also
gift128_nibbles_to_words()
void gift128b_decrypt_preloaded ( const gift128b_key_schedule_t ks,
uint32_t  output[4],
const uint32_t  input[4] 
)

Decrypts a 128-bit block with GIFT-128 (bit-sliced and pre-loaded).

Parameters
ksPoints to the GIFT-128 key schedule.
outputOutput buffer which must be at least 16 bytes in length.
inputInput buffer which must be at least 16 bytes in length.

The input and output buffers can be the same buffer for in-place decryption.

This function assumes that the input has already been pre-loaded from big-endian into host byte order in the supplied word array. The output is delivered in the same way.

void gift128b_encrypt_preloaded ( const gift128b_key_schedule_t ks,
uint32_t  output[4],
const uint32_t  input[4] 
)

Encrypts a 128-bit block with GIFT-128 (bit-sliced and pre-loaded).

Parameters
ksPoints to the GIFT-128 key schedule.
outputOutput buffer which must be at least 16 bytes in length.
inputInput buffer which must be at least 16 bytes in length.

The input and output buffers can be the same buffer for in-place encryption.

This function assumes that the input has already been pre-loaded from big-endian into host byte order in the supplied word array. The output is delivered in the same way.

void gift128b_init ( gift128b_key_schedule_t ks,
const unsigned char *  key 
)

Initializes the key schedule for GIFT-128 (bit-sliced).

Parameters
ksPoints to the key schedule to initialize.
keyPoints to the 16 bytes of the key data.