[LEDE-DEV] [PATCH opkg] libopkg: fix SHA256 calculation for big endian system

Jonas Gorski jonas.gorski at gmail.com
Sat Nov 18 04:25:52 PST 2017


The SHA256 implementation relied on WORDS_BIGENDIAN being defined for
big endian systems, but this was never done. This caused it to produce
wrong checksums on those systems.

Fix this by replacing the check with a generic check for big endian byte
order.

Fixes: 84552e64fa6d ("Adding sha256.[ch] Sorry forgot adding them. Thanks for Graham Gower <graham.gower at gmail.com>")
Signed-off-by: Jonas Gorski <jonas.gorski at gmail.com>
---
 libopkg/sha256.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libopkg/sha256.c b/libopkg/sha256.c
index e0c4e3e0d423..5848799c0260 100644
--- a/libopkg/sha256.c
+++ b/libopkg/sha256.c
@@ -30,7 +30,7 @@
 #include "unlocked-io.h"
 #endif
 
-#ifdef WORDS_BIGENDIAN
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 #define SWAP(n) (n)
 #else
 #define SWAP(n) \
-- 
2.13.2




More information about the Lede-dev mailing list