Skip to content

Commit

Permalink
dev-libs/opensc: fix libressl-2.7 build
Browse files Browse the repository at this point in the history
Closes: https://bugs.gentoo.org/show_bug.cgi?id=658212
Thanks: Tom Li
Package-Manager: Portage-2.3.40, Repoman-2.3.9
  • Loading branch information
alonbl committed Jun 28, 2018
1 parent 098ca53 commit 37cd06c
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
79 changes: 79 additions & 0 deletions dev-libs/opensc/files/opensc-0.18.0-libressl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
From 226cd96bfd384a40b3ab6b6dafb97f6e399524f4 Mon Sep 17 00:00:00 2001
From: Alon Bar-Lev <[email protected]>
Date: Fri, 22 Jun 2018 22:21:03 +0300
Subject: [PATCH] build: support >=libressl-2.7

https://github.com/OpenSC/OpenSC/pull/1406

---
src/libopensc/sc-ossl-compat.h | 19 +++++++++++++------
src/tools/sc-hsm-tool.c | 2 +-
2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/libopensc/sc-ossl-compat.h b/src/libopensc/sc-ossl-compat.h
index a94d9564..d9e087a3 100644
--- a/src/libopensc/sc-ossl-compat.h
+++ b/src/libopensc/sc-ossl-compat.h
@@ -90,17 +90,24 @@ extern "C" {

#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
#define RSA_PKCS1_OpenSSL RSA_PKCS1_SSLeay
-#define OPENSSL_malloc_init CRYPTO_malloc_init

-#define EVP_PKEY_get0_RSA(x) (x->pkey.rsa)
-#define EVP_PKEY_get0_DSA(x) (x->pkey.dsa)
#define X509_get_extension_flags(x) (x->ex_flags)
#define X509_get_key_usage(x) (x->ex_kusage)
#define X509_get_extended_key_usage(x) (x->ex_xkusage)
-#define EVP_PKEY_up_ref(user_key) CRYPTO_add(&user_key->references, 1, CRYPTO_LOCK_EVP_PKEY)
#if !defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER < 0x2050300fL
#define X509_up_ref(cert) CRYPTO_add(&cert->references, 1, CRYPTO_LOCK_X509)
#endif
+#if !defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER < 0x20700000L
+#define OPENSSL_malloc_init CRYPTO_malloc_init
+#define EVP_PKEY_get0_RSA(x) (x->pkey.rsa)
+#define EVP_PKEY_get0_DSA(x) (x->pkey.dsa)
+#define EVP_PKEY_up_ref(user_key) CRYPTO_add(&user_key->references, 1, CRYPTO_LOCK_EVP_PKEY)
+#endif
+#endif
+
+/* workaround unused value warning for a macro that does nothing */
+#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x20700000L
+#define OPENSSL_malloc_init()
#endif

/*
@@ -110,7 +117,7 @@ extern "C" {
* If that is not good enough, versions could be added to libopensc
*/

-#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
/* based on OpenSSL-1.1.0 e_os2.h */
/* sc_ossl_inline: portable inline definition usable in public headers */
# if !defined(inline) && !defined(__cplusplus)
@@ -129,7 +136,7 @@ extern "C" {
# endif
#endif

-#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2050300fL)

#define RSA_bits(R) (BN_num_bits(R->n))

diff --git a/src/tools/sc-hsm-tool.c b/src/tools/sc-hsm-tool.c
index 823eb217..307bad25 100644
--- a/src/tools/sc-hsm-tool.c
+++ b/src/tools/sc-hsm-tool.c
@@ -1761,7 +1761,7 @@ int main(int argc, char *argv[])
}
}

-#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !(defined LIBRESSL_VERSION_NUMBER)
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x20700000L)
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS
| OPENSSL_INIT_ADD_ALL_CIPHERS
| OPENSSL_INIT_ADD_ALL_DIGESTS,
--
2.16.4

1 change: 1 addition & 0 deletions dev-libs/opensc/opensc-0.18.0.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ REQUIRED_USE="

PATCHES=(
"${FILESDIR}/${P}-build.patch"
"${FILESDIR}/${P}-libressl.patch"
)

src_configure() {
Expand Down

0 comments on commit 37cd06c

Please sign in to comment.