summaryrefslogtreecommitdiffstats
path: root/crypto/rand
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2020-03-05 12:50:31 -0500
committerRichard Levitte <levitte@openssl.org>2020-04-16 13:52:22 +0200
commit705536e2b5c4167dbda2e0046d83f9e0f4a65514 (patch)
tree5b76e00908f3d8c5dcbb75f094a4c06d989e97d5 /crypto/rand
parent7165593ce5a07a6860d4d408ad640ee707172936 (diff)
Use build.info, not ifdef for crypto modules
Don't wrap conditionally-compiled files in global ifndef tests. Instead, test if the feature is disabled and, if so, do not compile it. Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11263)
Diffstat (limited to 'crypto/rand')
-rw-r--r--crypto/rand/build.info5
-rw-r--r--crypto/rand/rand_egd.c61
2 files changed, 32 insertions, 34 deletions
diff --git a/crypto/rand/build.info b/crypto/rand/build.info
index 0925c4b2de..80f5710174 100644
--- a/crypto/rand/build.info
+++ b/crypto/rand/build.info
@@ -2,6 +2,9 @@ LIBS=../../libcrypto
$COMMON=rand_lib.c rand_crng_test.c rand_win.c rand_unix.c rand_vms.c \
drbg_lib.c drbg_ctr.c rand_vxworks.c drbg_hash.c drbg_hmac.c
+IF[{- !$disabled{'egd'} -}]
+ $COMMON=$COMMON rand_egd.c
+ENDIF
-SOURCE[../../libcrypto]=$COMMON randfile.c rand_err.c rand_egd.c
+SOURCE[../../libcrypto]=$COMMON randfile.c rand_err.c
SOURCE[../../providers/libfips.a]=$COMMON
diff --git a/crypto/rand/rand_egd.c b/crypto/rand/rand_egd.c
index bac8d609c4..dfed1453d7 100644
--- a/crypto/rand/rand_egd.c
+++ b/crypto/rand/rand_egd.c
@@ -8,19 +8,16 @@
*/
#include <openssl/opensslconf.h>
-#ifdef OPENSSL_NO_EGD
-NON_EMPTY_TRANSLATION_UNIT
-#else
-# include <openssl/crypto.h>
-# include <openssl/e_os2.h>
-# include <openssl/rand.h>
+#include <openssl/crypto.h>
+#include <openssl/e_os2.h>
+#include <openssl/rand.h>
/*
* Query an EGD
*/
-# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_VOS) || defined(OPENSSL_SYS_UEFI)
+#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_VOS) || defined(OPENSSL_SYS_UEFI)
int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
{
return -1;
@@ -36,26 +33,26 @@ int RAND_egd_bytes(const char *path, int bytes)
return -1;
}
-# else
+#else
-# include <unistd.h>
-# 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
+# include <unistd.h>
+# 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)
{
@@ -83,23 +80,23 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
for ( ; ; ) {
if (connect(fd, (struct sockaddr *)&addr, i) == 0)
break;
-# ifdef EISCONN
+# ifdef EISCONN
if (errno == EISCONN)
break;
-# endif
+# endif
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;
default:
@@ -153,6 +150,4 @@ int RAND_egd(const char *path)
return RAND_egd_bytes(path, 255);
}
-# endif
-
#endif