From baaad91bf07bc08367ac11ce712dbb74024cb41d Mon Sep 17 00:00:00 2001
From: Frank Hunleth <fhunleth@troodon-software.com>
Date: Sun, 11 Sep 2022 08:18:28 -0400
Subject: [PATCH] Revert "package/libp11: bump to version 0.4.12"

This reverts commit ecf8efb292fb410ab8080891fb017d4a01ef3cd5.
---
 package/libp11/0001-Update-wp11_rsa.c.patch   | 26 ++++++++++++
 ...rc-p11_attr.c-fix-build-with-gcc-4.8.patch | 42 -------------------
 package/libp11/libp11.hash                    |  2 +-
 package/libp11/libp11.mk                      |  2 +-
 4 files changed, 28 insertions(+), 44 deletions(-)
 create mode 100644 package/libp11/0001-Update-wp11_rsa.c.patch
 delete mode 100644 package/libp11/0001-src-p11_attr.c-fix-build-with-gcc-4.8.patch

diff --git a/package/libp11/0001-Update-wp11_rsa.c.patch b/package/libp11/0001-Update-wp11_rsa.c.patch
new file mode 100644
index 0000000000..0a2d6e65ce
--- /dev/null
+++ b/package/libp11/0001-Update-wp11_rsa.c.patch
@@ -0,0 +1,26 @@
+From 4968cfc64dbaa39bb479a24d9578d75099e2f337 Mon Sep 17 00:00:00 2001
+From: patchMonkey156 <pagorman@asu.edu>
+Date: Mon, 19 Oct 2020 17:12:15 -0400
+Subject: [PATCH] Update p11_rsa.c
+
+Bugfix for new LibreSSL version 3.2.2
+[Retrieved from:
+https://github.com/OpenSC/libp11/commit/4968cfc64dbaa39bb479a24d9578d75099e2f337]
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+---
+ src/p11_rsa.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/p11_rsa.c b/src/p11_rsa.c
+index b6beef0..ff12ed7 100644
+--- a/src/p11_rsa.c
++++ b/src/p11_rsa.c
+@@ -336,7 +336,7 @@ int pkcs11_get_key_size(PKCS11_KEY *key)
+ 	return RSA_size(rsa);
+ }
+ 
+-#if OPENSSL_VERSION_NUMBER < 0x10100005L || defined(LIBRESSL_VERSION_NUMBER)
++#if ( ( defined (OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100005L ) || ( defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3020199L ) )
+ 
+ int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))
+ 		(int flen, const unsigned char *from,
diff --git a/package/libp11/0001-src-p11_attr.c-fix-build-with-gcc-4.8.patch b/package/libp11/0001-src-p11_attr.c-fix-build-with-gcc-4.8.patch
deleted file mode 100644
index 60fc16d9d0..0000000000
--- a/package/libp11/0001-src-p11_attr.c-fix-build-with-gcc-4.8.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From ba44b87318ed89e489fa3ce0a5d66002afa2bd6c Mon Sep 17 00:00:00 2001
-From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
-Date: Fri, 12 Aug 2022 11:54:54 +0200
-Subject: [PATCH] src/p11_attr.c: fix build with gcc 4.8
-
-Fix the following build failure with gcc 4.8 raised since version 0.4.12
-and
-https://github.com/OpenSC/libp11/commit/639a4b6463278c0119a2ec60b261da3e5330fb33:
-
-p11_attr.c: In function 'pkcs11_zap_attrs':
-p11_attr.c:167:2: error: 'for' loop initial declarations are only allowed in C99 mode
-  for (unsigned i = 0; i < 32; i++) {
-  ^
-p11_attr.c:167:2: note: use option -std=c99 or -std=gnu99 to compile your code
-
-Fixes:
- - http://autobuild.buildroot.org/results/4391020fb5738cc8c26dc53783a6228bbf76473a
-
-Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
-[Retrieved from:
-https://github.com/OpenSC/libp11/commit/ba44b87318ed89e489fa3ce0a5d66002afa2bd6c]
----
- src/p11_attr.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/src/p11_attr.c b/src/p11_attr.c
-index d49456ff..d425241a 100644
---- a/src/p11_attr.c
-+++ b/src/p11_attr.c
-@@ -162,9 +162,11 @@ void pkcs11_addattr_obj(PKCS11_TEMPLATE *tmpl, int type, pkcs11_i2d_fn enc, void
- 
- void pkcs11_zap_attrs(PKCS11_TEMPLATE *tmpl)
- {
-+	unsigned int i;
-+
- 	if (!tmpl->allocated)
- 		return;
--	for (unsigned i = 0; i < 32; i++) {
-+	for (i = 0; i < 32; i++) {
- 		if (tmpl->allocated & (1<<i))
- 			OPENSSL_free(tmpl->attrs[i].pValue);
- 	}
diff --git a/package/libp11/libp11.hash b/package/libp11/libp11.hash
index 0e42bdd4cf..52d73d4206 100644
--- a/package/libp11/libp11.hash
+++ b/package/libp11/libp11.hash
@@ -1,3 +1,3 @@
 # Locally computed:
-sha256  1e1a2533b3fcc45fde4da64c9c00261b1047f14c3f911377ebd1b147b3321cfd  libp11-0.4.12.tar.gz
+sha256  57d47a12a76fd92664ae30032cf969284ebac1dfc25bf824999d74b016d51366  libp11-0.4.11.tar.gz
 sha256  d80c9d084ebfb50ea1ed91bfbc2410d6ce542097a32c43b00781b83adcb8c77f  COPYING
diff --git a/package/libp11/libp11.mk b/package/libp11/libp11.mk
index 7718573ace..c1873a920c 100644
--- a/package/libp11/libp11.mk
+++ b/package/libp11/libp11.mk
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-LIBP11_VERSION = 0.4.12
+LIBP11_VERSION = 0.4.11
 LIBP11_SITE = https://github.com/OpenSC/libp11/releases/download/libp11-$(LIBP11_VERSION)
 LIBP11_DEPENDENCIES = openssl host-pkgconf
 LIBP11_INSTALL_STAGING = YES
-- 
2.34.1

