X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/6bb16603e80a4771db61e2a984a0c277bd6339d7..88ea89339783ee587180b645981967f6cb8bcd20:/sshsh512.c diff --git a/sshsh512.c b/sshsh512.c index a2dd0c0b..8d0b1ae3 100644 --- a/sshsh512.c +++ b/sshsh512.c @@ -13,14 +13,14 @@ * overlap destination with one source, but the others can't. */ #define add(r,x,y) ( r.lo = y.lo + x.lo, \ - r.hi = y.hi + x.hi + (r.lo < y.lo) ) -#define rorB(r,x,y) ( r.lo = (x.hi >> ((y)-32)) | (x.lo << (64-(y))), \ - r.hi = (x.lo >> ((y)-32)) | (x.hi << (64-(y))) ) -#define rorL(r,x,y) ( r.lo = (x.lo >> (y)) | (x.hi << (32-(y))), \ - r.hi = (x.hi >> (y)) | (x.lo << (32-(y))) ) -#define shrB(r,x,y) ( r.lo = x.hi >> ((y)-32), r.hi = 0 ) -#define shrL(r,x,y) ( r.lo = (x.lo >> (y)) | (x.hi << (32-(y))), \ - r.hi = x.hi >> (y) ) + r.hi = y.hi + x.hi + ((uint32)r.lo < (uint32)y.lo) ) +#define rorB(r,x,y) ( r.lo = ((uint32)x.hi >> ((y)-32)) | ((uint32)x.lo << (64-(y))), \ + r.hi = ((uint32)x.lo >> ((y)-32)) | ((uint32)x.hi << (64-(y))) ) +#define rorL(r,x,y) ( r.lo = ((uint32)x.lo >> (y)) | ((uint32)x.hi << (32-(y))), \ + r.hi = ((uint32)x.hi >> (y)) | ((uint32)x.lo << (32-(y))) ) +#define shrB(r,x,y) ( r.lo = (uint32)x.hi >> ((y)-32), r.hi = 0 ) +#define shrL(r,x,y) ( r.lo = ((uint32)x.lo >> (y)) | ((uint32)x.hi << (32-(y))), \ + r.hi = (uint32)x.hi >> (y) ) #define and(r,x,y) ( r.lo = x.lo & y.lo, r.hi = x.hi & y.hi ) #define xor(r,x,y) ( r.lo = x.lo ^ y.lo, r.hi = x.hi ^ y.hi ) #define not(r,x) ( r.lo = ~x.lo, r.hi = ~x.hi ) @@ -45,7 +45,7 @@ #define smallsigma1(r,t,x) ( rorL(r,x,19), rorB(t,x,61), xor(r,r,t), \ shrL(t,x,6), xor(r,r,t) ) -void SHA512_Core_Init(SHA512_State *s) { +static void SHA512_Core_Init(SHA512_State *s) { static const uint64 iv[] = { INIT(0x6a09e667, 0xf3bcc908), INIT(0xbb67ae85, 0x84caa73b), @@ -61,7 +61,7 @@ void SHA512_Core_Init(SHA512_State *s) { s->h[i] = iv[i]; } -void SHA512_Block(SHA512_State *s, uint64 *block) { +static void SHA512_Block(SHA512_State *s, uint64 *block) { uint64 w[80]; uint64 a,b,c,d,e,f,g,h; static const uint64 k[] = {