diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/rand/rand_egd.c | 84 | ||||
-rw-r--r-- | crypto/rand/rand_unix.c | 10 |
2 files changed, 51 insertions, 43 deletions
diff --git a/crypto/rand/rand_egd.c b/crypto/rand/rand_egd.c index ea3621c44f..e65dc0917a 100644 --- a/crypto/rand/rand_egd.c +++ b/crypto/rand/rand_egd.c @@ -95,7 +95,9 @@ * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255. */ -#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS) || defined(OPENSSL_SYS_UEFI) +#ifndef OPENSSL_NO_EGD + +# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS) || defined(OPENSSL_SYS_UEFI) int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) { return (-1); @@ -110,26 +112,26 @@ int RAND_egd_bytes(const char *path, int bytes) { return (-1); } -#else -# include <openssl/opensslconf.h> -# include OPENSSL_UNISTD -# include <stddef.h> -# include <sys/types.h> -# include <sys/socket.h> -# ifndef NO_SYS_UN_H -# ifdef OPENSSL_SYS_VXWORKS -# include <streams/un.h> -# else -# include <sys/un.h> -# endif # else +# include <openssl/opensslconf.h> +# include OPENSSL_UNISTD +# include <stddef.h> +# include <sys/types.h> +# include <sys/socket.h> +# ifndef NO_SYS_UN_H +# ifdef OPENSSL_SYS_VXWORKS +# include <streams/un.h> +# else +# include <sys/un.h> +# endif +# else struct sockaddr_un { short sun_family; /* AF_UNIX */ char sun_path[108]; /* path name (gag) */ }; -# endif /* NO_SYS_UN_H */ -# include <string.h> -# include <errno.h> +# endif /* NO_SYS_UN_H */ +# include <string.h> +# include <errno.h> int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) { @@ -155,25 +157,25 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) success = 1; else { switch (errno) { -# ifdef EINTR +# ifdef EINTR case EINTR: -# endif -# ifdef EAGAIN +# endif +# ifdef EAGAIN case EAGAIN: -# endif -# ifdef EINPROGRESS +# endif +# ifdef EINPROGRESS case EINPROGRESS: -# endif -# ifdef EALREADY +# endif +# ifdef EALREADY case EALREADY: -# endif +# endif /* No error, try again */ break; -# ifdef EISCONN +# ifdef EISCONN case EISCONN: success = 1; break; -# endif +# endif default: goto err; /* failure */ } @@ -190,12 +192,12 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) numbytes += num; else { switch (errno) { -# ifdef EINTR +# ifdef EINTR case EINTR: -# endif -# ifdef EAGAIN +# endif +# ifdef EAGAIN case EAGAIN: -# endif +# endif /* No error, try again */ break; default: @@ -213,12 +215,12 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) numbytes += num; else { switch (errno) { -# ifdef EINTR +# ifdef EINTR case EINTR: -# endif -# ifdef EAGAIN +# endif +# ifdef EAGAIN case EAGAIN: -# endif +# endif /* No error, try again */ break; default: @@ -242,12 +244,12 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) numbytes += num; else { switch (errno) { -# ifdef EINTR +# ifdef EINTR case EINTR: -# endif -# ifdef EAGAIN +# endif +# ifdef EAGAIN case EAGAIN: -# endif +# endif /* No error, try again */ break; default: @@ -285,4 +287,10 @@ int RAND_egd(const char *path) return (RAND_egd_bytes(path, 255)); } +# endif + +#else /* OPENSSL_NO_EGD */ +# if PEDANTIC +static void *dummy = &dummy; +# endif #endif diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c index bb70a5b3fe..38f157b674 100644 --- a/crypto/rand/rand_unix.c +++ b/crypto/rand/rand_unix.c @@ -244,7 +244,7 @@ int RAND_poll(void) { unsigned long l; pid_t curr_pid = getpid(); -# if defined(DEVRANDOM) || defined(DEVRANDOM_EGD) +# if defined(DEVRANDOM) || (!defined(OPENSS_NO_EGD) && defined(DEVRANDOM_EGD)) unsigned char tmpbuf[ENTROPY_NEEDED]; int n = 0; # endif @@ -254,7 +254,7 @@ int RAND_poll(void) int fd; unsigned int i; # endif -# ifdef DEVRANDOM_EGD +# if !defined(OPENSSL_NO_EGD) && defined(DEVRANDOM_EGD) static const char *egdsockets[] = { DEVRANDOM_EGD, NULL }; const char **egdsocket = NULL; # endif @@ -371,7 +371,7 @@ int RAND_poll(void) } # endif /* defined(DEVRANDOM) */ -# ifdef DEVRANDOM_EGD +# if !defined(OPENSSL_NO_EGD) && defined(DEVRANDOM_EGD) /* * Use an EGD socket to read entropy from an EGD or PRNGD entropy * collecting daemon. @@ -388,7 +388,7 @@ int RAND_poll(void) } # endif /* defined(DEVRANDOM_EGD) */ -# if defined(DEVRANDOM) || defined(DEVRANDOM_EGD) +# if defined(DEVRANDOM) || (!defined(OPENSSL_NO_EGD) && defined(DEVRANDOM_EGD)) if (n > 0) { RAND_add(tmpbuf, sizeof tmpbuf, (double)n); OPENSSL_cleanse(tmpbuf, n); @@ -404,7 +404,7 @@ int RAND_poll(void) l = time(NULL); RAND_add(&l, sizeof(l), 0.0); -# if defined(DEVRANDOM) || defined(DEVRANDOM_EGD) +# if defined(DEVRANDOM) || (!defined(OPENSSL_NO_EGD) && defined(DEVRANDOM_EGD)) return 1; # else return 0; |