diff options
author | dimitri staessens <[email protected]> | 2017-08-09 19:41:57 +0000 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-08-09 19:41:57 +0000 |
commit | afc4342532225fb86d11729ddb783095cb62686a (patch) | |
tree | 58ef8a40142323771eecbd8ce6c2eaea409bc138 /src/lib/hash.c | |
parent | c1d7ff1e1bd44e1a38af8a1b498c68f3378fa342 (diff) | |
parent | 24aa46946349529bf36d3569796a28917d3e756f (diff) | |
download | ouroboros-afc4342532225fb86d11729ddb783095cb62686a.tar.gz ouroboros-afc4342532225fb86d11729ddb783095cb62686a.zip |
Merged in dstaesse/ouroboros/be-libgcrypt (pull request #544)
build, lib, ipcpd, irmd: Add support for libgcrypt
Diffstat (limited to 'src/lib/hash.c')
-rw-r--r-- | src/lib/hash.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/hash.c b/src/lib/hash.c index 9db3a276..088d43cd 100644 --- a/src/lib/hash.c +++ b/src/lib/hash.c @@ -27,12 +27,22 @@ #include <ouroboros/config.h> #include <ouroboros/hash.h> +#ifndef HAVE_LIBGCRYPT +#include <ouroboros/crc32.h> +#include <ouroboros/md5.h> +#include <ouroboros/sha3.h> +#else +#include <gcrypt.h> +#endif #include <string.h> #include <assert.h> #include <stdbool.h> uint16_t hash_len(enum hash_algo algo) { +#ifdef HAVE_LIBGCRYPT + return (uint16_t) gcry_md_get_algo_dlen(algo); +#else switch (algo) { case HASH_CRC32: return CRC32_HASH_LEN; @@ -52,12 +62,16 @@ uint16_t hash_len(enum hash_algo algo) } return 0; +#endif } void str_hash(enum hash_algo algo, void * buf, const char * str) { +#ifdef HAVE_LIBGCRYPT + gcry_md_hash_buffer(algo, buf, str, strlen(str)); +#else struct sha3_ctx sha3_ctx; struct md5_ctx md5_ctx; @@ -95,4 +109,5 @@ void str_hash(enum hash_algo algo, assert(false); break; } +#endif } |