Belle II Software  release-08-01-10
KeccakHash.h
1 /*
2 Implementation by the Keccak, Keyak and Ketje Teams, namely, Guido Bertoni,
3 Joan Daemen, MichaĆ«l Peeters, Gilles Van Assche and Ronny Van Keer, hereby
4 denoted as "the implementer".
5 
6 For more information, feedback or questions, please refer to our websites:
7 http://keccak.noekeon.org/
8 http://keyak.noekeon.org/
9 http://ketje.noekeon.org/
10 
11 To the extent possible under law, the implementer has waived all copyright
12 and related or neighboring rights to the source code in this file.
13 http://creativecommons.org/publicdomain/zero/1.0/
14 */
15 
16 #ifndef _KeccakHashInterface_h_
17 #define _KeccakHashInterface_h_
18 
19 #ifndef KeccakP1600_excluded
20 
21 #include "KeccakSponge.h"
22 #include <string.h>
23 
24 typedef unsigned char BitSequence;
25 typedef size_t DataLength;
26 typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2 } HashReturn;
27 
28 // @cond doxygen_ignore
29 typedef struct {
30  KeccakWidth1600_SpongeInstance sponge;
31  unsigned int fixedOutputLength;
32  unsigned char delimitedSuffix;
33 } Keccak_HashInstance;
34 // @endcond
35 
51 HashReturn Keccak_HashInitialize(Keccak_HashInstance* hashInstance, unsigned int rate, unsigned int capacity,
52  unsigned int hashbitlen, unsigned char delimitedSuffix);
53 
56 #define Keccak_HashInitialize_SHAKE128(hashInstance) Keccak_HashInitialize(hashInstance, 1344, 256, 0, 0x1F)
57 
60 #define Keccak_HashInitialize_SHAKE256(hashInstance) Keccak_HashInitialize(hashInstance, 1088, 512, 0, 0x1F)
61 
64 #define Keccak_HashInitialize_SHA3_224(hashInstance) Keccak_HashInitialize(hashInstance, 1152, 448, 224, 0x06)
65 
68 #define Keccak_HashInitialize_SHA3_256(hashInstance) Keccak_HashInitialize(hashInstance, 1088, 512, 256, 0x06)
69 
72 #define Keccak_HashInitialize_SHA3_384(hashInstance) Keccak_HashInitialize(hashInstance, 832, 768, 384, 0x06)
73 
76 #define Keccak_HashInitialize_SHA3_512(hashInstance) Keccak_HashInitialize(hashInstance, 576, 1024, 512, 0x06)
77 
88 HashReturn Keccak_HashUpdate(Keccak_HashInstance* hashInstance, const BitSequence* data, DataLength databitlen);
89 
101 HashReturn Keccak_HashFinal(Keccak_HashInstance* hashInstance, BitSequence* hashval);
102 
112 HashReturn Keccak_HashSqueeze(Keccak_HashInstance* hashInstance, BitSequence* data, DataLength databitlen);
113 
114 #endif
115 
116 #endif