summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/rand/rand_unix.c
diff options
context:
space:
mode:
authormarkus <markus@openbsd.org>2002-09-05 22:33:18 +0000
committermarkus <markus@openbsd.org>2002-09-05 22:33:18 +0000
commit6578914fed88fb905cb1cc0652774ce825c4d675 (patch)
tree1443d61ae65c7ca6a02982cb4470b397f6cc037f /lib/libcrypto/rand/rand_unix.c
parentmerge with 0.9.7-beta1 (diff)
downloadwireguard-openbsd-6578914fed88fb905cb1cc0652774ce825c4d675.tar.xz
wireguard-openbsd-6578914fed88fb905cb1cc0652774ce825c4d675.zip
import openssl-0.9.7-beta3
Diffstat (limited to 'lib/libcrypto/rand/rand_unix.c')
-rw-r--r--lib/libcrypto/rand/rand_unix.c40
1 files changed, 2 insertions, 38 deletions
diff --git a/lib/libcrypto/rand/rand_unix.c b/lib/libcrypto/rand/rand_unix.c
index 0b292351302..ec09d74603c 100644
--- a/lib/libcrypto/rand/rand_unix.c
+++ b/lib/libcrypto/rand/rand_unix.c
@@ -109,6 +109,8 @@
*
*/
+#define USE_SOCKETS
+#include "e_os.h"
#include "cryptlib.h"
#include <openssl/rand.h>
#include "rand_lcl.h"
@@ -122,43 +124,6 @@
#include <unistd.h>
#include <time.h>
-#ifdef __OpenBSD__
-#undef DEVRANDOM
-#define DEVRANDOM "/dev/arandom"
-int RAND_poll(void)
-{
- unsigned long l;
- pid_t curr_pid = getpid();
- FILE *fh;
-
- /* Use a random entropy pool device. Linux, FreeBSD and OpenBSD
- * have this. Use /dev/urandom if you can as /dev/random may block
- * if it runs out of random entries. */
-
- if ((fh = fopen(DEVRANDOM, "r")) != NULL)
- {
- unsigned char tmpbuf[ENTROPY_NEEDED];
- int n;
-
- setvbuf(fh, NULL, _IONBF, 0);
- n=fread((unsigned char *)tmpbuf,1,ENTROPY_NEEDED,fh);
- fclose(fh);
- RAND_add(tmpbuf,sizeof tmpbuf,n);
- memset(tmpbuf,0,n);
- }
-
- /* put in some default random data, we need more than just this */
- l=curr_pid;
- RAND_add(&l,sizeof(l),0);
- l=getuid();
- RAND_add(&l,sizeof(l),0);
-
- l=time(NULL);
- RAND_add(&l,sizeof(l),0);
-
- return 1;
-}
-#else
int RAND_poll(void)
{
unsigned long l;
@@ -271,4 +236,3 @@ int RAND_poll(void)
}
#endif
-#endif