diff mbox series

[36/40] test/crypto: reduce rsa struct to only necessary fields

Message ID 20220520055445.40063-37-arkadiuszx.kusztal@intel.com (mailing list archive)
State Changes Requested
Delegated to: akhil goyal
Headers show
Series cryptodev: rsa, dh, ecdh changes | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Kusztal, ArkadiuszX May 20, 2022, 5:54 a.m. UTC
- reduced rsa struct to only necessary fields.
This commit reflects changes to the asymmetric crypto API.

Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
---
 app/test/test_cryptodev_asym.c | 80 +++++++++++++++++++++++-------------------
 1 file changed, 43 insertions(+), 37 deletions(-)
diff mbox series

Patch

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index eca0612815..ed86eaf8ba 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -90,14 +90,14 @@  queue_ops_rsa_sign_verify(void *sess)
 	/* Compute sign on the test vector */
 	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
 
-	asym_op->rsa.message.data = rsaplaintext.data;
-	asym_op->rsa.message.length = rsaplaintext.len;
-	asym_op->rsa.sign.length = 0;
-	asym_op->rsa.sign.data = output_buf;
+	asym_op->rsa.input.data = rsaplaintext.data;
+	asym_op->rsa.input.length = rsaplaintext.len;
+	asym_op->rsa.output.length = 0;
+	asym_op->rsa.output.data = output_buf;
 	asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
 
-	debug_hexdump(stdout, "message", asym_op->rsa.message.data,
-		      asym_op->rsa.message.length);
+	debug_hexdump(stdout, "message", asym_op->rsa.input.data,
+		      asym_op->rsa.input.length);
 
 	/* Attach asymmetric crypto session to crypto operations */
 	rte_crypto_op_attach_asym_session(op, sess);
@@ -120,13 +120,17 @@  queue_ops_rsa_sign_verify(void *sess)
 		goto error_exit;
 	}
 
-	debug_hexdump(stdout, "signed message", asym_op->rsa.sign.data,
-		      asym_op->rsa.sign.length);
+	debug_hexdump(stdout, "signed message", asym_op->rsa.output.data,
+		      asym_op->rsa.output.length);
 	asym_op = result_op->asym;
 
 	/* Verify sign */
 	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
 	asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
+	asym_op->rsa.input.data = output_buf;
+	asym_op->rsa.input.length = asym_op->rsa.output.length;
+	asym_op->rsa.message.data = rsaplaintext.data;
+	asym_op->rsa.message.length = rsaplaintext.len;
 
 	/* Process crypto operation */
 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
@@ -181,14 +185,14 @@  queue_ops_rsa_enc_dec(void *sess)
 	/* Compute encryption on the test vector */
 	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
 
-	asym_op->rsa.message.data = rsaplaintext.data;
-	asym_op->rsa.cipher.data = cipher_buf;
-	asym_op->rsa.cipher.length = 0;
-	asym_op->rsa.message.length = rsaplaintext.len;
+	asym_op->rsa.input.data = rsaplaintext.data;
+	asym_op->rsa.output.data = cipher_buf;
+	asym_op->rsa.output.length = 0;
+	asym_op->rsa.input.length = rsaplaintext.len;
 	asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
 
-	debug_hexdump(stdout, "message", asym_op->rsa.message.data,
-		      asym_op->rsa.message.length);
+	debug_hexdump(stdout, "message", asym_op->rsa.input.data,
+		      asym_op->rsa.input.length);
 
 	/* Attach asymmetric crypto session to crypto operations */
 	rte_crypto_op_attach_asym_session(op, sess);
@@ -210,14 +214,16 @@  queue_ops_rsa_enc_dec(void *sess)
 		status = TEST_FAILED;
 		goto error_exit;
 	}
-	debug_hexdump(stdout, "encrypted message", asym_op->rsa.message.data,
-		      asym_op->rsa.message.length);
+	debug_hexdump(stdout, "encrypted message", asym_op->rsa.output.data,
+		      asym_op->rsa.output.length);
 
 	/* Use the resulted output as decryption Input vector*/
 	asym_op = result_op->asym;
