There are several places where the rotation yields garbage according to ANSI
C definition when called with 0 bit position argument.

diff -Pur linux_reference/drivers/char/random.c linux/drivers/char/random.c
--- linux_reference/drivers/char/random.c       Wed Jul 19 00:58:13 2000
+++ linux/drivers/char/random.c Sun Dec 17 22:42:59 2000
@@ -411,7 +411,7 @@
 #if (!defined (__i386__))
 extern inline __u32 rotate_left(int i, __u32 word)
 {
-       return (word << i) | (word >> (32 - i));
+       return (word << i) | (word >> ((-i)&31));
        
 }
 #else
@@ -857,7 +857,7 @@
 #define K3  0x8F1BBCDCL                        /* Rounds 40-59: sqrt(5) * 2^30 */
 #define K4  0xCA62C1D6L                        /* Rounds 60-79: sqrt(10) * 2^30 */
 
-#define ROTL(n,X)  ( ( ( X ) << n ) | ( ( X ) >> ( 32 - n ) ) )
+#define ROTL(n,X)  ( ( ( X ) << n ) | ( ( X ) >> ( (- n)&31 ) ) )
 
 #define subRound(a, b, c, d, e, f, k, data) \
     ( e += ROTL( 5, a ) + f( b, c, d ) + k + data, b = ROTL( 30, b ) )
@@ -1087,7 +1087,7 @@
 
 /* This is the central step in the MD5 algorithm. */
 #define MD5STEP(f, w, x, y, z, data, s) \
-       ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
+       ( w += f(x, y, z) + data,  w = w<<s | w>>((-s)&31),  w += x )
 
 /*
  * The core of the MD5 algorithm, this alters an existing MD5 hash to
@@ -1883,7 +1883,7 @@
  * Rotation is separate from addition to prevent recomputation
  */
 #define ROUND(f, a, b, c, d, x, s)     \
-       (a += f(b, c, d) + x, a = (a << s) | (a >> (32-s)))
+       (a += f(b, c, d) + x, a = (a << s) | (a >> ((-s)&31)))
 #define K1 0
 #define K2 013240474631UL
 #define K3 015666365641UL

 Clock

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/

Reply via email to