grain128aead_32p.h 664 Bytes
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

#ifndef GRAIN128AEAD_32P_H
#define GRAIN128AEAD_32P_H

typedef uint8_t		u8;
typedef uint16_t	u16;
typedef uint32_t	u32;
typedef uint64_t	u64;


// 4 words key and IV, 12 init rounds, 1024 rounds before reinit = 1040
#define BUF_SIZE 1040

typedef struct {
	u32 lfsr[BUF_SIZE];
	u32 nfsr[BUF_SIZE];
	u32 *lptr;
	u32 *nptr;
	u32 count;
	u64 acc;
	u64 reg;
} grain_ctx;

void grain_init(grain_ctx *, const u8 *, const u8 *);
void grain_reinit(grain_ctx *);
u32 next_keystream(grain_ctx *);
void auth_accumulate(grain_ctx *, u16, u16);
void auth_accumulate8(grain_ctx *, u8, u8);
u16 getmb(u32);
u16 getkb(u32);
int encode_der(unsigned long long len, u8 **);

#endif