Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/gen arc4 is a random number sequence, there is no p...



details:   https://anonhg.NetBSD.org/src/rev/67ed1720be99
branches:  trunk
changeset: 781122:67ed1720be99
user:      dsl <dsl%NetBSD.org@localhost>
date:      Mon Aug 20 20:32:09 2012 +0000

description:
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.

diffstat:

 lib/libc/gen/arc4random.c |  12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diffs (47 lines):

diff -r 6f9a6c55f726 -r 67ed1720be99 lib/libc/gen/arc4random.c
--- a/lib/libc/gen/arc4random.c Mon Aug 20 20:27:46 2012 +0000
+++ b/lib/libc/gen/arc4random.c Mon Aug 20 20:32:09 2012 +0000
@@ -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 @@
        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 @@
        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 @@
        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



Home | Main Index | Thread Index | Old Index