diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2019-10-05 13:05:12 +0200 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2019-10-05 13:52:26 +0200 |
commit | c8ab23cbce8a209566f317d22e2c554ff621e3c8 (patch) | |
tree | d5705905d8cd21eee16a5487ba10bc87b20f4e34 /src/lib | |
parent | d7db0ac776bdeaff89d13e951e19e9fe28d7bbd1 (diff) | |
download | ouroboros-c8ab23cbce8a209566f317d22e2c554ff621e3c8.tar.gz ouroboros-c8ab23cbce8a209566f317d22e2c554ff621e3c8.zip |
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 <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/lib/config.h.in | 1 | ||||
-rw-r--r-- | 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 <gcrypt.h> #elif defined(__FreeBSD__) #include <stdlib.h> -#elif defined(HAVE_OPENSSL) +#elif defined(HAVE_OPENSSL_RNG) #include <openssl/rand.h> #include <limits.h> #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; |