summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rand
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/rand')
-rw-r--r--src/lib/libcrypto/rand/Makefile.ssl3
-rw-r--r--src/lib/libcrypto/rand/md_rand.c4
-rw-r--r--src/lib/libcrypto/rand/rand.h4
-rw-r--r--src/lib/libcrypto/rand/rand_egd.c7
-rw-r--r--src/lib/libcrypto/rand/rand_win.c8
-rw-r--r--src/lib/libcrypto/rand/randfile.c10
6 files changed, 27 insertions, 9 deletions
diff --git a/src/lib/libcrypto/rand/Makefile.ssl b/src/lib/libcrypto/rand/Makefile.ssl
index 5f6199a35f..707eaac678 100644
--- a/src/lib/libcrypto/rand/Makefile.ssl
+++ b/src/lib/libcrypto/rand/Makefile.ssl
@@ -39,7 +39,8 @@ all: lib
39 39
40lib: $(LIBOBJ) 40lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 41 $(AR) $(LIB) $(LIBOBJ)
42 $(RANLIB) $(LIB) 42 @echo You may get an error following this line. Please ignore.
43 - $(RANLIB) $(LIB)
43 @touch lib 44 @touch lib
44 45
45files: 46files:
diff --git a/src/lib/libcrypto/rand/md_rand.c b/src/lib/libcrypto/rand/md_rand.c
index d167dea77d..567838f6c3 100644
--- a/src/lib/libcrypto/rand/md_rand.c
+++ b/src/lib/libcrypto/rand/md_rand.c
@@ -482,12 +482,12 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
482 unpredictable */ 482 unpredictable */
483static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num) 483static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
484 { 484 {
485 int ret, err; 485 int ret;
486 486
487 ret = RAND_bytes(buf, num); 487 ret = RAND_bytes(buf, num);
488 if (ret == 0) 488 if (ret == 0)
489 { 489 {
490 err = ERR_peek_error(); 490 long err = ERR_peek_error();
491 if (ERR_GET_LIB(err) == ERR_LIB_RAND && 491 if (ERR_GET_LIB(err) == ERR_LIB_RAND &&
492 ERR_GET_REASON(err) == RAND_R_PRNG_NOT_SEEDED) 492 ERR_GET_REASON(err) == RAND_R_PRNG_NOT_SEEDED)
493 (void)ERR_get_error(); 493 (void)ERR_get_error();
diff --git a/src/lib/libcrypto/rand/rand.h b/src/lib/libcrypto/rand/rand.h
index eb9c8c034d..9c6052733e 100644
--- a/src/lib/libcrypto/rand/rand.h
+++ b/src/lib/libcrypto/rand/rand.h
@@ -59,6 +59,8 @@
59#ifndef HEADER_RAND_H 59#ifndef HEADER_RAND_H
60#define HEADER_RAND_H 60#define HEADER_RAND_H
61 61
62#include <stdlib.h>
63
62#ifdef __cplusplus 64#ifdef __cplusplus
63extern "C" { 65extern "C" {
64#endif 66#endif
@@ -89,7 +91,7 @@ void RAND_seed(const void *buf,int num);
89void RAND_add(const void *buf,int num,double entropy); 91void RAND_add(const void *buf,int num,double entropy);
90int RAND_load_file(const char *file,long max_bytes); 92int RAND_load_file(const char *file,long max_bytes);
91int RAND_write_file(const char *file); 93int RAND_write_file(const char *file);
92const char *RAND_file_name(char *file,int num); 94const char *RAND_file_name(char *file,size_t num);
93int RAND_status(void); 95int RAND_status(void);
94int RAND_egd(const char *path); 96int RAND_egd(const char *path);
95int RAND_egd_bytes(const char *path,int bytes); 97int RAND_egd_bytes(const char *path,int bytes);
diff --git a/src/lib/libcrypto/rand/rand_egd.c b/src/lib/libcrypto/rand/rand_egd.c
index 02a0d86fa3..79b5e6fa57 100644
--- a/src/lib/libcrypto/rand/rand_egd.c
+++ b/src/lib/libcrypto/rand/rand_egd.c
@@ -74,7 +74,14 @@ int RAND_egd_bytes(const char *path,int bytes)
74#include OPENSSL_UNISTD 74#include OPENSSL_UNISTD
75#include <sys/types.h> 75#include <sys/types.h>
76#include <sys/socket.h> 76#include <sys/socket.h>
77#ifndef NO_SYS_UN_H
77#include <sys/un.h> 78#include <sys/un.h>
79#else
80struct sockaddr_un {
81 short sun_family; /* AF_UNIX */
82 char sun_path[108]; /* path name (gag) */
83};
84#endif /* NO_SYS_UN_H */
78#include <string.h> 85#include <string.h>
79 86
80#ifndef offsetof 87#ifndef offsetof
diff --git a/src/lib/libcrypto/rand/rand_win.c b/src/lib/libcrypto/rand/rand_win.c
index 9f2dcff9a9..3d137badd0 100644
--- a/src/lib/libcrypto/rand/rand_win.c
+++ b/src/lib/libcrypto/rand/rand_win.c
@@ -570,14 +570,15 @@ static void readtimer(void)
570 DWORD w; 570 DWORD w;
571 LARGE_INTEGER l; 571 LARGE_INTEGER l;
572 static int have_perfc = 1; 572 static int have_perfc = 1;
573#ifndef __GNUC__ 573#ifdef _MSC_VER
574 static int have_tsc = 1; 574 static int have_tsc = 1;
575 DWORD cyclecount; 575 DWORD cyclecount;
576 576
577 if (have_tsc) { 577 if (have_tsc) {
578 __try { 578 __try {
579 __asm { 579 __asm {
580 rdtsc 580 _emit 0x0f
581 _emit 0x31
581 mov cyclecount, eax 582 mov cyclecount, eax
582 } 583 }
583 RAND_add(&cyclecount, sizeof(cyclecount), 1); 584 RAND_add(&cyclecount, sizeof(cyclecount), 1);
@@ -725,8 +726,9 @@ int RAND_poll(void)
725 726
726#ifdef DEVRANDOM 727#ifdef DEVRANDOM
727 return 1; 728 return 1;
728#endif 729#else
729 return 0; 730 return 0;
731#endif
730} 732}
731 733
732#endif 734#endif
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c
index 663a36cb70..f4376cf8cc 100644
--- a/src/lib/libcrypto/rand/randfile.c
+++ b/src/lib/libcrypto/rand/randfile.c
@@ -73,7 +73,7 @@
73# include <sys/stat.h> 73# include <sys/stat.h>
74#endif 74#endif
75 75
76#include <openssl/e_os.h> 76#include "openssl/e_os.h"
77#include <openssl/crypto.h> 77#include <openssl/crypto.h>
78#include <openssl/rand.h> 78#include <openssl/rand.h>
79 79
@@ -83,6 +83,9 @@
83 83
84/* #define RFILE ".rnd" - defined in ../../e_os.h */ 84/* #define RFILE ".rnd" - defined in ../../e_os.h */
85 85
86/* Note that these functions are intended for seed files only.
87 * Entropy devices and EGD sockets are handled in rand_unix.c */
88
86int RAND_load_file(const char *file, long bytes) 89int RAND_load_file(const char *file, long bytes)
87 { 90 {
88 /* If bytes >= 0, read up to 'bytes' bytes. 91 /* If bytes >= 0, read up to 'bytes' bytes.
@@ -213,7 +216,7 @@ err:
213 return (rand_err ? -1 : ret); 216 return (rand_err ? -1 : ret);
214 } 217 }
215 218
216const char *RAND_file_name(char *buf, int size) 219const char *RAND_file_name(char *buf, size_t size)
217 { 220 {
218 char *s = NULL; 221 char *s = NULL;
219 char *ret=NULL; 222 char *ret=NULL;
@@ -239,6 +242,8 @@ const char *RAND_file_name(char *buf, int size)
239 strlcat(buf,RFILE,size); 242 strlcat(buf,RFILE,size);
240 ret=buf; 243 ret=buf;
241 } 244 }
245 else
246 buf[0] = '\0'; /* no file name */
242 } 247 }
243 248
244#ifdef DEVRANDOM 249#ifdef DEVRANDOM
@@ -257,3 +262,4 @@ const char *RAND_file_name(char *buf, int size)
257#endif 262#endif
258 return(ret); 263 return(ret);
259 } 264 }
265