Fix egd and devrandom source configs
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Sun, 17 May 2020 00:08:56 +0000 (02:08 +0200)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Wed, 20 May 2020 12:48:16 +0000 (14:48 +0200)
./config --with-rand-seed=egd

need to defines OPENSSL_RAND_SEED_EGD and OPENSSL_NO_EGD
so get rid of OPENSSL_NO_EGD (compiles but I did not really test EGD)

./config --with-rand-seed=devrandom

does not work since wait_random_seeded works under the assumption
that OPENSSL_RAND_SEED_GETRANDOM is supposed to be enabled as well,
that is usually the case, but not when only devrandom is enabled.
Skip the wait code in this special case.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11848)

Configure
crypto/rand/rand_unix.c

index 7738073455becf5fab4dbeaf587e3d3d202d05b0..1a22f47822f90be1e8d7bc1d9c4498689e1c2be2 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -1124,6 +1124,9 @@ if (scalar(@seed_sources) == 0) {
     print "Using os-specific seed configuration\n";
     push @seed_sources, 'os';
 }
+if (scalar(grep { $_ eq 'egd' } @seed_sources) > 0) {
+    delete $disabled{'egd'};
+}
 if (scalar(grep { $_ eq 'none' } @seed_sources) > 0) {
     die "Cannot seed with none and anything else" if scalar(@seed_sources) > 1;
     warn <<_____ if scalar(@seed_sources) == 1;
index 081ffca908bd486145cabffa64f3caa5f794c97a..869c2d04ddab5858b46effc0477f8bb1494623f2 100644 (file)
@@ -391,7 +391,8 @@ static struct random_device {
 } random_devices[OSSL_NELEM(random_device_paths)];
 static int keep_random_devices_open = 1;
 
-#   if defined(__linux) && defined(DEVRANDOM_WAIT)
+#   if defined(__linux) && defined(DEVRANDOM_WAIT) \
+       && defined(OPENSSL_RAND_SEED_GETRANDOM)
 static void *shm_addr;
 
 #    if !defined(FIPS_MODULE)
@@ -474,7 +475,7 @@ static int wait_random_seeded(void)
     }
     return seeded;
 }
-#   else /* defined __linux */
+#   else /* defined __linux && DEVRANDOM_WAIT && OPENSSL_RAND_SEED_GETRANDOM */
 static int wait_random_seeded(void)
 {
     return 1;