+ RTE_LOG(ERR, USER1, "Error sending packet for decryption\n");
+ status = TEST_FAILED;
+ goto error_exit;
+ }
+
+ while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+ rte_pause();
+
+ if (result_op == NULL) {
+ RTE_LOG(ERR, USER1, "Failed to process decryption op\n");
+ status = TEST_FAILED;
+ goto error_exit;
+ }
+ status = TEST_SUCCESS;
+ ret = rsa_verify(&rsaplaintext, result_op);
+ if (ret)
+ status = TEST_FAILED;
+
+error_exit:
+
+ rte_crypto_op_free(op);
+
+ return status;
+}
+static int
+test_cryptodev_asym_ver(union test_case_structure *data_tc,
+ struct rte_crypto_op *result_op)
+{
+ int status = TEST_SUCCESS;
+ int ret = 0;
+ uint8_t *data_expected = NULL, *data_received = NULL;
+ size_t data_size = 0;
+
+ switch (data_tc->modex.xform_type) {
+ case RTE_CRYPTO_ASYM_XFORM_MODEX:
+ data_expected = data_tc->modex.reminder.data;
+ data_received = result_op->asym->modex.result.data;
+ data_size = result_op->asym->modex.result.length;
+ break;
+ case RTE_CRYPTO_ASYM_XFORM_MODINV:
+ data_expected = data_tc->modinv.inverse.data;
+ data_received = result_op->asym->modinv.result.data;
+ data_size = result_op->asym->modinv.result.length;
+ break;
+ case RTE_CRYPTO_ASYM_XFORM_DH:
+ case RTE_CRYPTO_ASYM_XFORM_DSA:
+ case RTE_CRYPTO_ASYM_XFORM_RSA:
+ case RTE_CRYPTO_ASYM_XFORM_NONE:
+ case RTE_CRYPTO_ASYM_XFORM_UNSPECIFIED:
+ default:
+ break;
+ }
+ ret = memcmp(data_expected, data_received, data_size);
+ if (ret)
+ status = TEST_FAILED;
+
+ return status;
+}
+
+static int
+test_cryptodev_asym_op(struct crypto_testsuite_params *ts_params,
+ union test_case_structure *data_tc,
+ char *test_msg, int sessionless)
+{
+ struct rte_crypto_asym_op *asym_op = NULL;
+ struct rte_crypto_op *op = NULL;
+ struct rte_crypto_op *result_op = NULL;
+ struct rte_crypto_asym_xform xform_tc;
+ struct rte_cryptodev_asym_session *sess = NULL;
+ struct rte_cryptodev_asym_capability_idx cap_idx;
+ const struct rte_cryptodev_asymmetric_xform_capability *capability;
+ uint8_t dev_id = ts_params->valid_devs[0];
+ uint8_t input[TEST_DATA_SIZE] = {0};
+ uint8_t *result = NULL;
+
+ int status = TEST_SUCCESS;
+
+ xform_tc.next = NULL;
+ xform_tc.xform_type = data_tc->modex.xform_type;
+
+ cap_idx.type = xform_tc.xform_type;
+ capability = rte_cryptodev_asym_capability_get(dev_id, &cap_idx);
+
+ if (capability == NULL) {
+ RTE_LOG(INFO, USER1,
+ "Device doesn't support MODEX. Test Skipped\n");
+ return -ENOTSUP;
+ }
+
+ /* Generate crypto op data structure */
+ op = rte_crypto_op_alloc(ts_params->op_mpool,
+ RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+
+ if (!op) {
+ snprintf(test_msg, ASYM_TEST_MSG_LEN,
+ "line %u FAILED: %s",
+ __LINE__, "Failed to allocate asymmetric crypto "
+ "operation struct");
+ status = TEST_FAILED;
+ goto error_exit;
+ }
+
+ asym_op = op->asym;
+
+ switch (xform_tc.xform_type) {
+ case RTE_CRYPTO_ASYM_XFORM_MODEX:
+ result = rte_zmalloc(NULL, data_tc->modex.result_len, 0);
+ xform_tc.modex.modulus.data = data_tc->modex.modulus.data;
+ xform_tc.modex.modulus.length = data_tc->modex.modulus.len;
+ xform_tc.modex.exponent.data = data_tc->modex.exponent.data;
+ xform_tc.modex.exponent.length = data_tc->modex.exponent.len;
+ memcpy(input, data_tc->modex.base.data,
+ data_tc->modex.base.len);
+ asym_op->modex.base.data = input;
+ asym_op->modex.base.length = data_tc->modex.base.len;
+ asym_op->modex.result.data = result;
+ asym_op->modex.result.length = data_tc->modex.result_len;
+ if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
+ xform_tc.modex.modulus.length)) {
+ snprintf(test_msg, ASYM_TEST_MSG_LEN,
+ "line %u "
+ "FAILED: %s", __LINE__,
+ "Invalid MODULUS length specified");
+ status = TEST_FAILED;
+ goto error_exit;
+ }
+ break;
+ case RTE_CRYPTO_ASYM_XFORM_MODINV:
+ result = rte_zmalloc(NULL, data_tc->modinv.result_len, 0);
+ xform_tc.modinv.modulus.data = data_tc->modinv.modulus.data;
+ xform_tc.modinv.modulus.length = data_tc->modinv.modulus.len;
+ memcpy(input, data_tc->modinv.base.data,
+ data_tc->modinv.base.len);
+ asym_op->modinv.base.data = input;
+ asym_op->modinv.base.length = data_tc->modinv.base.len;
+ asym_op->modinv.result.data = result;
+ asym_op->modinv.result.length = data_tc->modinv.result_len;
+ if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
+ xform_tc.modinv.modulus.length)) {
+ snprintf(test_msg, ASYM_TEST_MSG_LEN,
+ "line %u "
+ "FAILED: %s", __LINE__,
+ "Invalid MODULUS length specified");
+ status = TEST_FAILED;
+ goto error_exit;
+ }
+ break;
+ case RTE_CRYPTO_ASYM_XFORM_DH:
+ case RTE_CRYPTO_ASYM_XFORM_DSA:
+ case RTE_CRYPTO_ASYM_XFORM_RSA:
+ case RTE_CRYPTO_ASYM_XFORM_NONE:
+ case RTE_CRYPTO_ASYM_XFORM_UNSPECIFIED:
+ default:
+ snprintf(test_msg, ASYM_TEST_MSG_LEN,
+ "line %u "
+ "FAILED: %s", __LINE__,
+ "Invalid ASYM algorithm specified");
+ status = TEST_FAILED;
+ goto error_exit;
+ }
+
+ if (!sessionless) {
+ sess = rte_cryptodev_asym_session_create(ts_params->session_mpool);
+ if (!sess) {
+ snprintf(test_msg, ASYM_TEST_MSG_LEN,
+ "line %u "
+ "FAILED: %s", __LINE__,
+ "Session creation failed");
+ status = TEST_FAILED;
+ goto error_exit;
+ }
+
+ if (rte_cryptodev_asym_session_init(dev_id, sess, &xform_tc,
+ ts_params->session_mpool) < 0) {
+ snprintf(test_msg, ASYM_TEST_MSG_LEN,
+ "line %u FAILED: %s",
+ __LINE__, "unabled to config sym session");
+ status = TEST_FAILED;
+ goto error_exit;
+ }
+
+ rte_crypto_op_attach_asym_session(op, sess);
+ } else {
+ asym_op->xform = &xform_tc;
+ op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
+ }
+ RTE_LOG(DEBUG, USER1, "Process ASYM operation");
+
+ /* Process crypto operation */
+ if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+ snprintf(test_msg, ASYM_TEST_MSG_LEN,