X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fsha.c;h=a75b8cf8977e6ce60f9cad21feed2fd17b0d68f7;hb=60183d858937837c14bd8a56efc4dde0a36335d6;hp=60260ac5013d95a1c7ddf591c2ac051d2ff2ac14;hpb=f7aee7431e94dcef216d52c775e006bb57471968;p=gnulib.git diff --git a/lib/sha.c b/lib/sha.c index 60260ac50..a75b8cf89 100644 --- a/lib/sha.c +++ b/lib/sha.c @@ -1,7 +1,7 @@ /* sha.c - Functions to compute the SHA1 hash (message-digest) of files or blocks of memory. Complies to the NIST specification FIPS-180-1. - Copyright (C) 2000 Scott G. Miller + Copyright (C) 2000, 2001 Scott G. Miller Credits: Robert Klep -- Expansion function fix @@ -24,6 +24,7 @@ #include "md5.h" #include "sha.h" +#include "unlocked-io.h" /* Not-swap is a macro that does an endian swap on architectures that are @@ -241,7 +242,8 @@ sha_process_bytes (const void *buffer, size_t len, struct sha_ctx *ctx) #define F4(B,C,D) (B ^ C ^ D) /* Process LEN bytes of BUFFER, accumulating context into CTX. - It is assumed that LEN % 64 == 0. */ + It is assumed that LEN % 64 == 0. + Most of this code comes from GnuPG's cipher/sha1.c. */ void sha_process_block (const void *buffer, size_t len, struct sha_ctx *ctx) @@ -265,7 +267,7 @@ sha_process_block (const void *buffer, size_t len, struct sha_ctx *ctx) #define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \ ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \ - , (x[I&0x0f] = (tm << 1) | (tm >> 31)) ) + , (x[I&0x0f] = rol(tm, 1)) ) #define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \ + F( B, C, D ) \ @@ -278,6 +280,7 @@ sha_process_block (const void *buffer, size_t len, struct sha_ctx *ctx) { md5_uint32 tm; int t; + /* FIXME: see sha1.c for a better implementation. */ for (t = 0; t < 16; t++) { x[t] = NOTSWAP (*words);