From c8ab23cbce8a209566f317d22e2c554ff621e3c8 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 5 Oct 2019 13:05:12 +0200 Subject: build: Allow older OpenSSL versions for random Ubuntu 16 comes with older versions of OpenSSL, glibc and libgcrypt. Ouroboros will now fall back to OpenSSL even if the version is <= 1.1.0. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/CMakeLists.txt | 5 +++-- src/lib/config.h.in | 1 + src/lib/random.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 31a7742b..8dbedcff 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -99,6 +99,7 @@ endif () find_package(OpenSSL QUIET) if (OPENSSL_FOUND) + set(HAVE_OPENSSL_RNG TRUE) if (OPENSSL_VERSION VERSION_LESS "1.1.0") message(STATUS "Install version >= \"1.1.0\" to enable OpenSSL support " "(found version \"${OPENSSL_VERSION}\")") @@ -114,7 +115,7 @@ if (OPENSSL_FOUND) endif () endif () -if (NOT HAVE_OPENSSL) +if (NOT HAVE_OPENSSL_RNG) set(OPENSSL_INCLUDE_DIR "") set(OPENSSL_LIBRARIES "") endif () @@ -133,7 +134,7 @@ else () endif() if (NOT ((CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") OR APPLE OR - HAVE_SYS_RANDOM OR HAVE_OPENSSL OR HAVE_LIBGCRYPT)) + HAVE_SYS_RANDOM OR HAVE_OPENSSL_RNG OR HAVE_LIBGCRYPT)) message(FATAL_ERROR "No secure random generator found, " "please install libgcrypt (> 1.7.0) or OpenSSL") endif () diff --git a/src/lib/config.h.in b/src/lib/config.h.in index 70261cab..8afc9a8c 100644 --- a/src/lib/config.h.in +++ b/src/lib/config.h.in @@ -33,6 +33,7 @@ #cmakedefine SHM_RBUFF_LOCKLESS #cmakedefine SHM_RDRB_MULTI_BLOCK #cmakedefine QOS_DISABLE_CRC +#cmakedefine HAVE_OPENSSL_RNG #define SHM_RBUFF_PREFIX "@SHM_RBUFF_PREFIX@" #define SHM_LOCKFILE_NAME "@SHM_LOCKFILE_NAME@" diff --git a/src/lib/random.c b/src/lib/random.c index 3751668e..971f5b5a 100644 --- a/src/lib/random.c +++ b/src/lib/random.c @@ -40,7 +40,7 @@ #include #elif defined(__FreeBSD__) #include -#elif defined(HAVE_OPENSSL) +#elif defined(HAVE_OPENSSL_RNG) #include #include #endif @@ -58,7 +58,7 @@ int random_buffer(void * buf, #elif defined(HAVE_LIBGCRYPT) gcry_randomize(buf, len, GCRY_STRONG_RANDOM); return 0; -#elif defined(HAVE_OPENSSL) +#elif defined(HAVE_OPENSSL_RNG) if (len > 0 && len < INT_MAX) return RAND_bytes((unsigned char *) buf, (int) len); return -1; -- cgit v1.2.3