Blame SOURCES/0001-tpm2-Do-not-call-EVP_PKEY_CTX_set0_rsa_oaep_label-fo.patch

1b023f
From e4261984374556da65c9d46097d5a1200b335c0c Mon Sep 17 00:00:00 2001
1b023f
From: Juergen Repp <juergen.repp@sit.fraunhofer.de>
1b023f
Date: Sat, 19 Feb 2022 12:59:32 +0100
1b023f
Subject: [PATCH] tpm2: Do not call EVP_PKEY_CTX_set0_rsa_oaep_label() for
1b023f
 label of size 0 (OSSL 3)
1b023f
1b023f
Openssl 3.0 did return an error if EVP_PKEY_CTX_set0_rsa_oaep_label was called
1b023f
with label size 0. The function should only be called if the size of the label
1b023f
is greater 0.
1b023f
With this fix TPM2_RSA_Encrypt/Decrypt did work with OpenSSL 1.1 and 3.0
1b023f
for encryption without label.
1b023f
1b023f
Signed-off-by: Juergen Repp <juergen.repp@sit.fraunhofer.de>
1b023f
---
1b023f
 src/tpm2/crypto/openssl/CryptRsa.c | 5 ++---
1b023f
 1 file changed, 2 insertions(+), 3 deletions(-)
1b023f
1b023f
diff --git a/src/tpm2/crypto/openssl/CryptRsa.c b/src/tpm2/crypto/openssl/CryptRsa.c
1b023f
index 4ed04384feb0..b5d6b6c3be82 100644
1b023f
--- a/src/tpm2/crypto/openssl/CryptRsa.c
1b023f
+++ b/src/tpm2/crypto/openssl/CryptRsa.c
1b023f
@@ -1356,10 +1356,9 @@ CryptRsaEncrypt(
1b023f
                 if (tmp == NULL)
1b023f
                     ERROR_RETURN(TPM_RC_FAILURE);
1b023f
                 memcpy(tmp, label->buffer, label->size);
1b023f
+                if (EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, tmp, label->size) <= 0)
1b023f
+                    ERROR_RETURN(TPM_RC_FAILURE);
1b023f
             }
1b023f
-            // label->size == 0 is supported
1b023f
-            if (EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, tmp, label->size) <= 0)
1b023f
-                ERROR_RETURN(TPM_RC_FAILURE);
1b023f
             tmp = NULL;
1b023f
             break;
1b023f
           default:
1b023f
-- 
1b023f
2.36.0.44.g0f828332d5ac
1b023f