From 41b30e7b49d91d31ab396c1cd163e92f72b25ae5 Mon Sep 17 00:00:00 2001
From: Treeve Jelbert <treeve@sourcemage.org>
Date: Sun, 6 May 2018 09:32:23 +0200
Subject: [PATCH] libressl-2.7 fix

---
 src/p11_rsa.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/p11_rsa.c b/src/p11_rsa.c
index 97cd5a2..e94fcd9 100644
--- a/src/p11_rsa.c
+++ b/src/p11_rsa.c
@@ -403,7 +403,7 @@ static void free_rsa_ex_index()
 #endif
 }
 
-#if OPENSSL_VERSION_NUMBER < 0x10100005L || defined(LIBRESSL_VERSION_NUMBER)
+#if OPENSSL_VERSION_NUMBER < 0x10100005L
 
 static RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth)
 {
@@ -418,7 +418,7 @@ static RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth)
 	}
 	return ret;
 }
-
+#if defined(LIBRESSL_VERSION_NUMBER)
 static int RSA_meth_set1_name(RSA_METHOD *meth, const char *name)
 {
 	char *tmp = OPENSSL_strdup(name);
@@ -434,6 +434,7 @@ static int RSA_meth_set_flags(RSA_METHOD *meth, int flags)
 	meth->flags = flags;
 	return 1;
 }
+#else
 
 static int RSA_meth_set_priv_enc(RSA_METHOD *meth,
 		int (*priv_enc) (int flen, const unsigned char *from,
@@ -456,6 +457,7 @@ static int RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa))
 	meth->finish = finish;
 	return 1;
 }
+#endif //libressl
 
 #endif
 
@@ -471,8 +473,11 @@ RSA_METHOD *PKCS11_get_rsa_method(void)
 		ops = RSA_meth_dup(RSA_get_default_method());
 		if (ops == NULL)
 			return NULL;
+
+#if !defined(LIBRESSL_VERSION_NUMBER)
 		RSA_meth_set1_name(ops, "libp11 RSA method");
 		RSA_meth_set_flags(ops, 0);
+#endif
 		RSA_meth_set_priv_enc(ops, pkcs11_rsa_priv_enc_method);
 		RSA_meth_set_priv_dec(ops, pkcs11_rsa_priv_dec_method);
 		RSA_meth_set_finish(ops, pkcs11_rsa_free_method);
-- 
2.17.0

