"seed2" was ruining non-repeating property, so remove it. discussed on tech-net
This commit is contained in:
parent
b6a2cef9dc
commit
0864b4939d
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ip_id.c,v 1.3 2003/11/19 18:39:34 jonathan Exp $ */
|
||||
/* $NetBSD: ip_id.c,v 1.4 2003/11/25 18:13:55 itojun Exp $ */
|
||||
/* $OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -57,7 +57,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_id.c,v 1.3 2003/11/19 18:39:34 jonathan Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_id.c,v 1.4 2003/11/25 18:13:55 itojun Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
|
||||
|
@ -85,7 +85,7 @@ const static u_int16_t pfacts[PFAC_N] = {
|
|||
};
|
||||
|
||||
static u_int16_t ru_x;
|
||||
static u_int16_t ru_seed, ru_seed2;
|
||||
static u_int16_t ru_seed;
|
||||
static u_int16_t ru_a, ru_b;
|
||||
static u_int16_t ru_g;
|
||||
static u_int16_t ru_counter = 0;
|
||||
|
@ -137,7 +137,6 @@ ip_initid(void)
|
|||
|
||||
/* 15 bits of random seed */
|
||||
ru_seed = (tmp >> 16) & 0x7FFF;
|
||||
ru_seed2 = arc4random() & 0x7FFF;
|
||||
|
||||
/* Determine the LCG we use */
|
||||
ru_b = ((tmp = arc4random()) & 0xfffe) | 1;
|
||||
|
@ -194,5 +193,5 @@ ip_randomid(void)
|
|||
|
||||
ru_counter += i;
|
||||
|
||||
return (ru_seed ^ pmod(ru_g, ru_seed2 ^ ru_x,RU_N)) | ru_msb;
|
||||
return (ru_seed ^ pmod(ru_g, ru_x, RU_N)) | ru_msb;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ip6_id.c,v 1.9 2003/09/16 00:31:23 itojun Exp $ */
|
||||
/* $NetBSD: ip6_id.c,v 1.10 2003/11/25 18:13:55 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 $ */
|
||||
|
||||
|
@ -87,7 +87,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip6_id.c,v 1.9 2003/09/16 00:31:23 itojun Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip6_id.c,v 1.10 2003/11/25 18:13:55 itojun Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -113,7 +113,7 @@ struct randomtab {
|
|||
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;
|
||||
|
@ -186,7 +186,6 @@ initid(struct randomtab *p)
|
|||
|
||||
/* (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;
|
||||
|
@ -243,7 +242,7 @@ randomid(struct randomtab *p)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue