Deleted Added
full compact
arc4random.c (238118) arc4random.c (241046)
1/* $OpenBSD: arc4random.c,v 1.22 2010/12/22 08:23:42 otto Exp $ */
2
3/*
4 * Copyright (c) 1996, David Mazieres <dm@uun.org>
5 * Copyright (c) 2008, Damien Miller <djm@openbsd.org>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above

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

25 * compatible with RSA Labs "RC4" cipher (the actual description of
26 * which is a trade secret). The same algorithm is used as a stream
27 * cipher called "arcfour" in Tatu Ylonen's ssh package.
28 *
29 * RC4 is a registered trademark of RSA Laboratories.
30 */
31
32#include <sys/cdefs.h>
1/* $OpenBSD: arc4random.c,v 1.22 2010/12/22 08:23:42 otto Exp $ */
2
3/*
4 * Copyright (c) 1996, David Mazieres <dm@uun.org>
5 * Copyright (c) 2008, Damien Miller <djm@openbsd.org>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above

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

25 * compatible with RSA Labs "RC4" cipher (the actual description of
26 * which is a trade secret). The same algorithm is used as a stream
27 * cipher called "arcfour" in Tatu Ylonen's ssh package.
28 *
29 * RC4 is a registered trademark of RSA Laboratories.
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/lib/libc/gen/arc4random.c 238118 2012-07-04 19:51:25Z pjd $");
33__FBSDID("$FreeBSD: head/lib/libc/gen/arc4random.c 241046 2012-09-29 11:54:34Z jilles $");
34
35#include "namespace.h"
36#include <fcntl.h>
37#include <limits.h>
38#include <stdlib.h>
39#include <unistd.h>
40#include <sys/types.h>
41#include <sys/param.h>

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

148 if (!rs_initialized) {
149 arc4_init();
150 rs_initialized = 1;
151 }
152 done = 0;
153 if (arc4_sysctl((u_char *)&rdat, KEYSIZE) == KEYSIZE)
154 done = 1;
155 if (!done) {
34
35#include "namespace.h"
36#include <fcntl.h>
37#include <limits.h>
38#include <stdlib.h>
39#include <unistd.h>
40#include <sys/types.h>
41#include <sys/param.h>

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

148 if (!rs_initialized) {
149 arc4_init();
150 rs_initialized = 1;
151 }
152 done = 0;
153 if (arc4_sysctl((u_char *)&rdat, KEYSIZE) == KEYSIZE)
154 done = 1;
155 if (!done) {
156 fd = _open(RANDOMDEV, O_RDONLY, 0);
156 fd = _open(RANDOMDEV, O_RDONLY | O_CLOEXEC, 0);
157 if (fd >= 0) {
158 if (_read(fd, &rdat, KEYSIZE) == KEYSIZE)
159 done = 1;
160 (void)_close(fd);
161 }
162 }
163 if (!done) {
164 (void)gettimeofday(&rdat.tv, NULL);

--- 161 unchanged lines hidden ---
157 if (fd >= 0) {
158 if (_read(fd, &rdat, KEYSIZE) == KEYSIZE)
159 done = 1;
160 (void)_close(fd);
161 }
162 }
163 if (!done) {
164 (void)gettimeofday(&rdat.tv, NULL);

--- 161 unchanged lines hidden ---