1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#ifndef SHA2_H_
#define SHA2_H_
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <stdint.h> // uint32_t, uint8_t
#include <stddef.h> // size_t
#define SHA256_HASH_SIZE 32
typedef struct {
uint8_t buf[64];
uint32_t h[8];
uint64_t num_bytes;
} sha256_t;
void sha256_init(sha256_t * const);
void sha256_push(sha256_t * const, const void *, size_t);
void sha256_fini(sha256_t * const, void * const);
void sha256(const void * const restrict, const size_t, void * const restrict);
#define SHA224_HASH_SIZE 28
typedef struct {
sha256_t ctx;
} sha224_t;
void sha224_init(sha224_t * const);
void sha224_push(sha224_t * const, const void *, size_t);
void sha224_fini(sha224_t * const, void * const);
void sha224(const void * const restrict, const size_t, void * const restrict);
#define SHA512_HASH_SIZE 64
typedef struct {
uint8_t buf[128];
uint64_t h[8];
uint64_t num_bytes_lo,
num_bytes_hi;
} sha512_t;
void sha512_init(sha512_t * const);
void sha512_push(sha512_t * const, const void *, size_t);
void sha512_fini(sha512_t * const, void * const);
void sha512(const void * const restrict, const size_t, void * const restrict);
#define SHA384_HASH_SIZE 48
typedef struct {
sha512_t ctx;
} sha384_t;
void sha384_init(sha384_t * const);
void sha384_push(sha384_t * const, const void *, size_t);
void sha384_fini(sha384_t * const, void * const);
void sha384(const void * const restrict, const size_t, void * restrict const);
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* SHA2_H_ */
|