- fix code to not modify the const buffer (grrr...)
authorMichael Schroeder <mls@suse.de>
Thu, 2 Jul 2009 16:26:04 +0000 (18:26 +0200)
committerMichael Schroeder <mls@suse.de>
Thu, 2 Jul 2009 16:26:04 +0000 (18:26 +0200)
src/sha1.c

index 74262a9..52f74d9 100644 (file)
@@ -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];