Skip to content

Commit

Permalink
sha1: error on big endian platform
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
  • Loading branch information
Jianhui Zhao committed Sep 26, 2018
1 parent 4cd51be commit 0512077
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/sha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

#include <string.h>
#include <arpa/inet.h>

#include "sha1.h"

Expand All @@ -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];
}

Expand Down

0 comments on commit 0512077

Please sign in to comment.