estate.h 1.37 KB
Newer Older
lwc-tester committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#ifndef __ESTATE_H__
#define __ESTATE_H__

#include <string.h>
#include <stdlib.h>

/* 
 * Block cipher's block size
 */ 
#define CRYPTO_BLOCKBYTES (16)

/* 
 * Block cipher's tweak size in bytes
 */ 
#define CRYPTO_TWEAKBYTES (1)

/* 
 * No. of block cipher rounds to be used in full version
 */ 
#define CRYPTO_BC_NUM_ROUNDS (10)

/* 
 * No. of block cipher rounds to be used in round-reduced version
 */ 
#define CRYPTO_BC_REDUCED_NUM_ROUNDS (6)

/**********************************************************************
 * 
 * @name	:	PARTIAL_BLOCK_LEN
 * 
 * @note	:	Computes the number of bytes in the (possibly) partial
 * 				block.
 * 
 **********************************************************************/		
#define PARTIAL_BLOCK_LEN(blks_num,byte_len)	((byte_len-((blks_num-1)*CRYPTO_BLOCKBYTES)))

/*
 * Generate encryption round keys.
 */
#define _TWEAES_ENC_ROUND_KEY_GEN(round_keys, key)		(generate_round_keys(round_keys, key))

/*
 * Generate decryption round keys.
 */
#define _TWEAES_DEC_ROUND_KEY_GEN(round_keys, key)		(generate_round_keys(round_keys, key))

typedef unsigned char u8;
typedef unsigned long long u64;

void generate_round_keys(u8 (*round_keys)[16],const u8 *key);

void tweaes_enc(u8 *ct, const u8 (*round_keys)[16], const u8 *twk, const u8 rounds, const u8 *pt);

void tweaes_dec(u8 *pt, const u8 (*round_keys)[16], const u8 *twk, const u8 rounds, const u8 *ct);

#endif