Mercurial > hg > octave-jordi > gnulib-hg
changeset 6784:fe34cbd2306e
2006-05-10 Paul Eggert <eggert@cs.ucla.edu>
* md4.c (rol): Cast right-shift arg to uint32_t to prevent
unwanted sign propagation, e.g., on hosts with 64-bit int.
There still are some problems with reeelly weird theoretical hosts
(e.g., 33-bit int) but it's not worth worrying about now.
* sha1.c (rol): Likewise.
(K1, K2, K3, K4): Remove unnecessary L suffix.
author | Simon Josefsson <simon@josefsson.org> |
---|---|
date | Thu, 11 May 2006 07:33:27 +0000 |
parents | 5b54872e7e56 |
children | 3d25db2cb5ba |
files | lib/ChangeLog lib/md4.c lib/sha1.c |
diffstat | 3 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,6 +1,12 @@ 2006-05-10 Paul Eggert <eggert@cs.ucla.edu> * crc.c (crc32_update): Remove unnecessary L suffix. + * md4.c (rol): Cast right-shift arg to uint32_t to prevent + unwanted sign propagation, e.g., on hosts with 64-bit int. + There still are some problems with reeelly weird theoretical hosts + (e.g., 33-bit int) but it's not worth worrying about now. + * sha1.c (rol): Likewise. + (K1, K2, K3, K4): Remove unnecessary L suffix. 2006-05-10 Bruno Haible <bruno@clisp.org>
--- a/lib/md4.c +++ b/lib/md4.c @@ -280,7 +280,7 @@ #define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) #define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) #define H(x, y, z) ((x) ^ (y) ^ (z)) -#define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) ) +#define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n)))) #define R1(a,b,c,d,k,s) a=rol(a+F(b,c,d)+x[k],s); #define R2(a,b,c,d,k,s) a=rol(a+G(b,c,d)+x[k]+K1,s); #define R3(a,b,c,d,k,s) a=rol(a+H(b,c,d)+x[k]+K2,s);
--- a/lib/sha1.c +++ b/lib/sha1.c @@ -270,10 +270,10 @@ /* --- Code below is the primary difference between md5.c and sha1.c --- */ /* SHA1 round constants */ -#define K1 0x5a827999L -#define K2 0x6ed9eba1L -#define K3 0x8f1bbcdcL -#define K4 0xca62c1d6L +#define K1 0x5a827999 +#define K2 0x6ed9eba1 +#define K3 0x8f1bbcdc +#define K4 0xca62c1d6 /* Round functions. Note that F2 is the same as F4. */ #define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) ) @@ -305,7 +305,7 @@ if (ctx->total[0] < len) ++ctx->total[1]; -#define rol(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) +#define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n)))) #define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \ ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \