mbuf: add a copy routine
[dpdk.git] / app / test / test_cryptodev_asym.c
index 2fe5b8f..e8177e7 100644 (file)
@@ -66,6 +66,185 @@ static uint32_t test_index;
 
 static struct crypto_testsuite_params testsuite_params = { NULL };
 
+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.length = 0;
+       asym_op->rsa.sign.data = output_buf;
+       asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
+
+       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_PADDING_PKCS1_5;
+
+       /* 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;
+       uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
+       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.cipher.data = cipher_buf;
+       asym_op->rsa.cipher.length = 0;
+       asym_op->rsa.message.length = rsaplaintext.len;
+       asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
+
+       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.message.length = 0;
+       asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
+       asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
+
+       /* 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;
+}
 static int
 test_cryptodev_asym_ver(union test_case_structure *data_tc,
                                                struct rte_crypto_op *result_op)
@@ -119,6 +298,18 @@ test_cryptodev_asym_op(struct crypto_testsuite_params *ts_params,
 
        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);
@@ -133,11 +324,6 @@ test_cryptodev_asym_op(struct crypto_testsuite_params *ts_params,
        }
 
        asym_op = op->asym;
-       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);
 
        switch (xform_tc.xform_type) {
        case RTE_CRYPTO_ASYM_XFORM_MODEX:
@@ -332,130 +518,93 @@ static int
 test_rsa_sign_verify(void)
 {
        struct crypto_testsuite_params *ts_params = &testsuite_params;
-       struct rte_mempool *op_mpool = ts_params->op_mpool;
        struct rte_mempool *sess_mpool = ts_params->session_mpool;
        uint8_t dev_id = ts_params->valid_devs[0];
-       struct rte_crypto_asym_op *asym_op = NULL;
-       struct rte_crypto_op *op = NULL, *result_op = NULL;
-       struct rte_cryptodev_asym_session *sess = NULL;
+       struct rte_cryptodev_asym_session *sess;
+       struct rte_cryptodev_info dev_info;
        int status = TEST_SUCCESS;
-       uint8_t output_buf[TEST_DATA_SIZE] = {0};
-       uint8_t input_buf[TEST_DATA_SIZE] = {0};
+
+       /* Test case supports op with exponent key only,
+        * Check in PMD feature flag for RSA exponent key type support.
+        */
+       rte_cryptodev_info_get(dev_id, &dev_info);
+       if (!(dev_info.feature_flags &
+                               RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_EXP)) {
+               RTE_LOG(INFO, USER1, "Device doesn't support sign op with "
+                       "exponent key type. Test Skipped\n");
+               return -ENOTSUP;
+       }
 
        sess = rte_cryptodev_asym_session_create(sess_mpool);
 
        if (!sess) {
-               RTE_LOG(ERR, USER1, "line %u "
-                               "FAILED: %s", __LINE__,
-                               "Session creation failed");
-               status = TEST_FAILED;
-               goto error_exit;
+               RTE_LOG(ERR, USER1, "Session creation failed for "
+                       "sign_verify\n");
+               return TEST_FAILED;
        }
 
        if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform,
                                sess_mpool) < 0) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "unabled to config sym session");
+               RTE_LOG(ERR, USER1, "Unable to config asym session for "
+                       "sign_verify\n");
                status = TEST_FAILED;
                goto error_exit;
        }
 
-       /* set up crypto op data structure */
-       op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
-       if (!op) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__,
-                               "Failed to allocate asymmetric crypto "
-                               "operation struct");
-               status = TEST_FAILED;
-               goto error_exit;
-       }
+       status = queue_ops_rsa_sign_verify(sess);
 
-       asym_op = op->asym;
-       /* Compute sign on the test vector */
-       asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
+error_exit:
 
-       memcpy(input_buf, &rsaplaintext.data,
-                       rsaplaintext.len);
-       asym_op->rsa.message.data = input_buf;
-       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;
+       rte_cryptodev_asym_session_clear(dev_id, sess);
+       rte_cryptodev_asym_session_free(sess);
 
-       debug_hexdump(stdout, "message", asym_op->rsa.message.data,
-                       asym_op->rsa.message.length);
+       TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
-       /* attach asymmetric crypto session to crypto operations */
-       rte_crypto_op_attach_asym_session(op, sess);
+       return status;
+}
 
