test/crypto: check key type feature flag for asym
authorAyuj Verma <ayverma@marvell.com>
Thu, 28 Mar 2019 10:28:40 +0000 (10:28 +0000)
committerAkhil Goyal <akhil.goyal@nxp.com>
Tue, 2 Apr 2019 14:50:24 +0000 (16:50 +0200)
crypto pmds are queried to check if Sign and Decrypt
with CRT keys or exponent is supported, thus call
operation with relevant key type.

Signed-off-by: Ayuj Verma <ayverma@marvell.com>
Signed-off-by: Shally Verma <shallyv@marvell.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
app/test/test_cryptodev_asym.c

index 2fe5b8f..d2efce9 100644 (file)
@@ -335,6 +335,7 @@ test_rsa_sign_verify(void)
        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_cryptodev_info dev_info;
        struct rte_crypto_asym_op *asym_op = NULL;
        struct rte_crypto_op *op = NULL, *result_op = NULL;
        struct rte_cryptodev_asym_session *sess = NULL;
@@ -342,6 +343,18 @@ test_rsa_sign_verify(void)
        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 TEST_SKIPPED;
+       }
+
        sess = rte_cryptodev_asym_session_create(sess_mpool);
 
        if (!sess) {
@@ -469,12 +482,25 @@ test_rsa_enc_dec(void)
        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_cryptodev_info dev_info;
        struct rte_crypto_asym_op *asym_op = NULL;
        struct rte_crypto_op *op = NULL, *result_op = NULL;
        struct rte_cryptodev_asym_session *sess = NULL;
        int status = TEST_SUCCESS;
        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 TEST_SKIPPED;
+       }
+
        sess = rte_cryptodev_asym_session_create(sess_mpool);
 
        if (!sess) {