From 2a151b217745b2361d40b326ecdf1c335fcc1258 Mon Sep 17 00:00:00 2001 From: Alexey Dokuchaev Date: Tue, 30 Jun 2020 09:49:25 +0000 Subject: Allow to build against contemporary versions of OpenSSL. PR: 229027 --- devel/ucommon/Makefile | 12 +------- devel/ucommon/files/patch-openssl_cipher.cpp | 28 +++++++++++++++++ devel/ucommon/files/patch-openssl_digest.cpp | 46 ++++++++++++++++++++++++++++ devel/ucommon/files/patch-openssl_hmac.cpp | 29 ++++++++++++++++++ 4 files changed, 104 insertions(+), 11 deletions(-) create mode 100644 devel/ucommon/files/patch-openssl_cipher.cpp create mode 100644 devel/ucommon/files/patch-openssl_digest.cpp create mode 100644 devel/ucommon/files/patch-openssl_hmac.cpp (limited to 'devel') diff --git a/devel/ucommon/Makefile b/devel/ucommon/Makefile index 33fd3dbd22b5..066c4b7bf2dc 100644 --- a/devel/ucommon/Makefile +++ b/devel/ucommon/Makefile @@ -13,23 +13,13 @@ COMMENT= Very lightweight C++ design pattern library LICENSE= LGPL3 LICENSE_FILE= ${WRKSRC}/COPYING.LESSER -BROKEN_SSL= openssl -BROKEN_SSL_REASON_openssl= error: allocation of incomplete type 'EVP_CIPHER_CTX' - USES= compiler:c++11-lib cmake pathfix pkgconfig ssl CMAKE_ARGS= -DBUILD_TESTING:BOOL=ON \ -DCMAKE_INSTALL_BINDIR:STRING=bin/${PORTNAME} USE_LDCONFIG= yes TEST_TARGET= test -.include - -.if ${SSL_DEFAULT} == base -BROKEN_FreeBSD_12= error: allocation of incomplete type 'EVP_CIPHER_CTX' (aka 'evp_cipher_ctx_st') -BROKEN_FreeBSD_13= error: allocation of incomplete type 'EVP_CIPHER_CTX' (aka 'evp_cipher_ctx_st') -.endif - post-install: ${INSTALL_DATA} ${BUILD_WRKSRC}/ucommon-config.h ${STAGEDIR}${PREFIX}/include/ucommon -.include +.include diff --git a/devel/ucommon/files/patch-openssl_cipher.cpp b/devel/ucommon/files/patch-openssl_cipher.cpp new file mode 100644 index 000000000000..87f9db0b237b --- /dev/null +++ b/devel/ucommon/files/patch-openssl_cipher.cpp @@ -0,0 +1,28 @@ +--- openssl/cipher.cpp.orig 2015-10-11 02:32:36 UTC ++++ openssl/cipher.cpp +@@ -107,8 +107,12 @@ void Cipher::release(void) + { + keys.clear(); + if(context) { ++#if OPENSSL_VERSION_NUMBER >= 0x10100005L ++ EVP_CIPHER_CTX_free((EVP_CIPHER_CTX*)context); ++#else + EVP_CIPHER_CTX_cleanup((EVP_CIPHER_CTX*)context); + delete (EVP_CIPHER_CTX*)context; ++#endif + context = NULL; + } + } +@@ -125,8 +129,12 @@ void Cipher::set(const key_t key, mode_t mode, uint8_t + if(!keys.keysize) + return; + ++#if OPENSSL_VERSION_NUMBER >= 0x10100005L ++ context = EVP_MD_CTX_new(); ++#else + context = new EVP_CIPHER_CTX; + EVP_CIPHER_CTX_init((EVP_CIPHER_CTX *)context); ++#endif + EVP_CipherInit_ex((EVP_CIPHER_CTX *)context, (EVP_CIPHER *)keys.algotype, NULL, keys.keybuf, keys.ivbuf, (int)mode); + EVP_CIPHER_CTX_set_padding((EVP_CIPHER_CTX *)context, 0); + } diff --git a/devel/ucommon/files/patch-openssl_digest.cpp b/devel/ucommon/files/patch-openssl_digest.cpp new file mode 100644 index 000000000000..ded8beb8b8f7 --- /dev/null +++ b/devel/ucommon/files/patch-openssl_digest.cpp @@ -0,0 +1,46 @@ +--- openssl/digest.cpp.orig 2015-10-11 02:32:36 UTC ++++ openssl/digest.cpp +@@ -37,20 +37,30 @@ void Digest::set(const char *type) + + hashtype = (void *)EVP_get_digestbyname(type); + if(hashtype) { ++#if OPENSSL_VERSION_NUMBER >= 0x10100005L ++ context = EVP_MD_CTX_new(); ++#else + context = new EVP_MD_CTX; + EVP_MD_CTX_init((EVP_MD_CTX *)context); ++#endif + EVP_DigestInit_ex((EVP_MD_CTX *)context, (const EVP_MD *)hashtype, NULL); + } + } + + void Digest::release(void) + { ++#if OPENSSL_VERSION_NUMBER < 0x10100005L + if(context) + EVP_MD_CTX_cleanup((EVP_MD_CTX *)context); ++#endif + + if(context) { ++#if OPENSSL_VERSION_NUMBER >= 0x10100005L ++ EVP_MD_CTX_free((EVP_MD_CTX *)context); ++#else + memset(context, 0, sizeof(EVP_MD_CTX)); + delete (EVP_MD_CTX *)context; ++#endif + context = NULL; + } + +@@ -71,8 +81,12 @@ void Digest::reset(void) + { + if(!context) { + if(hashtype) { ++#if OPENSSL_VERSION_NUMBER >= 0x10100005L ++ context = EVP_MD_CTX_new(); ++#else + context = new EVP_MD_CTX; + EVP_MD_CTX_init((EVP_MD_CTX *)context); ++#endif + } + else + return; diff --git a/devel/ucommon/files/patch-openssl_hmac.cpp b/devel/ucommon/files/patch-openssl_hmac.cpp new file mode 100644 index 000000000000..943230260c99 --- /dev/null +++ b/devel/ucommon/files/patch-openssl_hmac.cpp @@ -0,0 +1,29 @@ +--- openssl/hmac.cpp.orig 2015-10-11 02:32:36 UTC ++++ openssl/hmac.cpp +@@ -35,8 +35,12 @@ void HMAC::set(const char *digest, const secure::keyby + + hmactype = EVP_get_digestbyname(digest); + if(hmactype && len) { ++#if OPENSSL_VERSION_NUMBER >= 0x10100005L ++ context = HMAC_CTX_new(); ++#else + context = new ::HMAC_CTX; + HMAC_CTX_init((HMAC_CTX *)context); ++#endif + HMAC_Init((HMAC_CTX *)context, *key, (int)len, (const EVP_MD *)hmactype); + } + } +@@ -44,9 +48,13 @@ void HMAC::set(const char *digest, const secure::keyby + void HMAC::release(void) + { + if(context) { ++#if OPENSSL_VERSION_NUMBER >= 0x10100005L ++ HMAC_CTX_free((HMAC_CTX *)context); ++#else + HMAC_cleanup((HMAC_CTX *)context); + memset(context, 0, sizeof(HMAC_CTX)); + delete (HMAC_CTX *)context; ++#endif + context = NULL; + } + -- cgit v1.2.3