From 05120773d97c4c963d5c106993e4083ca19a47e4 Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Wed, 26 Sep 2018 10:30:08 +0800 Subject: [PATCH] sha1: error on big endian platform Signed-off-by: Jianhui Zhao --- src/sha1.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/sha1.c b/src/sha1.c index 48d9f32..0507954 100644 --- a/src/sha1.c +++ b/src/sha1.c @@ -20,6 +20,7 @@ */ #include +#include #include "sha1.h" @@ -32,10 +33,8 @@ union char64long16 { static uint32_t blk0(union char64long16 *block, int i) { - /* Forrest: SHA expect BIG_ENDIAN, swap if LITTLE_ENDIAN */ -#if BYTE_ORDER == LITTLE_ENDIAN - block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) | (rol(block->l[i], 8) & 0x00FF00FF); -#endif + /* Forrest: SHA expect big endian */ + block->l[i] = htonl(block->l[i]); return block->l[i]; }