-       RTE_LOG(DEBUG, USER1, "Process ASYM operation");
+static int
+test_rsa_enc_dec(void)
+{
+       struct crypto_testsuite_params *ts_params = &testsuite_params;
+       struct rte_mempool *sess_mpool = ts_params->session_mpool;
+       uint8_t dev_id = ts_params->valid_devs[0];
+       struct rte_cryptodev_asym_session *sess;
+       struct rte_cryptodev_info dev_info;
+       int status = TEST_SUCCESS;
 
-       /* Process crypto operation */
-       if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "Error sending packet for operation");
-               status = TEST_FAILED;
-               goto error_exit;
+       /* Test case supports op with exponent key only,
+        * Check in PMD feature flag for RSA exponent key type support.
+        */
+       rte_cryptodev_info_get(dev_id, &dev_info);
+       if (!(dev_info.feature_flags &
+                               RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_EXP)) {
+               RTE_LOG(INFO, USER1, "Device doesn't support decrypt op with "
+                       "exponent key type. Test skipped\n");
+               return -ENOTSUP;
        }
 
-       while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
-               rte_pause();
+       sess = rte_cryptodev_asym_session_create(sess_mpool);
 
-       if (result_op == NULL) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "Failed to process asym crypto op");
-               status = TEST_FAILED;
-               goto error_exit;
+       if (!sess) {
+               RTE_LOG(ERR, USER1, "Session creation failed for enc_dec\n");
+               return TEST_FAILED;
        }
-       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_BT2;
-
-       /* Process crypto operation */
-       if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "Error sending packet for operation");
+       if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform,
+                               sess_mpool) < 0) {
+               RTE_LOG(ERR, USER1, "Unable to config asym session for "
+                       "enc_dec\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,
-                               "line %u FAILED: %s",
-                               __LINE__, "Failed to process asym crypto op");
-               status = TEST_FAILED;
-               goto error_exit;
-       }
-       status = TEST_SUCCESS;
-       if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "Failed to process asym crypto op");
-               status = TEST_FAILED;
-               goto error_exit;
-       }
+       status = queue_ops_rsa_enc_dec(sess);
 
 error_exit:
 
-       if (sess) {
-               rte_cryptodev_asym_session_clear(dev_id, sess);
-               rte_cryptodev_asym_session_free(sess);
-       }
-
-       if (op)
-               rte_crypto_op_free(op);
+       rte_cryptodev_asym_session_clear(dev_id, sess);
+       rte_cryptodev_asym_session_free(sess);
 
        TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
@@ -463,127 +612,94 @@ error_exit:
 }
 
 static int
-test_rsa_enc_dec(void)
+test_rsa_sign_verify_crt(void)
 {
        struct crypto_testsuite_params *ts_params = &testsuite_params;
-       struct rte_mempool *op_mpool = ts_params->op_mpool;
        struct rte_mempool *sess_mpool = ts_params->session_mpool;
        uint8_t dev_id = ts_params->valid_devs[0];
-       struct rte_crypto_asym_op *asym_op = NULL;
-       struct rte_crypto_op *op = NULL, *result_op = NULL;
-       struct rte_cryptodev_asym_session *sess = NULL;
+       struct rte_cryptodev_asym_session *sess;
+       struct rte_cryptodev_info dev_info;
        int status = TEST_SUCCESS;
-       uint8_t input_buf[TEST_DATA_SIZE] = {0};
+
+       /* Test case supports op with quintuple format key only,
+        * Check im PMD feature flag for RSA quintuple key type support.
+        */
+       rte_cryptodev_info_get(dev_id, &dev_info);
+       if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
+               RTE_LOG(INFO, USER1, "Device doesn't support sign op with "
+                       "quintuple key type. Test skipped\n");
+               return -ENOTSUP;
+       }
 
        sess = rte_cryptodev_asym_session_create(sess_mpool);
 
        if (!sess) {
-               RTE_LOG(ERR, USER1, "line %u "
-                               "FAILED: %s", __LINE__,
-                               "Session creation failed");
+               RTE_LOG(ERR, USER1, "Session creation failed for "
+                       "sign_verify_crt\n");
                status = TEST_FAILED;
-               goto error_exit;
+               return status;
        }
 
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform,
+       if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt,
                                sess_mpool) < 0) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "unabled to config sym session");
+               RTE_LOG(ERR, USER1, "Unable to config asym session for "
+                       "sign_verify_crt\n");
                status = TEST_FAILED;
                goto error_exit;
        }
+       status = queue_ops_rsa_sign_verify(sess);
 
