aboutsummaryrefslogtreecommitdiff
path: root/C/Sha3.h
diff options
context:
space:
mode:
authorIgor Pavlov <87184205+ip7z@users.noreply.github.com>2024-11-29 00:00:00 +0000
committerIgor Pavlov <87184205+ip7z@users.noreply.github.com>2024-11-30 15:27:15 +0500
commite5431fa6f5505e385c6f9367260717e9c47dc2ee (patch)
tree4cd2c2c3b225b48c8e7053432c41d7b6b6a3d5f8 /C/Sha3.h
parente008ce3976c087bfd21344af8f00a23cf69d4174 (diff)
download7zip-main.tar.gz
7zip-main.tar.bz2
7zip-main.zip
Diffstat (limited to 'C/Sha3.h')
-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