Blame SOURCES/openssl-pkcs11-0.4.10-openssl3.patch

a5d914
From 433947efff5712a6a3960c53e8b99e4fe123aace Mon Sep 17 00:00:00 2001
a5d914
From: Jakub Jelen <jjelen@redhat.com>
a5d914
Date: Wed, 19 May 2021 14:23:27 +0200
a5d914
Subject: [PATCH] Do not modify EC/RSA structures after assigning them to
a5d914
 EVP_PKEY
a5d914
a5d914
This was causing OpenSSL 3.0 to fail detect our RSA/EC methods and
a5d914
failing the tests ({ec,rsa}-testfork.softhsm).
a5d914
a5d914
The OpenSSL issue:
a5d914
https://github.com/openssl/openssl/issues/15350
a5d914
---
a5d914
 src/p11_ec.c  | 2 +-
a5d914
 src/p11_rsa.c | 4 ++--
a5d914
 2 files changed, 3 insertions(+), 3 deletions(-)
a5d914
a5d914
diff --git a/src/p11_ec.c b/src/p11_ec.c
a5d914
index 294cbad..9c5ee0f 100644
a5d914
--- a/src/p11_ec.c
a5d914
+++ b/src/p11_ec.c
a5d914
@@ -365,7 +365,6 @@ static EVP_PKEY *pkcs11_get_evp_key_ec(PKCS11_KEY *key)
a5d914
 		EC_KEY_free(ec);
a5d914
 		return NULL;
a5d914
 	}
a5d914
-	EVP_PKEY_set1_EC_KEY(pk, ec); /* Also increments the ec ref count */
a5d914
 
a5d914
 	if (key->isPrivate) {
a5d914
 #if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
a5d914
@@ -379,6 +378,7 @@ static EVP_PKEY *pkcs11_get_evp_key_ec(PKCS11_KEY *key)
a5d914
 	 * unless the key has the "sensitive" attribute set */
a5d914
 
a5d914
 	pkcs11_set_ex_data_ec(ec, key);
a5d914
+	EVP_PKEY_set1_EC_KEY(pk, ec); /* Also increments the ec ref count */
a5d914
 	EC_KEY_free(ec); /* Drops our reference to it */
a5d914
 	return pk;
a5d914
 }
a5d914
diff --git a/src/p11_rsa.c b/src/p11_rsa.c
a5d914
index f2f3eb3..183cce2 100644
a5d914
--- a/src/p11_rsa.c
a5d914
+++ b/src/p11_rsa.c
a5d914
@@ -286,8 +286,6 @@ static EVP_PKEY *pkcs11_get_evp_key_rsa(PKCS11_KEY *key)
a5d914
 		RSA_free(rsa);
a5d914
 		return NULL;
a5d914
 	}
a5d914
-	EVP_PKEY_set1_RSA(pk, rsa); /* Also increments the rsa ref count */
a5d914
-
a5d914
 	if (key->isPrivate) {
a5d914
 		RSA_set_method(rsa, PKCS11_get_rsa_method());
a5d914
 #if OPENSSL_VERSION_NUMBER >= 0x10100005L && !defined(LIBRESSL_VERSION_NUMBER)
a5d914
@@ -304,6 +302,8 @@ static EVP_PKEY *pkcs11_get_evp_key_rsa(PKCS11_KEY *key)
a5d914
 	rsa->flags |= RSA_FLAG_SIGN_VER;
a5d914
 #endif
a5d914
 	pkcs11_set_ex_data_rsa(rsa, key);
a5d914
+
a5d914
+	EVP_PKEY_set1_RSA(pk, rsa); /* Also increments the rsa ref count */
a5d914
 	RSA_free(rsa); /* Drops our reference to it */
a5d914
 	return pk;
a5d914
 }
a5d914