rsa: Fix LibreSSL before v2.7.0

Fix LibreSSL compilation for versions before v2.7.0.

Signed-off-by: Caliph Nomble <nomble@palism.com>
Reviewed-by: Jonathan Gray <jsg@jsg.id.au>
lime2-spi
Caliph Nomble 6 years ago committed by Tom Rini
parent ca230b094e
commit 7ac1a432a1
  1. 18
      lib/rsa/rsa-sign.c

@ -20,7 +20,8 @@
#define HAVE_ERR_REMOVE_THREAD_STATE #define HAVE_ERR_REMOVE_THREAD_STATE
#endif #endif
#if OPENSSL_VERSION_NUMBER < 0x10100000L #if OPENSSL_VERSION_NUMBER < 0x10100000L || \
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
static void RSA_get0_key(const RSA *r, static void RSA_get0_key(const RSA *r,
const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
{ {
@ -299,7 +300,8 @@ static int rsa_init(void)
{ {
int ret; int ret;
#if OPENSSL_VERSION_NUMBER < 0x10100000L #if OPENSSL_VERSION_NUMBER < 0x10100000L || \
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
ret = SSL_library_init(); ret = SSL_library_init();
#else #else
ret = OPENSSL_init_ssl(0, NULL); ret = OPENSSL_init_ssl(0, NULL);
@ -308,7 +310,8 @@ static int rsa_init(void)
fprintf(stderr, "Failure to init SSL library\n"); fprintf(stderr, "Failure to init SSL library\n");
return -1; return -1;
} }
#if OPENSSL_VERSION_NUMBER < 0x10100000L #if OPENSSL_VERSION_NUMBER < 0x10100000L || \
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
SSL_load_error_strings(); SSL_load_error_strings();
OpenSSL_add_all_algorithms(); OpenSSL_add_all_algorithms();
@ -354,7 +357,8 @@ err_set_rsa:
err_engine_init: err_engine_init:
ENGINE_free(e); ENGINE_free(e);
err_engine_by_id: err_engine_by_id:
#if OPENSSL_VERSION_NUMBER < 0x10100000L #if OPENSSL_VERSION_NUMBER < 0x10100000L || \
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
ENGINE_cleanup(); ENGINE_cleanup();
#endif #endif
return ret; return ret;
@ -362,7 +366,8 @@ err_engine_by_id:
static void rsa_remove(void) static void rsa_remove(void)
{ {
#if OPENSSL_VERSION_NUMBER < 0x10100000L #if OPENSSL_VERSION_NUMBER < 0x10100000L || \
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
CRYPTO_cleanup_all_ex_data(); CRYPTO_cleanup_all_ex_data();
ERR_free_strings(); ERR_free_strings();
#ifdef HAVE_ERR_REMOVE_THREAD_STATE #ifdef HAVE_ERR_REMOVE_THREAD_STATE
@ -432,7 +437,8 @@ static int rsa_sign_with_key(RSA *rsa, struct checksum_algo *checksum_algo,
ret = rsa_err("Could not obtain signature"); ret = rsa_err("Could not obtain signature");
goto err_sign; goto err_sign;
} }
#if OPENSSL_VERSION_NUMBER < 0x10100000L #if OPENSSL_VERSION_NUMBER < 0x10100000L || \
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
EVP_MD_CTX_cleanup(context); EVP_MD_CTX_cleanup(context);
#else #else
EVP_MD_CTX_reset(context); EVP_MD_CTX_reset(context);

Loading…
Cancel
Save