Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Utilities/cmlibrhash/librhash/sha256.h
3150 views
1
/* sha.h sha256 and sha224 hash functions */
2
#ifndef SHA256_H
3
#define SHA256_H
4
#include "ustd.h"
5
6
#ifdef __cplusplus
7
extern "C" {
8
#endif
9
10
#define sha256_block_size 64
11
#define sha256_hash_size 32
12
#define sha224_hash_size 28
13
14
/* algorithm context */
15
typedef struct sha256_ctx
16
{
17
unsigned message[16]; /* 512-bit buffer for leftovers */
18
uint64_t length; /* number of processed bytes */
19
unsigned hash[8]; /* 256-bit algorithm internal hashing state */
20
unsigned digest_length; /* length of the algorithm digest in bytes */
21
} sha256_ctx;
22
23
void rhash_sha224_init(sha256_ctx* ctx);
24
void rhash_sha256_init(sha256_ctx* ctx);
25
void rhash_sha256_update(sha256_ctx* ctx, const unsigned char* data, size_t length);
26
void rhash_sha256_final(sha256_ctx* ctx, unsigned char* result);
27
28
#ifdef __cplusplus
29
} /* extern "C" */
30
#endif /* __cplusplus */
31
32
#endif /* SHA256_H */
33
34