-	asym_op->rsa.message.length = 0;
+	asym_op->rsa.output.length = 0;
 	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
 	asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
+	rte_memcpy(asym_op->rsa.input.data, asym_op->rsa.output.data,
+		asym_op->rsa.input.length);
 
 	/* Process crypto operation */
 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
@@ -270,20 +276,20 @@  test_cryptodev_asym_ver(struct rte_crypto_op *op,
 	case RTE_CRYPTO_ASYM_XFORM_RSA:
 		if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {
 			data_size = xform_tc->rsa.n.length;
-			data_received = result_op->asym->rsa.cipher.data;
+			data_received = result_op->asym->rsa.output.data;
 			data_expected = data_tc->rsa_data.ct.data;
 		} else if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) {
 			data_size = xform_tc->rsa.n.length;
 			data_expected = data_tc->rsa_data.pt.data;
-			data_received = result_op->asym->rsa.message.data;
+			data_received = result_op->asym->rsa.output.data;
 		} else if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
 			data_size = xform_tc->rsa.n.length;
 			data_expected = data_tc->rsa_data.sign.data;
-			data_received = result_op->asym->rsa.sign.data;
+			data_received = result_op->asym->rsa.output.data;
 		} else if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_VERIFY) {
 			data_size = xform_tc->rsa.n.length;
 			data_expected = data_tc->rsa_data.pt.data;
-			data_received = result_op->asym->rsa.cipher.data;
+			data_received = result_op->asym->rsa.output.data;
 		}
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_DH:
@@ -415,25 +421,25 @@  test_cryptodev_asym_op(struct crypto_testsuite_params_asym *ts_params,
 		op->asym->rsa.padding.type = data_tc->rsa_data.padding;
 
 		if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {
-			asym_op->rsa.message.data = data_tc->rsa_data.pt.data;
-			asym_op->rsa.message.length = data_tc->rsa_data.pt.len;
-			asym_op->rsa.cipher.data = result;
-			asym_op->rsa.cipher.length = data_tc->rsa_data.n.len;
+			asym_op->rsa.input.data = data_tc->rsa_data.pt.data;
+			asym_op->rsa.input.length = data_tc->rsa_data.pt.len;
+			asym_op->rsa.output.data = result;
+			asym_op->rsa.output.length = data_tc->rsa_data.n.len;
 		} else if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) {
-			asym_op->rsa.message.data = result;
-			asym_op->rsa.message.length = data_tc->rsa_data.n.len;
-			asym_op->rsa.cipher.data = data_tc->rsa_data.ct.data;
-			asym_op->rsa.cipher.length = data_tc->rsa_data.ct.len;
+			asym_op->rsa.output.data = result;
+			asym_op->rsa.output.length = data_tc->rsa_data.n.len;
+			asym_op->rsa.input.data = data_tc->rsa_data.ct.data;
+			asym_op->rsa.input.length = data_tc->rsa_data.ct.len;
 		} else if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
-			asym_op->rsa.sign.data = result;
-			asym_op->rsa.sign.length = data_tc->rsa_data.n.len;
-			asym_op->rsa.message.data = data_tc->rsa_data.pt.data;
-			asym_op->rsa.message.length = data_tc->rsa_data.pt.len;
+			asym_op->rsa.output.data = result;
+			asym_op->rsa.output.length = data_tc->rsa_data.n.len;
+			asym_op->rsa.input.data = data_tc->rsa_data.pt.data;
+			asym_op->rsa.input.length = data_tc->rsa_data.pt.len;
 		} else if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_VERIFY) {
-			asym_op->rsa.cipher.data = result;
-			asym_op->rsa.cipher.length = data_tc->rsa_data.n.len;
-			asym_op->rsa.sign.data = data_tc->rsa_data.sign.data;
-			asym_op->rsa.sign.length = data_tc->rsa_data.sign.len;
+			asym_op->rsa.message.data = result;
+			asym_op->rsa.message.length = data_tc->rsa_data.n.len;
+			asym_op->rsa.input.data = data_tc->rsa_data.sign.data;
+			asym_op->rsa.input.length = data_tc->rsa_data.sign.len;
 		}
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_DH: