From 78a41ef0795c00692fcb2a89450c4cd0dc654d07 Mon Sep 17 00:00:00 2001 From: Tirupatigopi Ravulapalli Date: Wed, 29 May 2024 15:53:59 -0400 Subject: [PATCH] Fix for RSA failure with SVM enabled in openssl-3.2 - Description: - SVM case pointer directly copying to inputData.pData and doing padding - Decrypting data is not equal to plain text zero - Fix: - Before padding creating memory using qat_mem_alloc(), - And passing this address to padding API - Due to this we are verifying successfully in zero plain text case Signed-off-by: Tirupatigopi Ravulapalli --- qat_hw_rsa.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/qat_hw_rsa.c b/qat_hw_rsa.c index d64b6e1..16a68ad 100644 --- a/qat_hw_rsa.c +++ b/qat_hw_rsa.c @@ -162,8 +162,7 @@ rsa_decrypt_op_buf_free(CpaCyRsaDecryptOpData * dec_op_data, DEBUG("- Started\n"); if (dec_op_data) { - if (dec_op_data->inputData.pData && !qat_svm) - qaeCryptoMemFreeNonZero(dec_op_data->inputData.pData); + QAT_CLEANSE_MEMFREE_NONZERO_FLATBUFF(dec_op_data->inputData, qat_svm); if (dec_op_data->pRecipientPrivateKey) { key = &dec_op_data->pRecipientPrivateKey->privateKeyRep2; @@ -510,12 +509,9 @@ build_decrypt_op_buf(int flen, const unsigned char *from, unsigned char *to, return 0; } - if (qat_svm) - (*dec_op_data)->inputData.pData = (Cpa8U *) from; - else - (*dec_op_data)->inputData.pData = (Cpa8U *) qaeCryptoMemAlloc( - ((padding != RSA_NO_PADDING) && alloc_pad) ? rsa_len : flen, - __FILE__,__LINE__); + (*dec_op_data)->inputData.pData = (Cpa8U *) qat_mem_alloc( + ((padding != RSA_NO_PADDING) && alloc_pad) ? rsa_len : flen, qat_svm, + __FILE__,__LINE__); if (NULL == (*dec_op_data)->inputData.pData) { WARN("Failed to allocate (*dec_op_data)->inputData.pData\n");