lotus.h 1.32 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
#ifndef __LOTUS_H__
#define __LOTUS_H__

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

/* 
 * No. of block cipher rounds to be used
 */ 
#define CRYPTO_BC_NUM_ROUNDS (28)

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

/* 
 * Primitive polynomial modulo reduced by x^128 in GF(2^{128})
 * p(x) = x^128 + x^7 + x^2 + x + 1
 * p(x) mod x^128 = x^7 + x^2 + x + 1
 */ 
#define PRIM_POLY_MOD_128	(0x87)

/**********************************************************************
 * 
 * @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))

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

typedef unsigned char u8;
typedef unsigned long long u64;

void twegift_enc(u8 *ct, const u8 *key, const u8 *twk, const u8 *pt);

void twegift_dec(u8 *pt, const u8 *key, const u8 *twk, const u8 *ct);

#endif