ip6_id.c (257179) | ip6_id.c (298995) |
---|---|
1/*- 2 * Copyright (C) 2003 WIDE Project. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 53 unchanged lines hidden (view full) --- 62 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 63 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 64 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 65 * 66 * $OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $ 67 */ 68 69#include <sys/cdefs.h> | 1/*- 2 * Copyright (C) 2003 WIDE Project. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 53 unchanged lines hidden (view full) --- 62 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 63 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 64 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 65 * 66 * $OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $ 67 */ 68 69#include <sys/cdefs.h> |
70__FBSDID("$FreeBSD: head/sys/netinet6/ip6_id.c 257179 2013-10-26 18:18:50Z glebius $"); | 70__FBSDID("$FreeBSD: head/sys/netinet6/ip6_id.c 298995 2016-05-03 18:05:43Z pfg $"); |
71 72/* 73 * seed = random (bits - 1) bit 74 * n = prime, g0 = generator to n, 75 * j = random so that gcd(j,n-1) == 1 76 * g = g0^j mod n will be a generator again. 77 * 78 * X[0] = random seed. --- 24 unchanged lines hidden (view full) --- 103#include <netinet6/ip6_var.h> 104 105#ifndef INT32_MAX 106#define INT32_MAX 0x7fffffffU 107#endif 108 109struct randomtab { 110 const int ru_bits; /* resulting bits */ | 71 72/* 73 * seed = random (bits - 1) bit 74 * n = prime, g0 = generator to n, 75 * j = random so that gcd(j,n-1) == 1 76 * g = g0^j mod n will be a generator again. 77 * 78 * X[0] = random seed. --- 24 unchanged lines hidden (view full) --- 103#include <netinet6/ip6_var.h> 104 105#ifndef INT32_MAX 106#define INT32_MAX 0x7fffffffU 107#endif 108 109struct randomtab { 110 const int ru_bits; /* resulting bits */ |
111 const long ru_out; /* Time after wich will be reseeded */ | 111 const long ru_out; /* Time after which will be reseeded */ |
112 const u_int32_t ru_max; /* Uniq cycle, avoid blackjack prediction */ 113 const u_int32_t ru_gen; /* Starting generator */ 114 const u_int32_t ru_n; /* ru_n: prime, ru_n - 1: product of pfacts[] */ 115 const u_int32_t ru_agen; /* determine ru_a as ru_agen^(2*rand) */ 116 const u_int32_t ru_m; /* ru_m = 2^x*3^y */ 117 const u_int32_t pfacts[4]; /* factors of ru_n */ 118 119 u_int32_t ru_counter; 120 u_int32_t ru_msb; 121 122 u_int32_t ru_x; 123 u_int32_t ru_seed, ru_seed2; 124 u_int32_t ru_a, ru_b; 125 u_int32_t ru_g; 126 long ru_reseed; 127}; 128 129static struct randomtab randomtab_32 = { 130 32, /* resulting bits */ | 112 const u_int32_t ru_max; /* Uniq cycle, avoid blackjack prediction */ 113 const u_int32_t ru_gen; /* Starting generator */ 114 const u_int32_t ru_n; /* ru_n: prime, ru_n - 1: product of pfacts[] */ 115 const u_int32_t ru_agen; /* determine ru_a as ru_agen^(2*rand) */ 116 const u_int32_t ru_m; /* ru_m = 2^x*3^y */ 117 const u_int32_t pfacts[4]; /* factors of ru_n */ 118 119 u_int32_t ru_counter; 120 u_int32_t ru_msb; 121 122 u_int32_t ru_x; 123 u_int32_t ru_seed, ru_seed2; 124 u_int32_t ru_a, ru_b; 125 u_int32_t ru_g; 126 long ru_reseed; 127}; 128 129static struct randomtab randomtab_32 = { 130 32, /* resulting bits */ |
131 180, /* Time after wich will be reseeded */ | 131 180, /* Time after which will be reseeded */ |
132 1000000000, /* Uniq cycle, avoid blackjack prediction */ 133 2, /* Starting generator */ 134 2147483629, /* RU_N-1 = 2^2*3^2*59652323 */ 135 7, /* determine ru_a as RU_AGEN^(2*rand) */ 136 1836660096, /* RU_M = 2^7*3^15 - don't change */ 137 { 2, 3, 59652323, 0 }, /* factors of ru_n */ 138}; 139 140static struct randomtab randomtab_20 = { 141 20, /* resulting bits */ | 132 1000000000, /* Uniq cycle, avoid blackjack prediction */ 133 2, /* Starting generator */ 134 2147483629, /* RU_N-1 = 2^2*3^2*59652323 */ 135 7, /* determine ru_a as RU_AGEN^(2*rand) */ 136 1836660096, /* RU_M = 2^7*3^15 - don't change */ 137 { 2, 3, 59652323, 0 }, /* factors of ru_n */ 138}; 139 140static struct randomtab randomtab_20 = { 141 20, /* resulting bits */ |
142 180, /* Time after wich will be reseeded */ | 142 180, /* Time after which will be reseeded */ |
143 200000, /* Uniq cycle, avoid blackjack prediction */ 144 2, /* Starting generator */ 145 524269, /* RU_N-1 = 2^2*3^2*14563 */ 146 7, /* determine ru_a as RU_AGEN^(2*rand) */ 147 279936, /* RU_M = 2^7*3^7 - don't change */ 148 { 2, 3, 14563, 0 }, /* factors of ru_n */ 149}; 150 --- 118 unchanged lines hidden --- | 143 200000, /* Uniq cycle, avoid blackjack prediction */ 144 2, /* Starting generator */ 145 524269, /* RU_N-1 = 2^2*3^2*14563 */ 146 7, /* determine ru_a as RU_AGEN^(2*rand) */ 147 279936, /* RU_M = 2^7*3^7 - don't change */ 148 { 2, 3, 14563, 0 }, /* factors of ru_n */ 149}; 150 --- 118 unchanged lines hidden --- |