X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Flibsha1.c;h=aaaa4eb2fc14225aad9032b66097008d9390e07a;hp=c39a5a174b9c9ea4bf5369ce7fe9af27cf1d52b6;hb=8fb16e277e4d6c32bafa79ae7967e1e6ba9258e0;hpb=8cbb5114a20c1217f23977fd5edca99a0b7a2955 diff --git a/lib/libsha1.c b/lib/libsha1.c index c39a5a17..aaaa4eb2 100644 --- a/lib/libsha1.c +++ b/lib/libsha1.c @@ -34,7 +34,7 @@ */ #include /* for memcpy() etc. */ - +#include "endian-util.h" #include "libsha1.h" #if defined(__cplusplus) @@ -49,11 +49,13 @@ extern "C" #define bswap_32(x) ((rotr32((x), 24) & 0x00ff00ff) | (rotr32((x), 8) & 0xff00ff00)) -#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) -#define bsw_32(p,n) \ - { int _i = (n); while(_i--) ((uint32_t*)p)[_i] = bswap_32(((uint32_t*)p)[_i]); } +#if (UTIL_BYTE_ORDER == UTIL_ORDER_LITTLE_ENDIAN) +# define bsw_32(p,n) \ + { int _i = (n); while(_i--) ((uint32_t*)p)[_i] = bswap_32(((uint32_t*)p)[_i]); } +#elif (UTIL_BYTE_ORDER == UTIL_ORDER_BIG_ENDIAN) +# define bsw_32(p,n) #else -#define bsw_32(p,n) +# error "Unsupported byte order" #endif #define SHA1_MASK (SHA1_BLOCK_SIZE - 1) @@ -174,7 +176,7 @@ void sha1_hash(const unsigned char data[], unsigned long len, sha1_ctx ctx[1]) if((ctx->count[0] += len) < len) ++(ctx->count[1]); - while(len >= space) /* tranfer whole blocks if possible */ + while(len >= space) /* transfer whole blocks if possible */ { memcpy(((unsigned char*)ctx->wbuf) + pos, sp, space); sp += space; len -= space; space = SHA1_BLOCK_SIZE; pos = 0;