From: Karel Kulhavy <clock@atrey.karlin.mff.cuni.cz>
To: linux-kernel@vger.kernel.org
Subject: random.c patch
Date: Sun, 17 Dec 2000 22:44:52 +0100 [thread overview]
Message-ID: <20001217224452.A8635@atrey.karlin.mff.cuni.cz> (raw)
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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
next reply other threads:[~2000-12-17 22:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-12-17 21:44 Karel Kulhavy [this message]
2000-12-18 1:08 ` random.c patch Sandy Harris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20001217224452.A8635@atrey.karlin.mff.cuni.cz \
--to=clock@atrey.karlin.mff.cuni.cz \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).