diff options
author | librhash upstream <kwrobot@kitware.com> | 2016-11-01 15:21:09 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-11-03 17:45:28 (GMT) |
commit | 1367fccc330b0ff314845aeb3547bbc38486913a (patch) | |
tree | a380e9ace4e3770a2c616bb3b162e2d18f722575 /librhash/sha256.h | |
download | CMake-1367fccc330b0ff314845aeb3547bbc38486913a.zip CMake-1367fccc330b0ff314845aeb3547bbc38486913a.tar.gz CMake-1367fccc330b0ff314845aeb3547bbc38486913a.tar.bz2 |
librhash 2016-11-01 (d839a1a8)
Code extracted from:
https://github.com/rhash/rhash.git
at commit d839a1a853f22b8cfd26c2006ee5481739ea1114 (master).
Diffstat (limited to 'librhash/sha256.h')
-rw-r--r-- | librhash/sha256.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/librhash/sha256.h b/librhash/sha256.h new file mode 100644 index 0000000..f87ebaa --- /dev/null +++ b/librhash/sha256.h @@ -0,0 +1,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 */ |