Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/gen discard first 256 words when we stir.
details: https://anonhg.NetBSD.org/src/rev/b607b2c08c85
branches: trunk
changeset: 532748:b607b2c08c85
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Jun 14 03:11:24 2002 +0000
description:
discard first 256 words when we stir.
diffstat:
lib/libc/gen/arc4random.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diffs (32 lines):
diff -r b7c50b2a9e1d -r b607b2c08c85 lib/libc/gen/arc4random.c
--- a/lib/libc/gen/arc4random.c Fri Jun 14 03:05:46 2002 +0000
+++ b/lib/libc/gen/arc4random.c Fri Jun 14 03:11:24 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arc4random.c,v 1.2 2002/05/24 04:53:07 itojun Exp $ */
+/* $NetBSD: arc4random.c,v 1.3 2002/06/14 03:11:24 itojun Exp $ */
/* $OpenBSD: arc4random.c,v 1.6 2001/06/05 05:05:38 pvalchev Exp $ */
/*
@@ -95,6 +95,7 @@
struct timeval tv;
u_int rnd[(128 - sizeof(struct timeval)) / sizeof(u_int)];
} rdat;
+ int n;
gettimeofday(&rdat.tv, NULL);
fd = open("/dev/urandom", O_RDONLY);
@@ -124,6 +125,14 @@
* whatever was on the stack... */
arc4_addrandom(as, (void *) &rdat, sizeof(rdat));
+
+ /*
+ * Throw away the first N words of output, as suggested in the
+ * paper "Weaknesses in the Key Scheduling Algorithm of RC4"
+ * by Fluher, Mantin, and Shamir. (N = 256 in our case.)
+ */
+ for (n = 0; n < 256 * 4; n++)
+ arc4_getbyte(as);
}
static inline u_int8_t
Home |
Main Index |
Thread Index |
Old Index