summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/rand
diff options
context:
space:
mode:
authorbeck <beck@openbsd.org>2001-06-22 00:02:45 +0000
committerbeck <beck@openbsd.org>2001-06-22 00:02:45 +0000
commitce6fc0900b2b4e5edea1b1b8e032cab822e464e9 (patch)
treeb11b933beb98ff4d5fb927f3ad0fdef1f485128d /lib/libcrypto/rand
parentBuild and install Heimdal infofile. (diff)
downloadwireguard-openbsd-ce6fc0900b2b4e5edea1b1b8e032cab822e464e9.tar.xz
wireguard-openbsd-ce6fc0900b2b4e5edea1b1b8e032cab822e464e9.zip
openssl-engine-0.9.6a merge
Diffstat (limited to 'lib/libcrypto/rand')
-rw-r--r--lib/libcrypto/rand/Makefile.ssl3
-rw-r--r--lib/libcrypto/rand/md_rand.c4
-rw-r--r--lib/libcrypto/rand/rand.h4
-rw-r--r--lib/libcrypto/rand/rand_egd.c7
-rw-r--r--lib/libcrypto/rand/rand_win.c8
-rw-r--r--lib/libcrypto/rand/randfile.c10
6 files changed, 27 insertions, 9 deletions
diff --git a/lib/libcrypto/rand/Makefile.ssl b/lib/libcrypto/rand/Makefile.ssl
index 5f6199a35fd..707eaac6786 100644
--- a/lib/libcrypto/rand/Makefile.ssl
+++ b/lib/libcrypto/rand/Makefile.ssl
@@ -39,7 +39,8 @@ all: lib
lib: $(LIBOBJ)
$(AR) $(LIB) $(LIBOBJ)
- $(RANLIB) $(LIB)
+ @echo You may get an error following this line. Please ignore.
+ - $(RANLIB) $(LIB)
@touch lib
files:
diff --git a/lib/libcrypto/rand/md_rand.c b/lib/libcrypto/rand/md_rand.c
index d167dea77db..567838f6c33 100644
--- a/lib/libcrypto/rand/md_rand.c
+++ b/lib/libcrypto/rand/md_rand.c
@@ -482,12 +482,12 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
unpredictable */
static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
{
- int ret, err;
+ int ret;
ret = RAND_bytes(buf, num);
if (ret == 0)
{
- err = ERR_peek_error();
+ long err = ERR_peek_error();
if (ERR_GET_LIB(err) == ERR_LIB_RAND &&
ERR_GET_REASON(err) == RAND_R_PRNG_NOT_SEEDED)
(void)ERR_get_error();
diff --git a/lib/libcrypto/rand/rand.h b/lib/libcrypto/rand/rand.h
index eb9c8c034de..9c6052733e1 100644
--- a/lib/libcrypto/rand/rand.h
+++ b/lib/libcrypto/rand/rand.h
@@ -59,6 +59,8 @@
#ifndef HEADER_RAND_H
#define HEADER_RAND_H
+#include <stdlib.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -89,7 +91,7 @@ void RAND_seed(const void *buf,int num);
void RAND_add(const void *buf,int num,double entropy);
int RAND_load_file(const char *file,long max_bytes);
int RAND_write_file(const char *file);
-const char *RAND_file_name(char *file,int num);
+const char *RAND_file_name(char *file,size_t num);
int RAND_status(void);
int RAND_egd(const char *path);
int RAND_egd_bytes(const char *path,int bytes);
diff --git a/lib/libcrypto/rand/rand_egd.c b/lib/libcrypto/rand/rand_egd.c
index 02a0d86fa33..79b5e6fa57f 100644
--- a/lib/libcrypto/rand/rand_egd.c
+++ b/lib/libcrypto/rand/rand_egd.c
@@ -74,7 +74,14 @@ int RAND_egd_bytes(const char *path,int bytes)
#include OPENSSL_UNISTD
#include <sys/types.h>
#include <sys/socket.h>
+#ifndef NO_SYS_UN_H
#include <sys/un.h>
+#else
+struct sockaddr_un {
+ short sun_family; /* AF_UNIX */
+ char sun_path[108]; /* path name (gag) */
+};
+#endif /* NO_SYS_UN_H */
#include <string.h>
#ifndef offsetof
diff --git a/lib/libcrypto/rand/rand_win.c b/lib/libcrypto/rand/rand_win.c
index 9f2dcff9a92..3d137badd0e 100644
--- a/lib/libcrypto/rand/rand_win.c
+++ b/lib/libcrypto/rand/rand_win.c
@@ -570,14 +570,15 @@ static void readtimer(void)
DWORD w;
LARGE_INTEGER l;
static int have_perfc = 1;
-#ifndef __GNUC__
+#ifdef _MSC_VER
static int have_tsc = 1;
DWORD cyclecount;
if (have_tsc) {
__try {
__asm {
- rdtsc
+ _emit 0x0f
+ _emit 0x31
mov cyclecount, eax
}
RAND_add(&cyclecount, sizeof(cyclecount), 1);
@@ -725,8 +726,9 @@ int RAND_poll(void)
#ifdef DEVRANDOM
return 1;
-#endif
+#else
return 0;
+#endif
}
#endif
diff --git a/lib/libcrypto/rand/randfile.c b/lib/libcrypto/rand/randfile.c
index 663a36cb701..f4376cf8cc5 100644
--- a/lib/libcrypto/rand/randfile.c
+++ b/lib/libcrypto/rand/randfile.c
@@ -73,7 +73,7 @@
# include <sys/stat.h>
#endif
-#include <openssl/e_os.h>
+#include "openssl/e_os.h"
#include <openssl/crypto.h>
#include <openssl/rand.h>
@@ -83,6 +83,9 @@
/* #define RFILE ".rnd" - defined in ../../e_os.h */
+/* Note that these functions are intended for seed files only.
+ * Entropy devices and EGD sockets are handled in rand_unix.c */
+
int RAND_load_file(const char *file, long bytes)
{
/* If bytes >= 0, read up to 'bytes' bytes.
@@ -213,7 +216,7 @@ err:
return (rand_err ? -1 : ret);
}
-const char *RAND_file_name(char *buf, int size)
+const char *RAND_file_name(char *buf, size_t size)
{
char *s = NULL;
char *ret=NULL;
@@ -239,6 +242,8 @@ const char *RAND_file_name(char *buf, int size)
strlcat(buf,RFILE,size);
ret=buf;
}
+ else
+ buf[0] = '\0'; /* no file name */
}
#ifdef DEVRANDOM
@@ -257,3 +262,4 @@ const char *RAND_file_name(char *buf, int size)
#endif
return(ret);
}
+