1 #ifndef __hash_h
2 #define __hash_h
3 
4 #include <stdint.h>
5 
6 /* some sizes (number of bytes) */
7 #define ROWS 8
8 #define LENGTHFIELDLEN ROWS
9 #define COLS512 8
10 
11 #define SIZE512 (ROWS*COLS512)
12 
13 #define ROUNDS512 10
14 #define HASH_BIT_LEN 256
15 
16 #define ROTL32(v, n) ((((v)<<(n))|((v)>>(32-(n))))&li_32(ffffffff))
17 
18 
19 #define li_32(h) 0x##h##u
20 #define EXT_BYTE(var,n) ((uint8_t)((uint32_t)(var) >> (8*n)))
21 #define u32BIG(a)				\
22   ((ROTL32(a,8) & li_32(00FF00FF)) |		\
23    (ROTL32(a,24) & li_32(FF00FF00)))
24 
25 
26 /* NIST API begin */
27 typedef unsigned char BitSequence;
28 typedef unsigned long long DataLength;
29 typedef struct {
30 	uint32_t chaining[SIZE512/sizeof(uint32_t)]; /* actual state */
31 	uint32_t block_counter1,
32 		 block_counter2; /* message block counter(s) */
33 	BitSequence buffer[SIZE512]; /* data buffer */
34 	int buf_ptr; /* data buffer pointer */
35 	int bits_in_last_byte; /* no. of message bits in last byte of data buffer */
36 } hashState;
37 
38 void groestl(const BitSequence*, DataLength, BitSequence*);
39 
40 #endif /* __hash_h */
41