diff lib/sha1.c @ 26475:61306c7a6237

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 3655e550b688
children caee82d64491
line wrap: on
line diff
--- a/lib/sha1.c	Thu May 11 06:36:07 2006 +0000
+++ b/lib/sha1.c	Thu May 11 07:33:27 2006 +0000
@@ -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] \