summaryrefslogtreecommitdiff
path: root/src/lib/hash.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2026-05-24 10:21:16 +0200
committerSander Vrijders <sander@ouroboros.rocks>2026-05-27 15:54:57 +0200
commit8ee68491daad630f5cd9168852f974633ce5ffd4 (patch)
tree1c58230728d852e5fd1ffbe54fc6f2bf7d75d5f3 /src/lib/hash.c
parent5d0cf67a38695ebe65a0506b5c6d6c0d229a3b3e (diff)
downloadouroboros-8ee68491daad630f5cd9168852f974633ce5ffd4.tar.gz
ouroboros-8ee68491daad630f5cd9168852f974633ce5ffd4.zip
lib: Fix mixed declarations in hash.c
The contexts are not declared at the top of the function anymore after addition of the CRC8/CRC16 variants (no implementation in libgcrypt). Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/hash.c')
-rw-r--r--src/lib/hash.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/hash.c b/src/lib/hash.c
index 7ffa5bc1..62bbf2b8 100644
--- a/src/lib/hash.c
+++ b/src/lib/hash.c
@@ -90,6 +90,10 @@ void mem_hash(enum hash_algo algo,
const uint8_t * buf,
size_t len)
{
+#ifndef HAVE_LIBGCRYPT
+ struct sha3_ctx sha3_ctx;
+ struct md5_ctx md5_ctx;
+#endif
if (algo == HASH_CRC8) {
uint8_t crc = 0;
@@ -114,9 +118,6 @@ void mem_hash(enum hash_algo algo,
#ifdef HAVE_LIBGCRYPT
gcry_md_hash_buffer(gcry_algo_tbl[algo], dst, buf, len);
#else
- struct sha3_ctx sha3_ctx;
- struct md5_ctx md5_ctx;
-
switch (algo) {
case HASH_CRC32:
memset(dst, 0, CRC32_HASH_LEN);