aboutsummaryrefslogtreecommitdiff
path: root/C/Sha3.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--C/Sha3.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/C/Sha3.h b/C/Sha3.h
new file mode 100644
index 0000000..c5909c9
--- /dev/null
+++ b/C/Sha3.h
@@ -0,0 +1,36 @@
1/* Sha3.h -- SHA-3 Hash
2: Igor Pavlov : Public domain */
3
4#ifndef ZIP7_INC_MD5_H
5#define ZIP7_INC_MD5_H
6
7#include "7zTypes.h"
8
9EXTERN_C_BEGIN
10
11#define SHA3_NUM_STATE_WORDS 25
12
13#define SHA3_BLOCK_SIZE_FROM_DIGEST_SIZE(digestSize) \
14 (SHA3_NUM_STATE_WORDS * 8 - (digestSize) * 2)
15
16typedef struct
17{
18 UInt32 count; // < blockSize
19 UInt32 blockSize; // <= SHA3_NUM_STATE_WORDS * 8
20 UInt64 _pad1[3];
21 // we want 32-bytes alignment here
22 UInt64 state[SHA3_NUM_STATE_WORDS];
23 UInt64 _pad2[3];
24 // we want 64-bytes alignment here
25 Byte buffer[SHA3_NUM_STATE_WORDS * 8]; // last bytes will be unused with predefined blockSize values
26} CSha3;
27
28#define Sha3_SET_blockSize(p, blockSize) { (p)->blockSize = (blockSize); }
29
30void Sha3_Init(CSha3 *p);
31void Sha3_Update(CSha3 *p, const Byte *data, size_t size);
32void Sha3_Final(CSha3 *p, Byte *digest, unsigned digestSize, unsigned shake);
33
34EXTERN_C_END
35
36#endif