X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fsec%2Fhash%2Fsha1.c;fp=bertos%2Fsec%2Fhash%2Fsha1.c;h=d9dc5c860764cf5b3fc080263e320c4b40342db2;hb=cbdcd1b3a571389f3c24295d2eb0a53bef08e7fa;hp=4333689e379cb22508c38000643eb71c60353428;hpb=2f8a515c8a7147b8e6cf6ab643bb275d73b030dd;p=bertos.git diff --git a/bertos/sec/hash/sha1.c b/bertos/sec/hash/sha1.c index 4333689e..d9dc5c86 100644 --- a/bertos/sec/hash/sha1.c +++ b/bertos/sec/hash/sha1.c @@ -63,9 +63,9 @@ static void SHA1Transform(uint32_t state[5], const uint8_t buffer[64]); /* blk0() and blk() perform the initial expand. */ /* I got the idea of expanding during the round function from SSLeay */ -#define blk0(i) (block->l[i] = be32_to_cpu(block->l[i])) -#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 blk0(i) (block[i] = be32_to_cpu(block[i])) +#define blk(i) (block[i&15] = rol(block[(i+13)&15]^block[(i+8)&15] \ + ^block[(i+2)&15]^block[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); @@ -76,18 +76,12 @@ static void SHA1Transform(uint32_t state[5], const uint8_t buffer[64]); /* Hash a single 512-bit block. This is the core of the algorithm. */ -typedef union { - uint8_t c[64]; - uint32_t l[16]; -} CHAR64LONG16; -static CHAR64LONG16 workspace; - static void SHA1Transform(uint32_t state[5], const uint8_t buffer[64]) { uint32_t a, b, c, d, e; + uint32_t block[16]; - CHAR64LONG16* block = &workspace; - memcpy(block, buffer, 64); + memcpy(&block, buffer, 64); /* Copy context->state[] to working vars */ a = state[0];