From 85d6717244448ab181ea74b4b4e9b2be9727b557 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Thu, 2 Jul 2009 18:26:04 +0200 Subject: [PATCH] - fix code to not modify the const buffer (grrr...) --- src/sha1.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sha1.c b/src/sha1.c index 74262a9..52f74d9 100644 --- a/src/sha1.c +++ b/src/sha1.c @@ -90,13 +90,13 @@ static void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64]); /* I got the idea of expanding during the round function from SSLeay */ /* FIXME: can we do this in an endian-proof way? */ #if __BYTE_ORDER == __BIG_ENDIAN -#define blk0(i) block->l[i] +#define blk0(i) block.l[i] #else -#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ - |(rol(block->l[i],8)&0x00FF00FF)) +#define blk0(i) (block.l[i] = (rol(block.l[i],24)&0xFF00FF00) \ + |(rol(block.l[i],8)&0x00FF00FF)) #endif -#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ - ^block->l[(i+2)&15]^block->l[i&15],1)) +#define blk(i) (block.l[i&15] = rol(block.l[(i+13)&15]^block.l[(i+8)&15] \ + ^block.l[(i+2)&15]^block.l[i&15],1)) /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); @@ -114,9 +114,9 @@ static void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64]) uint8_t c[64]; uint32_t l[16]; } CHAR64LONG16; - CHAR64LONG16* block; + CHAR64LONG16 block; - block = (CHAR64LONG16*)buffer; + memcpy(&block, buffer, 64); /* Copy context->state[] to working vars */ a = state[0]; -- 2.7.4