Deleted Added
full compact
ip6_id.c (174510) ip6_id.c (253970)
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 174510 2007-12-10 16:03:40Z obrien $");
70__FBSDID("$FreeBSD: head/sys/netinet6/ip6_id.c 253970 2013-08-05 20:13:02Z hrs $");
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.

--- 137 unchanged lines hidden (view full) ---

216 noprime = 0;
217 else
218 j = (j + 1) % p->ru_n;
219 }
220
221 p->ru_g = pmod(p->ru_gen, j, p->ru_n);
222 p->ru_counter = 0;
223
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.

--- 137 unchanged lines hidden (view full) ---

216 noprime = 0;
217 else
218 j = (j + 1) % p->ru_n;
219 }
220
221 p->ru_g = pmod(p->ru_gen, j, p->ru_n);
222 p->ru_counter = 0;
223
224 p->ru_reseed = time_second + p->ru_out;
224 p->ru_reseed = time_uptime + p->ru_out;
225 p->ru_msb = p->ru_msb ? 0 : (1U << (p->ru_bits - 1));
226}
227
228static u_int32_t
229randomid(struct randomtab *p)
230{
231 int i, n;
232 u_int32_t tmp;
233
225 p->ru_msb = p->ru_msb ? 0 : (1U << (p->ru_bits - 1));
226}
227
228static u_int32_t
229randomid(struct randomtab *p)
230{
231 int i, n;
232 u_int32_t tmp;
233
234 if (p->ru_counter >= p->ru_max || time_second > p->ru_reseed)
234 if (p->ru_counter >= p->ru_max || time_uptime > p->ru_reseed)
235 initid(p);
236
237 tmp = arc4random();
238
239 /* Skip a random number of ids */
240 n = tmp & 0x3; tmp = tmp >> 2;
241 if (p->ru_counter + n >= p->ru_max)
242 initid(p);

--- 25 unchanged lines hidden ---
235 initid(p);
236
237 tmp = arc4random();
238
239 /* Skip a random number of ids */
240 n = tmp & 0x3; tmp = tmp >> 2;
241 if (p->ru_counter + n >= p->ru_max)
242 initid(p);

--- 25 unchanged lines hidden ---