+static int
+queue_ops_rsa_sign_verify(struct rte_cryptodev_asym_session *sess)
+{
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
+ struct rte_mempool *op_mpool = ts_params->op_mpool;
+ uint8_t dev_id = ts_params->valid_devs[0];
+ struct rte_crypto_op *op, *result_op;
+ struct rte_crypto_asym_op *asym_op;
+ uint8_t output_buf[TEST_DATA_SIZE];
+ int status = TEST_SUCCESS;
+
+ /* Set up crypto op data structure */
+ op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+ if (!op) {
+ RTE_LOG(ERR, USER1, "Failed to allocate asymmetric crypto "
+ "operation struct\n");
+ return TEST_FAILED;
+ }
+
+ asym_op = op->asym;
+
+ /* 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.data = output_buf;
+ asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT1;
+
+ debug_hexdump(stdout, "message", asym_op->rsa.message.data,
+ asym_op->rsa.message.length);
+
+ /* Attach asymmetric crypto session to crypto operations */
+ rte_crypto_op_attach_asym_session(op, sess);
+
+ RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
+
+ /* Process crypto operation */
+ if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+ RTE_LOG(ERR, USER1, "Error sending packet for sign\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 sign op\n");
+ status = TEST_FAILED;
+ goto error_exit;
+ }
+
+ debug_hexdump(stdout, "signed message", asym_op->rsa.sign.data,
+ asym_op->rsa.sign.length);
+ asym_op = result_op->asym;
+
+ /* Verify sign */
+ asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
+ asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT1;
+
+ /* Process crypto operation */
+ if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+ RTE_LOG(ERR, USER1, "Error sending packet for verify\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 verify op\n");
+ status = TEST_FAILED;
+ goto error_exit;
+ }
+
+ status = TEST_SUCCESS;
+ if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ RTE_LOG(ERR, USER1, "Failed to process sign-verify op\n");
+ status = TEST_FAILED;
+ }
+
+error_exit:
+
+ rte_crypto_op_free(op);
+
+ return status;
+}
+
+static int
+queue_ops_rsa_enc_dec(struct rte_cryptodev_asym_session *sess)
+{
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
+ struct rte_mempool *op_mpool = ts_params->op_mpool;
+ uint8_t dev_id = ts_params->valid_devs[0];
+ struct rte_crypto_op *op, *result_op;
+ struct rte_crypto_asym_op *asym_op;
+ int ret, status = TEST_SUCCESS;
+
+ /* Set up crypto op data structure */
+ op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+ if (!op) {
+ RTE_LOG(ERR, USER1, "Failed to allocate asymmetric crypto "
+ "operation struct\n");
+ return TEST_FAILED;
+ }
+
+ asym_op = op->asym;
+
+ /* 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.message.length = rsaplaintext.len;
+ asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT2;
+
+ debug_hexdump(stdout, "message", asym_op->rsa.message.data,
+ asym_op->rsa.message.length);
+
+ /* Attach asymmetric crypto session to crypto operations */
+ rte_crypto_op_attach_asym_session(op, sess);
+
+ RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
+
+ /* Process crypto operation */
+ if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+ RTE_LOG(ERR, USER1, "Error sending packet for encryption\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 encryption op\n");
+ status = TEST_FAILED;
+ goto error_exit;
+ }
+ debug_hexdump(stdout, "encrypted message", asym_op->rsa.message.data,
+ asym_op->rsa.message.length);
+
+ /* Use the resulted output as decryption Input vector*/
+ asym_op = result_op->asym;
+ asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
+ asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT2;
+
+ /* Process crypto operation */
+ if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+ 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;
+}