-       /* set up crypto op data structure */
-       op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
-       if (!op) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__,
-                               "Failed to allocate asymmetric crypto "
-                               "operation struct");
-               status = TEST_FAILED;
-               goto error_exit;
-       }
-
-       asym_op = op->asym;
-       /*Compute encryption on the test vector */
-       asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
+error_exit:
 
-       memcpy(input_buf, rsaplaintext.data,
-                       rsaplaintext.len);
-       asym_op->rsa.message.data = input_buf;
-       asym_op->rsa.message.length = rsaplaintext.len;
-       asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT2;
+       rte_cryptodev_asym_session_clear(dev_id, sess);
+       rte_cryptodev_asym_session_free(sess);
 
-       debug_hexdump(stdout, "message", asym_op->rsa.message.data,
-                       asym_op->rsa.message.length);
+       TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
-       /* attach asymmetric crypto session to crypto operations */
-       rte_crypto_op_attach_asym_session(op, sess);
+       return status;
+}
 
-       RTE_LOG(DEBUG, USER1, "Process ASYM operation");
+static int
+test_rsa_enc_dec_crt(void)
+{
+       struct crypto_testsuite_params *ts_params = &testsuite_params;
+       struct rte_mempool *sess_mpool = ts_params->session_mpool;
+       uint8_t dev_id = ts_params->valid_devs[0];
+       struct rte_cryptodev_asym_session *sess;
+       struct rte_cryptodev_info dev_info;
+       int status = TEST_SUCCESS;
 
-       /* Process crypto operation */
-       if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "Error sending packet for operation");
-               status = TEST_FAILED;
-               goto error_exit;
+       /* Test case supports op with quintuple format key only,
+        * Check in PMD feature flag for RSA quintuple key type support.
+        */
+       rte_cryptodev_info_get(dev_id, &dev_info);
+       if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
+               RTE_LOG(INFO, USER1, "Device doesn't support decrypt op with "
+                       "quintuple key type. Test skipped\n");
+               return -ENOTSUP;
        }
 
-       while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
-               rte_pause();
-
-       if (result_op == NULL) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "Failed to process asym crypto op");
-               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_BT1;
+       sess = rte_cryptodev_asym_session_create(sess_mpool);
 
-       /* Process crypto operation */
-       if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "Error sending packet for operation");
-               status = TEST_FAILED;
-               goto error_exit;
+       if (!sess) {
+               RTE_LOG(ERR, USER1, "Session creation failed for "
+                       "enc_dec_crt\n");
+               return TEST_FAILED;
        }
 
-       while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
-               rte_pause();
-
-       if (result_op == NULL) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "Failed to process asym crypto op");
+       if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt,
+                               sess_mpool) < 0) {
+               RTE_LOG(ERR, USER1, "Unable to config asym session for "
+                       "enc_dec_crt\n");
                status = TEST_FAILED;
                goto error_exit;
        }
-       status = TEST_SUCCESS;
-       int ret = 0;
-       ret = rsa_verify(&rsaplaintext, result_op);
-       if (ret)
-               status = TEST_FAILED;
+       status = queue_ops_rsa_enc_dec(sess);
 
 error_exit:
 
-       if (sess) {
-               rte_cryptodev_asym_session_clear(dev_id, sess);
-               rte_cryptodev_asym_session_free(sess);
-       }
-
-       if (op)
-               rte_crypto_op_free(op);
+       rte_cryptodev_asym_session_clear(dev_id, sess);
+       rte_cryptodev_asym_session_free(sess);
 
        TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
@@ -594,9 +710,10 @@ static int
 testsuite_setup(void)
 {
        struct crypto_testsuite_params *ts_params = &testsuite_params;
+       uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
        struct rte_cryptodev_info info;
-       uint32_t i = 0, nb_devs, dev_id;
-       int ret;
+       int ret, dev_id = -1;
+       uint32_t i, nb_devs;
        uint16_t qp_id;
 
        memset(ts_params, 0, sizeof(*ts_params));
@@ -632,39 +749,41 @@ testsuite_setup(void)
                }
        }
 
-       nb_devs = rte_cryptodev_count();
+       /* Get list of valid crypto devs */
+       nb_devs = rte_cryptodev_devices_get(
+                               rte_cryptodev_driver_name_get(gbl_driver_id),
+                               valid_devs, RTE_CRYPTO_MAX_DEVS);
        if (nb_devs < 1) {
                RTE_LOG(ERR, USER1, "No crypto devices found?\n");
                return TEST_FAILED;
        }
 
