diff --git a/crypto/rand_extra/getrandom_fillin.h b/crypto/rand_extra/getrandom_fillin.h index 9b18b7e9fdd..7a03709d2f4 100644 --- a/crypto/rand_extra/getrandom_fillin.h +++ b/crypto/rand_extra/getrandom_fillin.h @@ -8,8 +8,7 @@ #include "internal.h" -#if defined(OPENSSL_RAND_URANDOM) - +#if defined(OPENSSL_RAND_URANDOM) && defined(OPENSSL_LINUX) #include #if defined(OPENSSL_X86_64) @@ -54,7 +53,7 @@ #define GRND_RANDOM 2 #endif -#endif // OPENSSL_LINUX +#endif // OPENSSL_RAND_URANDOM && OPENSSL_LINUX #endif // OPENSSL_HEADER_CRYPTO_RAND_GETRANDOM_FILLIN_H diff --git a/crypto/rand_extra/urandom.c b/crypto/rand_extra/urandom.c index c8b611abea8..1aa71038c5b 100644 --- a/crypto/rand_extra/urandom.c +++ b/crypto/rand_extra/urandom.c @@ -353,7 +353,12 @@ static void ensure_getrandom_is_initialized(void) { static void ensure_dev_urandom_is_initialized(void) { // On platforms where urandom doesn't block at startup, we ensure that the - // kernel has sufficient entropy before continuing. + // kernel has sufficient entropy before continuing. We do this via the + // RNDGETENTCNT ioctl from , which is Linux-specific. + // + // On other URANDOM-path platforms (e.g. AIX) we have no portable way to + // query the kernel entropy pool, so we skip this pre-check and proceed. +#if defined(OPENSSL_LINUX) for (;;) { int entropy_bits = 0; if (ioctl(urandom_fd, RNDGETENTCNT, &entropy_bits)) { @@ -376,6 +381,7 @@ static void ensure_dev_urandom_is_initialized(void) { struct timespec sleep_time = {.tv_sec = 0, .tv_nsec = MILLISECONDS_250 }; nanosleep(&sleep_time, &sleep_time); } +#endif // OPENSSL_LINUX random_flavor_state = STATE_READY; }