1 /* $MirOS: src/include/whirlpool.h,v 1.2 2013/10/31 20:06:10 tg Exp $ */
2 
3 #ifndef _WHIRLPOOL_H
4 #define _WHIRLPOOL_H
5 
6 #define WHIRLPOOL_BLOCK_LENGTH		64
7 #define WHIRLPOOL_DIGEST_LENGTH		64
8 #define WHIRLPOOL_DIGEST_STRING_LENGTH	(WHIRLPOOL_DIGEST_LENGTH * 2 + 1)
9 
10 typedef struct {
11 	uint8_t bitLength[32];	/* number of hashed bits (256-bit counter) */
12 	uint8_t buffer[WHIRLPOOL_BLOCK_LENGTH];	/* buffer of data to hash */
13 	int bufferBits;		/* current number of bits on the buffer */
14 	int bufferPos;		/* current (possibly incomplete) byte slot */
15 	uint64_t hash[WHIRLPOOL_DIGEST_LENGTH / 8];	/* the hashing state */
16 } WHIRLPOOL_CTX;
17 
18 #include <sys/cdefs.h>
19 
20 __BEGIN_DECLS
21 void WHIRLPOOLInit(WHIRLPOOL_CTX *);
22 void WHIRLPOOLPad(WHIRLPOOL_CTX *);
23 void WHIRLPOOLUpdate(WHIRLPOOL_CTX *, const uint8_t *, size_t)
24 	__attribute__((__bounded__(__string__, 2, 3)));
25 void WHIRLPOOLFinal(uint8_t *, WHIRLPOOL_CTX *)
26 	__attribute__((__bounded__(__minbytes__, 1, WHIRLPOOL_DIGEST_LENGTH)));
27 char *WHIRLPOOLEnd(WHIRLPOOL_CTX *, char *)
28 	__attribute__((__bounded__(__minbytes__, 2, WHIRLPOOL_DIGEST_STRING_LENGTH)));
29 char *WHIRLPOOLFile(const char *, char *)
30 	__attribute__((__bounded__(__minbytes__, 2, WHIRLPOOL_DIGEST_STRING_LENGTH)));
31 char *WHIRLPOOLFileChunk(const char *, char *, off_t, off_t)
32 	__attribute__((__bounded__(__minbytes__, 2, WHIRLPOOL_DIGEST_STRING_LENGTH)));
33 char *WHIRLPOOLData(const uint8_t *, size_t, char *)
34 	__attribute__((__bounded__(__string__, 1, 2)))
35 	__attribute__((__bounded__(__minbytes__, 3, WHIRLPOOL_DIGEST_STRING_LENGTH)));
36 __END_DECLS
37 
38 #endif
39