Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Utilities/cmlibrhash/librhash/sha3.h
3150 views
1
/* sha3.h */
2
#ifndef RHASH_SHA3_H
3
#define RHASH_SHA3_H
4
#include "ustd.h"
5
6
#ifdef __cplusplus
7
extern "C" {
8
#endif
9
10
#define sha3_224_hash_size 28
11
#define sha3_256_hash_size 32
12
#define sha3_384_hash_size 48
13
#define sha3_512_hash_size 64
14
#define sha3_max_permutation_size 25
15
#define sha3_max_rate_in_qwords 24
16
17
/**
18
* SHA3 Algorithm context.
19
*/
20
typedef struct sha3_ctx
21
{
22
/* 1600 bits algorithm hashing state */
23
uint64_t hash[sha3_max_permutation_size];
24
/* 1536-bit buffer for leftovers */
25
uint64_t message[sha3_max_rate_in_qwords];
26
/* count of bytes in the message[] buffer */
27
unsigned rest;
28
/* size of a message block processed at once */
29
unsigned block_size;
30
} sha3_ctx;
31
32
/* methods for calculating the hash function */
33
34
void rhash_sha3_224_init(sha3_ctx* ctx);
35
void rhash_sha3_256_init(sha3_ctx* ctx);
36
void rhash_sha3_384_init(sha3_ctx* ctx);
37
void rhash_sha3_512_init(sha3_ctx* ctx);
38
void rhash_sha3_update(sha3_ctx* ctx, const unsigned char* msg, size_t size);
39
void rhash_sha3_final(sha3_ctx* ctx, unsigned char* result);
40
41
#ifdef USE_KECCAK
42
#define rhash_keccak_224_init rhash_sha3_224_init
43
#define rhash_keccak_256_init rhash_sha3_256_init
44
#define rhash_keccak_384_init rhash_sha3_384_init
45
#define rhash_keccak_512_init rhash_sha3_512_init
46
#define rhash_keccak_update rhash_sha3_update
47
void rhash_keccak_final(sha3_ctx* ctx, unsigned char* result);
48
#endif
49
50
#ifdef __cplusplus
51
} /* extern "C" */
52
#endif /* __cplusplus */
53
54
#endif /* RHASH_SHA3_H */
55
56