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

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