summaryrefslogtreecommitdiff
path: root/src/lib/hash.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2024-02-19 16:05:59 +0100
committerSander Vrijders <sander@ouroboros.rocks>2024-02-19 16:06:34 +0100
commitc58cc09cf50a18058efb59e1b4fb73ab1e3a45a2 (patch)
tree7674e6939fc30eb3b052686ea2ee95bde3580bca /src/lib/hash.c
parentd2556ebc3fbc59736863e53f5b2c35e72eb09ae8 (diff)
downloadouroboros-c58cc09cf50a18058efb59e1b4fb73ab1e3a45a2.tar.gz
ouroboros-c58cc09cf50a18058efb59e1b4fb73ab1e3a45a2.zip
lib: Fix CRC32 hashing0.21.1
I assumed that all hashes were stored in Big Endian, but apparently the CRC32 was still in machine endianness when calculated by the rhash implementation. Fixed and updated hash tests a bit. 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.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/lib/hash.c b/src/lib/hash.c
index 995ba0d2..b465f894 100644
--- a/src/lib/hash.c
+++ b/src/lib/hash.c
@@ -29,6 +29,7 @@
#include "config.h"
+#include <ouroboros/endian.h>
#include <ouroboros/hash.h>
#ifdef HAVE_LIBGCRYPT
@@ -90,6 +91,7 @@ void mem_hash(enum hash_algo algo,
case HASH_CRC32:
memset(dst, 0, CRC32_HASH_LEN);
crc32((uint32_t *) dst, buf, len);
+ *(uint32_t *) dst = htobe32(*(uint32_t *) dst);
break;
case HASH_MD5:
rhash_md5_init(&md5_ctx);