summaryrefslogtreecommitdiff
path: root/include/ouroboros/hash.h
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-06-04 18:31:07 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-06-04 18:54:45 +0200
commitea1248d40a0c68f3e6cf09d03354f7a5fc6e2612 (patch)
treecd13756e810c77dd36bedecf2a76058d6e3af4b8 /include/ouroboros/hash.h
parent51aac5614ccd7928ba23af0cca0e94010f3fcebc (diff)
downloadouroboros-ea1248d40a0c68f3e6cf09d03354f7a5fc6e2612.tar.gz
ouroboros-ea1248d40a0c68f3e6cf09d03354f7a5fc6e2612.zip
include: Fix macro for printing hash
Diffstat (limited to 'include/ouroboros/hash.h')
-rw-r--r--include/ouroboros/hash.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/include/ouroboros/hash.h b/include/ouroboros/hash.h
index de3ce541..eeca8a28 100644
--- a/include/ouroboros/hash.h
+++ b/include/ouroboros/hash.h
@@ -24,6 +24,7 @@
#ifndef OUROBOROS_LIB_HASH_H
#define OUROBOROS_LIB_HASH_H
+#include <ouroboros/endian.h>
#include <ouroboros/ipcp.h>
#include <ouroboros/crc32.h>
@@ -32,11 +33,11 @@
#define HASH_FMT "%02x%02x%02x%02x"
-#define HASH_VAL(hash) \
- ((*(unsigned int *) hash) & 0xFF000000) >> 24, \
- ((*(unsigned int *) hash) & 0x00FF0000) >> 16, \
- ((*(unsigned int *) hash) & 0x0000FF00) >> 8, \
- ((*(unsigned int *) hash) & 0x000000FF)
+#define HASH_VAL(hash) \
+ (betoh32(*(uint32_t *) hash) & 0xFF000000) >> 24, \
+ (betoh32(*(uint32_t *) hash) & 0x00FF0000) >> 16, \
+ (betoh32(*(uint32_t *) hash) & 0x0000FF00) >> 8, \
+ (betoh32(*(uint32_t *) hash) & 0x000000FF)
uint16_t hash_len(enum hash_algo algo);