-       /* Create list of valid crypto devs */
-       for (i = 0; i < nb_devs; i++) {
-               rte_cryptodev_info_get(i, &info);
-               if (info.driver_id == gbl_driver_id)
-                       ts_params->valid_devs[ts_params->valid_dev_count++] = i;
+       /*
+        * Get first valid asymmetric device found in test suite param and
+        * break
+        */
+       for (i = 0; i < nb_devs ; i++) {
+               rte_cryptodev_info_get(valid_devs[i], &info);
+               if (info.feature_flags & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) {
+                       dev_id = ts_params->valid_devs[0] = valid_devs[i];
+                       break;
+               }
        }
 
-       if (ts_params->valid_dev_count < 1)
-               return TEST_FAILED;
-
-       /* Set up all the qps on the first of the valid devices found */
-
-       dev_id = ts_params->valid_devs[0];
-
-       rte_cryptodev_info_get(dev_id, &info);
-
-       /* check if device support asymmetric, skip if not */
-       if (!(info.feature_flags &
-                               RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO)) {
+       if (dev_id == -1) {
                RTE_LOG(ERR, USER1, "Device doesn't support asymmetric. "
-                               "Test Skipped.\n");
+                       "Test skipped.\n");
                return TEST_FAILED;
        }
 
+       /* Set valid device count */
+       ts_params->valid_dev_count = nb_devs;
+
        /* configure device with num qp */
        ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
        ts_params->conf.socket_id = SOCKET_ID_ANY;
+       ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY |
+                       RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO;
        TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
                        &ts_params->conf),
                        "Failed to configure cryptodev %u with %u qps",
@@ -1234,7 +1353,7 @@ test_mod_inv(void)
        if (rte_cryptodev_asym_get_xform_enum(
                &modinv_xform.xform_type, "modinv") < 0) {
                RTE_LOG(ERR, USER1,
-                                "Invalid ASYNC algorithm specified\n");
+                                "Invalid ASYM algorithm specified\n");
                return -1;
        }
 
@@ -1242,12 +1361,18 @@ test_mod_inv(void)
        capability = rte_cryptodev_asym_capability_get(dev_id,
                                        &cap_idx);
 
+       if (capability == NULL) {
+               RTE_LOG(INFO, USER1,
+                       "Device doesn't support MOD INV. Test Skipped\n");
+               return -ENOTSUP;
+       }
+
        if (rte_cryptodev_asym_xform_capability_check_modlen(
                capability,
                modinv_xform.modinv.modulus.length)) {
                RTE_LOG(ERR, USER1,
-                                "Invalid MODULOUS length specified\n");
-                               return -1;
+                                "Invalid MODULUS length specified\n");
+                               return -ENOTSUP;
                }
 
        sess = rte_cryptodev_asym_session_create(sess_mpool);
@@ -1353,7 +1478,7 @@ test_mod_exp(void)
                "modexp")
                < 0) {
                RTE_LOG(ERR, USER1,
-                               "Invalid ASYNC algorithm specified\n");
+                               "Invalid ASYM algorithm specified\n");
                return -1;
        }
 
@@ -1361,11 +1486,17 @@ test_mod_exp(void)
        cap_idx.type = modex_xform.xform_type;
        capability = rte_cryptodev_asym_capability_get(dev_id, &cap_idx);
 
+       if (capability == NULL) {
+               RTE_LOG(INFO, USER1,
+                       "Device doesn't support MOD EXP. Test Skipped\n");
+               return -ENOTSUP;
+       }
+
        if (rte_cryptodev_asym_xform_capability_check_modlen(
                        capability, modex_xform.modex.modulus.length)) {
                RTE_LOG(ERR, USER1,
-                               "Invalid MODULOUS length specified\n");
-                               return -1;
+                               "Invalid MODULUS length specified\n");
+                               return -ENOTSUP;
                }
 
        /* generate crypto op data structure */
@@ -1641,6 +1772,8 @@ static struct unit_test_suite cryptodev_openssl_asym_testsuite  = {
                TEST_CASE_ST(ut_setup, ut_teardown, test_dh_keygenration),
                TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_enc_dec),
                TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_sign_verify),
+               TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_enc_dec_crt),
+               TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_sign_verify_crt),
                TEST_CASE_ST(ut_setup, ut_teardown, test_mod_inv),
                TEST_CASE_ST(ut_setup, ut_teardown, test_mod_exp),
                TEST_CASE_ST(ut_setup, ut_teardown, test_one_by_one),