diff options
author | Brad King <brad.king@kitware.com> | 2016-11-10 20:42:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-11-10 20:42:32 (GMT) |
commit | 87584b5e9d4bb3147de4ad2adac2d337be456a62 (patch) | |
tree | f7e0486e4cd089014b572e801ea338fab877adbf /Utilities/cmlibrhash/librhash/sha3.h | |
parent | c50c32a30f434613a0a46b1c7dbb7eb03d29896d (diff) | |
parent | 7fcbd47e955d7e318f1f6dd96cc26d6737525c86 (diff) | |
download | CMake-87584b5e9d4bb3147de4ad2adac2d337be456a62.zip CMake-87584b5e9d4bb3147de4ad2adac2d337be456a62.tar.gz CMake-87584b5e9d4bb3147de4ad2adac2d337be456a62.tar.bz2 |
Merge branch 'upstream-librhash' into add-SHA-3
* upstream-librhash:
librhash 2016-11-06 (de79828d)
Diffstat (limited to 'Utilities/cmlibrhash/librhash/sha3.h')
-rw-r--r-- | Utilities/cmlibrhash/librhash/sha3.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Utilities/cmlibrhash/librhash/sha3.h b/Utilities/cmlibrhash/librhash/sha3.h new file mode 100644 index 0000000..2831997 --- /dev/null +++ b/Utilities/cmlibrhash/librhash/sha3.h @@ -0,0 +1,54 @@ +/* sha3.h */ +#ifndef RHASH_SHA3_H +#define RHASH_SHA3_H +#include "ustd.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define sha3_224_hash_size 28 +#define sha3_256_hash_size 32 +#define sha3_384_hash_size 48 +#define sha3_512_hash_size 64 +#define sha3_max_permutation_size 25 +#define sha3_max_rate_in_qwords 24 + +/** + * SHA3 Algorithm context. + */ +typedef struct sha3_ctx +{ + /* 1600 bits algorithm hashing state */ + uint64_t hash[sha3_max_permutation_size]; + /* 1536-bit buffer for leftovers */ + uint64_t message[sha3_max_rate_in_qwords]; + /* count of bytes in the message[] buffer */ + unsigned rest; + /* size of a message block processed at once */ + unsigned block_size; +} sha3_ctx; + +/* methods for calculating the hash function */ + +void rhash_sha3_224_init(sha3_ctx *ctx); +void rhash_sha3_256_init(sha3_ctx *ctx); +void rhash_sha3_384_init(sha3_ctx *ctx); +void rhash_sha3_512_init(sha3_ctx *ctx); +void rhash_sha3_update(sha3_ctx *ctx, const unsigned char* msg, size_t size); +void rhash_sha3_final(sha3_ctx *ctx, unsigned char* result); + +#ifdef USE_KECCAK +#define rhash_keccak_224_init rhash_sha3_224_init +#define rhash_keccak_256_init rhash_sha3_256_init +#define rhash_keccak_384_init rhash_sha3_384_init +#define rhash_keccak_512_init rhash_sha3_512_init +#define rhash_keccak_update rhash_sha3_update +void rhash_keccak_final(sha3_ctx *ctx, unsigned char* result); +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* RHASH_SHA3_H */ |