From f1fed0fb465a8c7d1b3f29380871134f9c4e3113 Mon Sep 17 00:00:00 2001 From: eroen Date: Wed, 4 Jan 2017 19:33:36 +0100 Subject: [PATCH] Enhance openssl 1.1.0 compatibility - Don't use deprecated version API - Skip openssl initialization, openssl handles this internally This prevents build failures when openssl 1.1.0 is built with --api=1.1 or compatibility mode is not enabled. X-Gentoo-Bug: 604698 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604698 --- lib/crypto_backend/crypto_openssl.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/crypto_backend/crypto_openssl.c b/lib/crypto_backend/crypto_openssl.c index b1e14b6..986fc9e 100644 --- a/lib/crypto_backend/crypto_openssl.c +++ b/lib/crypto_backend/crypto_openssl.c @@ -35,8 +35,6 @@ #include #include "crypto_backend.h" -static int crypto_backend_initialised = 0; - struct crypt_hash { EVP_MD_CTX *md; const EVP_MD *hash_id; @@ -49,6 +47,9 @@ struct crypt_hmac { int hash_len; }; +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) +static int crypto_backend_initialised = 0; + int crypt_backend_init(struct crypt_device *ctx) { if (crypto_backend_initialised) @@ -59,15 +60,17 @@ int crypt_backend_init(struct crypt_device *ctx) crypto_backend_initialised = 1; return 0; } - -uint32_t crypt_backend_flags(void) +#else +int crypt_backend_init(struct crypt_device *ctx) { return 0; } +#endif -const char *crypt_backend_version(void) + +uint32_t crypt_backend_flags(void) { - return SSLeay_version(SSLEAY_VERSION); + return 0; } /* @@ -105,8 +108,20 @@ static void HMAC_CTX_free(HMAC_CTX *md) HMAC_CTX_cleanup(md); free(md); } + +#define OPENSSL_VERSION SSLEAY_VERSION +const char *OpenSSL_version(int t) +{ + return SSLeay_version(t); +} #endif +const char *crypt_backend_version(void) +{ + return OpenSSL_version(OPENSSL_VERSION); +} + + /* HASH */ int crypt_hash_size(const char *name) { -- 2.11.0