Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/gen "seed2" was ruining the non-repeating property ...



details:   https://anonhg.NetBSD.org/src/rev/cfa222a4aee0
branches:  trunk
changeset: 555698:cfa222a4aee0
user:      itojun <itojun%NetBSD.org@localhost>
date:      Tue Nov 25 18:13:06 2003 +0000

description:
"seed2" was ruining the non-repeating property of this function; remove it.
discussed on tech-net for ip_id.c (thanks for all the analysis).

diffstat:

 lib/libc/gen/randomid.c |  9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diffs (43 lines):

diff -r b880a6d10eb2 -r cfa222a4aee0 lib/libc/gen/randomid.c
--- a/lib/libc/gen/randomid.c   Tue Nov 25 17:09:24 2003 +0000
+++ b/lib/libc/gen/randomid.c   Tue Nov 25 18:13:06 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: randomid.c,v 1.8 2003/09/16 07:56:51 simonb Exp $      */
+/*     $NetBSD: randomid.c,v 1.9 2003/11/25 18:13:06 itojun Exp $      */
 /*     $KAME: ip6_id.c,v 1.8 2003/09/06 13:41:06 itojun Exp $  */
 /*     $OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $       */
 
@@ -88,7 +88,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: randomid.c,v 1.8 2003/09/16 07:56:51 simonb Exp $");
+__RCSID("$NetBSD: randomid.c,v 1.9 2003/11/25 18:13:06 itojun Exp $");
 #endif
 
 #include "namespace.h"
@@ -130,7 +130,7 @@
        u_int32_t ru_msb;
 
        u_int32_t ru_x;
-       u_int32_t ru_seed, ru_seed2;
+       u_int32_t ru_seed;
        u_int32_t ru_a, ru_b;
        u_int32_t ru_g;
        long ru_reseed;
@@ -218,7 +218,6 @@
 
        /* (bits - 1) bits of random seed */
        p->ru_seed = arc4random() & (~0U >> (32 - p->ru_bits + 1));
-       p->ru_seed2 = arc4random() & (~0U >> (32 - p->ru_bits + 1));
 
        /* Determine the LCG we use */
        p->ru_b = (arc4random() & (~0U >> (32 - p->ru_bits))) | 1;
@@ -319,6 +318,6 @@
 
        p->ru_counter += i;
 
-       return (p->ru_seed ^ pmod(p->ru_g, p->ru_seed2 ^ p->ru_x, p->ru_n)) |
+       return (p->ru_seed ^ pmod(p->ru_g, p->ru_x, p->ru_n)) |
            p->ru_msb;
 }



Home | Main Index | Thread Index | Old Index