bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: test failures: crc, md4, gc-md4


From: Paul Eggert
Subject: Re: test failures: crc, md4, gc-md4
Date: Wed, 10 May 2006 22:59:25 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Simon Josefsson <address@hidden> writes:

> -#define K1 0x5a827999L
> -#define K2 0x6ed9eba1L
> +#define K1 0x5a827999
> +#define K2 0x6ed9eba1

That fixes the bug on hosts where int is 32 bits and long is 64 bits,
but if I understand the problem you found, then surely the bug remains
on hosts where int and long are both 64 bits.

How about this further fix?

2006-05-10  Paul Eggert  <address@hidden>

        * 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.

Index: lib/crc.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/crc.c,v
retrieving revision 1.2
diff -p -u -r1.2 crc.c
--- lib/crc.c   21 Oct 2005 12:39:10 -0000      1.2
+++ lib/crc.c   11 May 2006 05:55:47 -0000
@@ -97,7 +97,7 @@ crc32_no_xor (const char *buf, size_t le
 uint32_t
 crc32_update (uint32_t crc, const char *buf, size_t len)
 {
-  return crc32_update_no_xor (crc ^ 0xffffffffL, buf, len) ^ 0xffffffffL;
+  return crc32_update_no_xor (crc ^ 0xffffffff, buf, len) ^ 0xffffffff;
 }
 
 uint32_t
Index: lib/md4.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/md4.c,v
retrieving revision 1.5
diff -p -u -r1.5 md4.c
--- lib/md4.c   10 May 2006 13:37:20 -0000      1.5
+++ lib/md4.c   11 May 2006 05:55:47 -0000
@@ -280,7 +280,7 @@ md4_process_bytes (const void *buffer, s
 #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);
Index: lib/sha1.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/sha1.c,v
retrieving revision 1.7
diff -p -u -r1.7 sha1.c
--- lib/sha1.c  12 Jan 2006 05:40:19 -0000      1.7
+++ lib/sha1.c  11 May 2006 05:55:47 -0000
@@ -270,10 +270,10 @@ sha1_process_bytes (const void *buffer, 
 /* --- 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 @@ sha1_process_block (const void *buffer, 
   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] \




reply via email to

[Prev in Thread] Current Thread [Next in Thread]