Module Name:    src
Committed By:   dsl
Date:           Mon Aug 20 20:32:09 UTC 2012

Modified Files:
        src/lib/libc/gen: arc4random.c

Log Message:
arc4 is a random number sequence, there is no point using its own
output values to determine a number of output values to skip.
Skipping values on any possibly random event might be worth while, as
  might using the keying algorithm to stir in a possibly random value.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/lib/libc/gen/arc4random.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gen/arc4random.c
diff -u src/lib/libc/gen/arc4random.c:1.18 src/lib/libc/gen/arc4random.c:1.19
--- src/lib/libc/gen/arc4random.c:1.18	Mon Aug 20 20:27:46 2012
+++ src/lib/libc/gen/arc4random.c	Mon Aug 20 20:32:09 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: arc4random.c,v 1.18 2012/08/20 20:27:46 dsl Exp $	*/
+/*	$NetBSD: arc4random.c,v 1.19 2012/08/20 20:32:09 dsl Exp $	*/
 /*	$OpenBSD: arc4random.c,v 1.6 2001/06/05 05:05:38 pvalchev Exp $	*/
 
 /*
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: arc4random.c,v 1.18 2012/08/20 20:27:46 dsl Exp $");
+__RCSID("$NetBSD: arc4random.c,v 1.19 2012/08/20 20:32:09 dsl Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -214,7 +214,6 @@ arc4random_buf(void *buf, size_t len)
 	uint8_t *bp = buf;
 	uint8_t *ep = bp + len;
 	uint8_t i, j;
-	int skip;
 
 	LOCK(&rs);
 	arc4_check_init(&rs);
@@ -223,10 +222,6 @@ arc4random_buf(void *buf, size_t len)
 	i = rs.i;
 	j = rs.j;
 
-	skip = arc4_getbyte_ij(&rs, &i, &j) % 3;
-	while (skip--)
-		(void)arc4_getbyte_ij(&rs, &i, &j);
-
 	while (bp < ep)
 		*bp++ = arc4_getbyte_ij(&rs, &i, &j);
 	rs.i = i;
@@ -266,9 +261,6 @@ arc4random_uniform(uint32_t upper_bound)
 	LOCK(&rs);
 	arc4_check_init(&rs);
 
-	if (arc4_getbyte(&rs) & 1)
-		(void)arc4_getbyte(&rs);
-
 	/*
 	 * This could theoretically loop forever but each retry has
 	 * p > 0.5 (worst case, usually far better) of selecting a

Reply via email to