Blame SOURCES/0005-FAPI-Test-Call-EVP_DigestSignInit-in-the-correct-ord.patch

a56c8e
From 563f9c951d9b050378b9d3659a932c98ab587b21 Mon Sep 17 00:00:00 2001
a56c8e
From: Petr Gotthard <petr.gotthard@centrum.cz>
a56c8e
Date: Sat, 17 Jul 2021 21:22:28 +0200
a56c8e
Subject: FAPI Test: Call EVP_DigestSignInit in the correct order
a56c8e
MIME-Version: 1.0
a56c8e
Content-Type: text/plain; charset=UTF-8
a56c8e
Content-Transfer-Encoding: 8bit
a56c8e
a56c8e
The EVP_DigestSignInit should be called only once and before calling
a56c8e
EVP_PKEY_CTX_set_rsa_padding. See a corresponding example
a56c8e
[here](https://www.openssl.org/docs/man1.0.2/man3/EVP_PKEY_sign_init.html)
a56c8e
a56c8e
Current code works with OpenSSL 1.x, but fails with OpenSSL 3.0.
a56c8e
This PR makes the code compatible with OpenSSL 1.0 through 3.0.
a56c8e
a56c8e
Signed-off-by: Petr Gotthard <petr.gotthard@centrum.cz>
a56c8e
---
a56c8e
 test/integration/fapi-data-crypt.int.c               | 8 ++------
a56c8e
 test/integration/fapi-key-create-policy-signed.int.c | 8 ++------
a56c8e
 2 files changed, 4 insertions(+), 12 deletions(-)
a56c8e
a56c8e
diff --git a/test/integration/fapi-data-crypt.int.c b/test/integration/fapi-data-crypt.int.c
a56c8e
index b2d20b28..d42466db 100644
a56c8e
--- a/test/integration/fapi-data-crypt.int.c
a56c8e
+++ b/test/integration/fapi-data-crypt.int.c
a56c8e
@@ -129,8 +129,8 @@ signatureCallback(
a56c8e
     mdctx = EVP_MD_CTX_create();
a56c8e
     chknull(mdctx);
a56c8e
 
a56c8e
-    if (1 != EVP_DigestSignInit(mdctx, &pctx, NULL, NULL, priv_key)) {
a56c8e
-        goto_error(r, TSS2_FAPI_RC_GENERAL_FAILURE, "OSSL digest sign init.",
a56c8e
+    if (1 != EVP_DigestSignInit(mdctx, &pctx, ossl_hash, NULL, priv_key)) {
a56c8e
+        goto_error(r, TSS2_FAPI_RC_GENERAL_FAILURE, "OSSL sign init.",
a56c8e
                    error_cleanup);
a56c8e
     }
a56c8e
     if (EVP_PKEY_type(EVP_PKEY_id(priv_key)) == EVP_PKEY_RSA) {
a56c8e
@@ -140,10 +140,6 @@ signatureCallback(
a56c8e
                        error_cleanup);
a56c8e
         }
a56c8e
     }
a56c8e
-    if (1 != EVP_DigestSignInit(mdctx, &pctx, ossl_hash, NULL, priv_key)) {
a56c8e
-        goto_error(r, TSS2_FAPI_RC_GENERAL_FAILURE, "OSSL sign init.",
a56c8e
-                   error_cleanup);
a56c8e
-    }
a56c8e
     if (1 != EVP_DigestSignUpdate(mdctx, dataToSign, dataToSignSize)) {
a56c8e
         goto_error(r, TSS2_FAPI_RC_GENERAL_FAILURE, "OSSL sign update.",
a56c8e
                    error_cleanup);
a56c8e
diff --git a/test/integration/fapi-key-create-policy-signed.int.c b/test/integration/fapi-key-create-policy-signed.int.c
a56c8e
index e51289a6..b903dec0 100644
a56c8e
--- a/test/integration/fapi-key-create-policy-signed.int.c
a56c8e
+++ b/test/integration/fapi-key-create-policy-signed.int.c
a56c8e
@@ -144,8 +144,8 @@ signatureCallback(
a56c8e
     mdctx = EVP_MD_CTX_create();
a56c8e
     chknull(mdctx);
a56c8e
 
a56c8e
-    if (1 != EVP_DigestSignInit(mdctx, &pctx, NULL, NULL, priv_key)) {
a56c8e
-        goto_error(r, TSS2_FAPI_RC_GENERAL_FAILURE, "OSSL digest sign init.",
a56c8e
+    if (1 != EVP_DigestSignInit(mdctx, &pctx, ossl_hash, NULL, priv_key)) {
a56c8e
+        goto_error(r, TSS2_FAPI_RC_GENERAL_FAILURE, "OSSL sign init.",
a56c8e
                    error_cleanup);
a56c8e
     }
a56c8e
     if (EVP_PKEY_type(EVP_PKEY_id(priv_key)) == EVP_PKEY_RSA) {
a56c8e
@@ -155,10 +155,6 @@ signatureCallback(
a56c8e
                        error_cleanup);
a56c8e
         }
a56c8e
     }
a56c8e
-    if (1 != EVP_DigestSignInit(mdctx, &pctx, ossl_hash, NULL, priv_key)) {
a56c8e
-        goto_error(r, TSS2_FAPI_RC_GENERAL_FAILURE, "OSSL sign init.",
a56c8e
-                   error_cleanup);
a56c8e
-    }
a56c8e
     if (1 != EVP_DigestSignUpdate(mdctx, dataToSign, dataToSignSize)) {
a56c8e
         goto_error(r, TSS2_FAPI_RC_GENERAL_FAILURE, "OSSL sign update.",
a56c8e
                    error_cleanup);
a56c8e
-- 
a56c8e
2.26.3
a56c8e