summaryrefslogtreecommitdiffstats
path: root/Utilities/cmlibrhash/librhash/sha256.h
blob: 3625cfe202923fa52dd32eeaf9a67a3bc87793c4 (plain)
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
/* sha.h sha256 and sha224 hash functions */
#ifndef SHA256_H
#define SHA256_H
#include "ustd.h"

#ifdef __cplusplus
extern "C" {
#endif

#define sha256_block_size 64
#define sha256_hash_size  32
#define sha224_hash_size  28

/* algorithm context */
typedef struct sha256_ctx
{
	unsigned message[16];   /* 512-bit buffer for leftovers */
	uint64_t length;        /* number of processed bytes */
	unsigned hash[8];       /* 256-bit algorithm internal hashing state */
	unsigned digest_length; /* length of the algorithm digest in bytes */
} sha256_ctx;

void rhash_sha224_init(sha256_ctx* ctx);
void rhash_sha256_init(sha256_ctx* ctx);
void rhash_sha256_update(sha256_ctx* ctx, const unsigned char* data, size_t length);
void rhash_sha256_final(sha256_ctx* ctx, unsigned char result[32]);

#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */

#endif /* SHA256_H */