[PATCH v2 3/3] crypto/qat: fix not set rsa lengths

Arek Kusztal arkadiuszx.kusztal at intel.com
Tue Oct 18 15:53:34 CEST 2022


Fixed not set output length in asym pmd
when doing RSA.

Fixes: 002486db239e ("crypto/qat: refactor asymmetric session")

Signed-off-by: Arek Kusztal <arkadiuszx.kusztal at intel.com>
---
v2:
- fixed compilation issues
- split into 3 patches

 drivers/crypto/qat/qat_asym.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c
index 0eb5ba79bc..05ca95319b 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -508,21 +508,19 @@ rsa_collect(struct rte_crypto_asym_op *asym_op,
 
 		if (asym_op->rsa.op_type ==
 				RTE_CRYPTO_ASYM_OP_ENCRYPT) {
-			uint8_t *rsa_result = asym_op->rsa.cipher.data;
-
-			rte_memcpy(rsa_result,
+			rte_memcpy(asym_op->rsa.cipher.data,
 					cookie->output_array[0],
 					alg_bytesize);
+			asym_op->rsa.cipher.length = alg_bytesize;
 			HEXDUMP("RSA Encrypted data", cookie->output_array[0],
 				alg_bytesize);
 		} else {
-			uint8_t *rsa_result = asym_op->rsa.cipher.data;
-
 			switch (asym_op->rsa.padding.type) {
 			case RTE_CRYPTO_RSA_PADDING_NONE:
-				rte_memcpy(rsa_result,
+				rte_memcpy(asym_op->rsa.cipher.data,
 						cookie->output_array[0],
 						alg_bytesize);
+				asym_op->rsa.cipher.length = alg_bytesize;
 				HEXDUMP("RSA signature",
 					cookie->output_array[0],
 					alg_bytesize);
@@ -534,13 +532,12 @@ rsa_collect(struct rte_crypto_asym_op *asym_op,
 		}
 	} else {
 		if (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) {
-			uint8_t *rsa_result = asym_op->rsa.message.data;
-
 			switch (asym_op->rsa.padding.type) {
 			case RTE_CRYPTO_RSA_PADDING_NONE:
-				rte_memcpy(rsa_result,
+				rte_memcpy(asym_op->rsa.message.data,
 					cookie->output_array[0],
 					alg_bytesize);
+				asym_op->rsa.message.length = alg_bytesize;
 				HEXDUMP("RSA Decrypted Message",
 					cookie->output_array[0],
 					alg_bytesize);
@@ -550,11 +547,10 @@ rsa_collect(struct rte_crypto_asym_op *asym_op,
 				return RTE_CRYPTO_OP_STATUS_ERROR;
 			}
 		} else {
-			uint8_t *rsa_result = asym_op->rsa.sign.data;
-
-			rte_memcpy(rsa_result,
-					cookie->output_array[0],
-					alg_bytesize);
+			rte_memcpy(asym_op->rsa.sign.data,
+				cookie->output_array[0],
+				alg_bytesize);
+			asym_op->rsa.sign.length = alg_bytesize;
 			HEXDUMP("RSA Signature", cookie->output_array[0],
 				alg_bytesize);
 		}
-- 
2.13.6



More information about the dev mailing list