LCOV - code coverage report
Current view: top level - app/test - test_cryptodev_asym.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 988 2417 40.9 %
Date: 2026-04-01 20:02:27 Functions: 63 94 67.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 291 1132 25.7 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2018 Cavium Networks
       3                 :            :  * Copyright (c) 2019 Intel Corporation
       4                 :            :  */
       5                 :            : 
       6                 :            : #include <rte_bus_vdev.h>
       7                 :            : #include <rte_common.h>
       8                 :            : #include <rte_hexdump.h>
       9                 :            : #include <rte_mbuf.h>
      10                 :            : #include <rte_malloc.h>
      11                 :            : #include <rte_memcpy.h>
      12                 :            : #include <rte_pause.h>
      13                 :            : 
      14                 :            : #include <rte_cryptodev.h>
      15                 :            : #include <rte_crypto.h>
      16                 :            : 
      17                 :            : #include "test_cryptodev.h"
      18                 :            : #include "test_cryptodev_dh_test_vectors.h"
      19                 :            : #include "test_cryptodev_dsa_test_vectors.h"
      20                 :            : #include "test_cryptodev_ecdh_test_vectors.h"
      21                 :            : #include "test_cryptodev_ecdsa_test_vectors.h"
      22                 :            : #include "test_cryptodev_ecpm_test_vectors.h"
      23                 :            : #include "test_cryptodev_eddsa_test_vectors.h"
      24                 :            : #include "test_cryptodev_mod_test_vectors.h"
      25                 :            : #include "test_cryptodev_rsa_test_vectors.h"
      26                 :            : #include "test_cryptodev_sm2_test_vectors.h"
      27                 :            : #include "test_cryptodev_ml_kem_test_vectors.h"
      28                 :            : #include "test_cryptodev_ml_dsa_test_vectors.h"
      29                 :            : #include "test_cryptodev_asym_util.h"
      30                 :            : #include "test.h"
      31                 :            : 
      32                 :            : #define TEST_NUM_BUFS 10
      33                 :            : #define TEST_NUM_SESSIONS 4
      34                 :            : 
      35                 :            : #ifndef TEST_DATA_SIZE
      36                 :            :         #define TEST_DATA_SIZE 4096
      37                 :            : #endif
      38                 :            : #define ASYM_TEST_MSG_LEN 256
      39                 :            : #define TEST_VECTOR_SIZE 256
      40                 :            : #define DEQ_TIMEOUT 10000
      41                 :            : 
      42                 :            : #define ADD_ASYM_TESTSUITE(index, parent_ts, child_ts, num_child_ts)    \
      43                 :            :         for (j = 0; j < num_child_ts; index++, j++)                  \
      44                 :            :                 parent_ts.unit_test_suites[index] = child_ts[j]
      45                 :            : 
      46                 :            : static int gbl_driver_id;
      47                 :            : static struct crypto_testsuite_params_asym {
      48                 :            :         struct rte_mempool *op_mpool;
      49                 :            :         struct rte_mempool *session_mpool;
      50                 :            :         struct rte_cryptodev_config conf;
      51                 :            :         struct rte_cryptodev_qp_conf qp_conf;
      52                 :            :         uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
      53                 :            :         uint8_t valid_dev_count;
      54                 :            : } testsuite_params, *params = &testsuite_params;
      55                 :            : 
      56                 :            : static struct ut_args {
      57                 :            :         void *sess;
      58                 :            :         struct rte_crypto_op *op;
      59                 :            :         struct rte_crypto_op *result_op;
      60                 :            : } _args, *self = &_args;
      61                 :            : 
      62                 :            : static int
      63                 :          2 : queue_ops_rsa_sign_verify(void *sess)
      64                 :            : {
      65                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
      66                 :          2 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
      67                 :          2 :         uint8_t dev_id = ts_params->valid_devs[0];
      68                 :            :         struct rte_crypto_op *op, *result_op;
      69                 :            :         struct rte_crypto_asym_op *asym_op;
      70                 :            :         uint8_t output_buf[TEST_DATA_SIZE];
      71                 :            :         int status;
      72                 :            : 
      73                 :            :         /* Set up crypto op data structure */
      74                 :          2 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
      75         [ -  + ]:          2 :         if (!op) {
      76                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to allocate asymmetric crypto "
      77                 :            :                         "operation struct\n");
      78                 :          0 :                 return TEST_FAILED;
      79                 :            :         }
      80                 :            : 
      81                 :            :         asym_op = op->asym;
      82                 :            : 
      83                 :            :         /* Compute sign on the test vector */
      84                 :          2 :         asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
      85                 :            : 
      86                 :          2 :         asym_op->rsa.message.data = rsaplaintext.data;
      87                 :          2 :         asym_op->rsa.message.length = rsaplaintext.len;
      88                 :          2 :         asym_op->rsa.sign.length = RTE_DIM(rsa_n);
      89                 :          2 :         asym_op->rsa.sign.data = output_buf;
      90                 :            : 
      91                 :          2 :         debug_hexdump(stdout, "message", asym_op->rsa.message.data,
      92                 :            :                       asym_op->rsa.message.length);
      93                 :            : 
      94                 :            :         /* Attach asymmetric crypto session to crypto operations */
      95         [ +  - ]:          2 :         rte_crypto_op_attach_asym_session(op, sess);
      96                 :            : 
      97                 :          2 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
      98                 :            : 
      99                 :            :         /* Process crypto operation */
     100         [ -  + ]:          2 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
     101                 :          0 :                 RTE_LOG(ERR, USER1, "Error sending packet for sign\n");
     102                 :            :                 status = TEST_FAILED;
     103                 :          0 :                 goto error_exit;
     104                 :            :         }
     105                 :            : 
     106         [ -  + ]:          2 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
     107                 :            :                 rte_pause();
     108                 :            : 
     109         [ -  + ]:          2 :         if (result_op == NULL) {
     110                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to process sign op\n");
     111                 :            :                 status = TEST_FAILED;
     112                 :          0 :                 goto error_exit;
     113                 :            :         }
     114                 :            : 
     115                 :          2 :         debug_hexdump(stdout, "signed message", asym_op->rsa.sign.data,
     116                 :            :                       asym_op->rsa.sign.length);
     117                 :          2 :         asym_op = result_op->asym;
     118                 :            : 
     119                 :            :         /* Verify sign */
     120                 :          2 :         asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
     121                 :            : 
     122                 :            :         /* Process crypto operation */
     123         [ -  + ]:          2 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
     124                 :          0 :                 RTE_LOG(ERR, USER1, "Error sending packet for verify\n");
     125                 :            :                 status = TEST_FAILED;
     126                 :          0 :                 goto error_exit;
     127                 :            :         }
     128                 :            : 
     129         [ -  + ]:          2 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
     130                 :            :                 rte_pause();
     131                 :            : 
     132         [ -  + ]:          2 :         if (result_op == NULL) {
     133                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to process verify op\n");
     134                 :            :                 status = TEST_FAILED;
     135                 :          0 :                 goto error_exit;
     136                 :            :         }
     137                 :            : 
     138         [ -  + ]:          2 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
     139                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to process sign-verify op\n");
     140                 :            :                 status = TEST_FAILED;
     141                 :          0 :                 goto error_exit;
     142                 :            :         }
     143                 :            : 
     144                 :            :         /* Negative test */
     145                 :          2 :         result_op->asym->rsa.sign.data[0] ^= 0xff;
     146                 :          2 :         result_op->asym->rsa.sign.length = RTE_DIM(rsa_n);
     147         [ -  + ]:          2 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &result_op, 1) != 1) {
     148                 :          0 :                 RTE_LOG(ERR, USER1, "Error sending packet for verify\n");
     149                 :            :                 status = TEST_FAILED;
     150                 :          0 :                 goto error_exit;
     151                 :            :         }
     152                 :            : 
     153         [ -  + ]:          2 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
     154                 :            :                 rte_pause();
     155                 :            : 
     156         [ -  + ]:          2 :         if (result_op == NULL) {
     157                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to process verify op\n");
     158                 :            :                 status = TEST_FAILED;
     159                 :          0 :                 goto error_exit;
     160                 :            :         }
     161                 :            : 
     162         [ -  + ]:          2 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_ERROR) {
     163                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to process sign-verify op\n");
     164                 :            :                 status = TEST_FAILED;
     165                 :          0 :                 goto error_exit;
     166                 :            :         }
     167                 :            : 
     168                 :            :         status = TEST_SUCCESS;
     169                 :          2 : error_exit:
     170                 :            : 
     171                 :          2 :         rte_crypto_op_free(op);
     172                 :            : 
     173                 :          2 :         return status;
     174                 :            : }
     175                 :            : 
     176                 :            : static int
     177                 :          2 : queue_ops_rsa_enc_dec(void *sess)
     178                 :            : {
     179                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     180                 :          2 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
     181                 :          2 :         uint8_t dev_id = ts_params->valid_devs[0];
     182                 :            :         struct rte_crypto_op *op, *result_op;
     183                 :            :         struct rte_crypto_asym_op *asym_op;
     184                 :          2 :         uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
     185                 :          2 :         uint8_t msg_buf[TEST_DATA_SIZE] = {0};
     186                 :            :         int ret, status;
     187                 :            : 
     188                 :          2 :         memcpy(msg_buf, rsaplaintext.data, rsaplaintext.len);
     189                 :            : 
     190                 :            :         /* Set up crypto op data structure */
     191                 :          2 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
     192         [ -  + ]:          2 :         if (!op) {
     193                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to allocate asymmetric crypto "
     194                 :            :                         "operation struct\n");
     195                 :          0 :                 return TEST_FAILED;
     196                 :            :         }
     197                 :            : 
     198                 :            :         asym_op = op->asym;
     199                 :            : 
     200                 :            :         /* Compute encryption on the test vector */
     201                 :          2 :         asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
     202                 :            : 
     203                 :          2 :         asym_op->rsa.message.data = msg_buf;
     204                 :          2 :         asym_op->rsa.cipher.data = cipher_buf;
     205                 :          2 :         asym_op->rsa.cipher.length = RTE_DIM(rsa_n);
     206                 :          2 :         asym_op->rsa.message.length = rsaplaintext.len;
     207                 :            : 
     208                 :          2 :         debug_hexdump(stdout, "message", asym_op->rsa.message.data,
     209                 :            :                       asym_op->rsa.message.length);
     210                 :            : 
     211                 :            :         /* Attach asymmetric crypto session to crypto operations */
     212         [ +  - ]:          2 :         rte_crypto_op_attach_asym_session(op, sess);
     213                 :            : 
     214                 :          2 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
     215                 :            : 
     216                 :            :         /* Process crypto operation */
     217         [ -  + ]:          2 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
     218                 :          0 :                 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
     219                 :            :                 status = TEST_FAILED;
     220                 :          0 :                 goto error_exit;
     221                 :            :         }
     222                 :            : 
     223         [ -  + ]:          2 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
     224                 :            :                 rte_pause();
     225                 :            : 
     226         [ -  + ]:          2 :         if (result_op == NULL) {
     227                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to process encryption op\n");
     228                 :            :                 status = TEST_FAILED;
     229                 :          0 :                 goto error_exit;
     230                 :            :         }
     231                 :          2 :         debug_hexdump(stdout, "encrypted message", asym_op->rsa.cipher.data,
     232                 :            :                       asym_op->rsa.cipher.length);
     233                 :            : 
     234                 :            :         /* Use the resulted output as decryption Input vector*/
     235                 :          2 :         asym_op = result_op->asym;
     236                 :          2 :         asym_op->rsa.message.length = RTE_DIM(rsa_n);
     237                 :          2 :         asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
     238                 :          2 :         memset(asym_op->rsa.message.data, 0, asym_op->rsa.message.length);
     239                 :            : 
     240                 :            :         /* Process crypto operation */
     241         [ -  + ]:          2 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
     242                 :          0 :                 RTE_LOG(ERR, USER1, "Error sending packet for decryption\n");
     243                 :            :                 status = TEST_FAILED;
     244                 :          0 :                 goto error_exit;
     245                 :            :         }
     246                 :            : 
     247         [ -  + ]:          2 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
     248                 :            :                 rte_pause();
     249                 :            : 
     250         [ -  + ]:          2 :         if (result_op == NULL) {
     251                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to process decryption op\n");
     252                 :            :                 status = TEST_FAILED;
     253                 :          0 :                 goto error_exit;
     254                 :            :         }
     255                 :            : 
     256         [ -  + ]:          2 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
     257                 :          0 :                 RTE_LOG(ERR, USER1, "Expected crypto op to succeed\n");
     258                 :            :                 status = TEST_FAILED;
     259                 :          0 :                 goto error_exit;
     260                 :            :         }
     261                 :            : 
     262                 :            :         ret = rsa_verify(&rsaplaintext, result_op);
     263                 :            :         if (ret) {
     264                 :            :                 status = TEST_FAILED;
     265                 :          0 :                 goto error_exit;
     266                 :            :         }
     267                 :            : 
     268                 :            :         status = TEST_SUCCESS;
     269                 :          2 : error_exit:
     270                 :            : 
     271                 :          2 :         rte_crypto_op_free(op);
     272                 :            : 
     273                 :          2 :         return status;
     274                 :            : }
     275                 :            : 
     276                 :            : static int
     277                 :          1 : test_rsa_sign_verify(void)
     278                 :            : {
     279                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     280                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
     281                 :            :         struct rte_cryptodev_asym_capability_idx idx;
     282                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     283                 :            :         struct rte_crypto_asym_xform xform;
     284                 :          1 :         void *sess = NULL;
     285                 :            :         struct rte_cryptodev_info dev_info;
     286                 :            :         int ret, status = TEST_SUCCESS;
     287                 :            : 
     288                 :            :         /* Check RSA capability */
     289                 :          1 :         idx.type = RTE_CRYPTO_ASYM_XFORM_RSA;
     290         [ +  - ]:          1 :         if (rte_cryptodev_asym_capability_get(dev_id, &idx) == NULL)
     291                 :            :                 return -ENOTSUP;
     292                 :            : 
     293                 :            :         /* Test case supports op with exponent key only,
     294                 :            :          * Check in PMD feature flag for RSA exponent key type support.
     295                 :            :          */
     296                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
     297         [ -  + ]:          1 :         if (!(dev_info.feature_flags &
     298                 :            :                                 RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_EXP)) {
     299                 :          0 :                 RTE_LOG(INFO, USER1, "Device doesn't support sign op with "
     300                 :            :                         "exponent key type. Test Skipped\n");
     301                 :          0 :                 return TEST_SKIPPED;
     302                 :            :         }
     303                 :            : 
     304                 :            :         memcpy(&xform, &rsa_xform, sizeof(rsa_xform));
     305                 :          1 :         xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
     306                 :            : 
     307                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
     308                 :            : 
     309         [ -  + ]:          1 :         if (ret < 0) {
     310                 :          0 :                 RTE_LOG(ERR, USER1, "Session creation failed for "
     311                 :            :                         "sign_verify\n");
     312         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
     313                 :          0 :                 goto error_exit;
     314                 :            :         }
     315                 :            : 
     316                 :          1 :         status = queue_ops_rsa_sign_verify(sess);
     317                 :            : 
     318                 :          1 : error_exit:
     319                 :          1 :         rte_cryptodev_asym_session_free(dev_id, sess);
     320                 :            : 
     321         [ +  - ]:          1 :         if (status == TEST_SKIPPED)
     322                 :            :                 return status;
     323                 :            : 
     324         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(status, 0, "Test failed");
     325                 :            : 
     326                 :            :         return status;
     327                 :            : }
     328                 :            : 
     329                 :            : static int
     330                 :          1 : test_rsa_enc_dec(void)
     331                 :            : {
     332                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     333                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
     334                 :            :         struct rte_cryptodev_asym_capability_idx idx;
     335                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     336                 :            :         struct rte_crypto_asym_xform xform;
     337                 :          1 :         void *sess = NULL;
     338                 :            :         struct rte_cryptodev_info dev_info;
     339                 :            :         int ret, status = TEST_SUCCESS;
     340                 :            : 
     341                 :            :         /* Check RSA capability */
     342                 :          1 :         idx.type = RTE_CRYPTO_ASYM_XFORM_RSA;
     343         [ +  - ]:          1 :         if (rte_cryptodev_asym_capability_get(dev_id, &idx) == NULL)
     344                 :            :                 return -ENOTSUP;
     345                 :            : 
     346                 :            :         /* Test case supports op with exponent key only,
     347                 :            :          * Check in PMD feature flag for RSA exponent key type support.
     348                 :            :          */
     349                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
     350         [ -  + ]:          1 :         if (!(dev_info.feature_flags &
     351                 :            :                                 RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_EXP)) {
     352                 :          0 :                 RTE_LOG(INFO, USER1, "Device doesn't support decrypt op with "
     353                 :            :                         "exponent key type. Test skipped\n");
     354                 :          0 :                 return TEST_SKIPPED;
     355                 :            :         }
     356                 :            : 
     357                 :            :         memcpy(&xform, &rsa_xform, sizeof(rsa_xform));
     358                 :          1 :         xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
     359                 :            : 
     360                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
     361                 :            : 
     362         [ -  + ]:          1 :         if (ret < 0) {
     363                 :          0 :                 RTE_LOG(ERR, USER1, "Session creation failed for enc_dec\n");
     364         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
     365                 :          0 :                 goto error_exit;
     366                 :            :         }
     367                 :            : 
     368                 :          1 :         status = queue_ops_rsa_enc_dec(sess);
     369                 :            : 
     370                 :          1 : error_exit:
     371                 :            : 
     372                 :          1 :         rte_cryptodev_asym_session_free(dev_id, sess);
     373                 :            : 
     374         [ +  - ]:          1 :         if (status == TEST_SKIPPED)
     375                 :            :                 return status;
     376                 :            : 
     377         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(status, 0, "Test failed");
     378                 :            : 
     379                 :            :         return status;
     380                 :            : }
     381                 :            : 
     382                 :            : static int
     383                 :          1 : test_rsa_sign_verify_crt(void)
     384                 :            : {
     385                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     386                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
     387                 :            :         struct rte_cryptodev_asym_capability_idx idx;
     388                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     389                 :          1 :         void *sess = NULL;
     390                 :            :         struct rte_cryptodev_info dev_info;
     391                 :            :         int ret, status = TEST_SUCCESS;
     392                 :            : 
     393                 :            :         /* Check RSA capability */
     394                 :          1 :         idx.type = RTE_CRYPTO_ASYM_XFORM_RSA;
     395         [ +  - ]:          1 :         if (rte_cryptodev_asym_capability_get(dev_id, &idx) == NULL)
     396                 :            :                 return -ENOTSUP;
     397                 :            : 
     398                 :            :         /* Test case supports op with quintuple format key only,
     399                 :            :          * Check im PMD feature flag for RSA quintuple key type support.
     400                 :            :          */
     401                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
     402         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
     403                 :          0 :                 RTE_LOG(INFO, USER1, "Device doesn't support sign op with "
     404                 :            :                         "quintuple key type. Test skipped\n");
     405                 :          0 :                 return TEST_SKIPPED;
     406                 :            :         }
     407                 :            : 
     408                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform, sess_mpool, &sess);
     409                 :            : 
     410         [ -  + ]:          1 :         if (ret < 0) {
     411                 :          0 :                 RTE_LOG(ERR, USER1, "Session creation failed for "
     412                 :            :                         "sign_verify_crt\n");
     413         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
     414                 :          0 :                 goto error_exit;
     415                 :            :         }
     416                 :            : 
     417                 :          1 :         status = queue_ops_rsa_sign_verify(sess);
     418                 :            : 
     419                 :          1 : error_exit:
     420                 :            : 
     421                 :          1 :         rte_cryptodev_asym_session_free(dev_id, sess);
     422                 :            : 
     423         [ +  - ]:          1 :         if (status == TEST_SKIPPED)
     424                 :            :                 return status;
     425                 :            : 
     426         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(status, 0, "Test failed");
     427                 :            : 
     428                 :            :         return status;
     429                 :            : }
     430                 :            : 
     431                 :            : static int
     432                 :          1 : test_rsa_enc_dec_crt(void)
     433                 :            : {
     434                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     435                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
     436                 :            :         struct rte_cryptodev_asym_capability_idx idx;
     437                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     438                 :          1 :         void *sess = NULL;
     439                 :            :         struct rte_cryptodev_info dev_info;
     440                 :            :         int ret, status = TEST_SUCCESS;
     441                 :            : 
     442                 :            :         /* Check RSA capability */
     443                 :          1 :         idx.type = RTE_CRYPTO_ASYM_XFORM_RSA;
     444         [ +  - ]:          1 :         if (rte_cryptodev_asym_capability_get(dev_id, &idx) == NULL)
     445                 :            :                 return -ENOTSUP;
     446                 :            : 
     447                 :            :         /* Test case supports op with quintuple format key only,
     448                 :            :          * Check in PMD feature flag for RSA quintuple key type support.
     449                 :            :          */
     450                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
     451         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
     452                 :          0 :                 RTE_LOG(INFO, USER1, "Device doesn't support decrypt op with "
     453                 :            :                         "quintuple key type. Test skipped\n");
     454                 :          0 :                 return TEST_SKIPPED;
     455                 :            :         }
     456                 :            : 
     457                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform, sess_mpool, &sess);
     458                 :            : 
     459         [ -  + ]:          1 :         if (ret < 0) {
     460                 :          0 :                 RTE_LOG(ERR, USER1, "Session creation failed for "
     461                 :            :                         "enc_dec_crt\n");
     462         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
     463                 :          0 :                 goto error_exit;
     464                 :            :         }
     465                 :            : 
     466                 :          1 :         status = queue_ops_rsa_enc_dec(sess);
     467                 :            : 
     468                 :          1 : error_exit:
     469                 :            : 
     470                 :          1 :         rte_cryptodev_asym_session_free(dev_id, sess);
     471                 :            : 
     472         [ +  - ]:          1 :         if (status == TEST_SKIPPED)
     473                 :            :                 return status;
     474                 :            : 
     475         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(status, 0, "Test failed");
     476                 :            : 
     477                 :            :         return status;
     478                 :            : }
     479                 :            : 
     480                 :            : static int
     481                 :          1 : testsuite_setup(void)
     482                 :            : {
     483                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     484                 :            :         uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
     485                 :            :         struct rte_cryptodev_info info;
     486                 :            :         int ret, dev_id = -1;
     487                 :            :         uint32_t i, nb_devs;
     488                 :            :         uint16_t qp_id;
     489                 :            : 
     490                 :            :         memset(ts_params, 0, sizeof(*ts_params));
     491                 :            : 
     492                 :            :         /* Device, op pool and session configuration for asymmetric crypto. 8< */
     493                 :          1 :         ts_params->op_mpool = rte_crypto_op_pool_create(
     494                 :            :                         "CRYPTO_ASYM_OP_POOL",
     495                 :            :                         RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
     496                 :            :                         TEST_NUM_BUFS, 0,
     497                 :            :                         0,
     498                 :          1 :                         rte_socket_id());
     499         [ -  + ]:          1 :         if (ts_params->op_mpool == NULL) {
     500                 :          0 :                 RTE_LOG(ERR, USER1, "Can't create ASYM_CRYPTO_OP_POOL\n");
     501                 :          0 :                 return TEST_FAILED;
     502                 :            :         }
     503                 :            : 
     504                 :            :         /* Create an OPENSSL device if required */
     505         [ +  - ]:          1 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
     506                 :            :                         RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
     507                 :          1 :                 nb_devs = rte_cryptodev_device_count_by_driver(
     508                 :          1 :                                 rte_cryptodev_driver_id_get(
     509                 :            :                                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
     510         [ -  + ]:          1 :                 if (nb_devs < 1) {
     511                 :          0 :                         ret = rte_vdev_init(
     512                 :            :                                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
     513                 :            :                                 NULL);
     514                 :            : 
     515         [ #  # ]:          0 :                         TEST_ASSERT(ret == 0, "Failed to create "
     516                 :            :                                 "instance of pmd : %s",
     517                 :            :                                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
     518                 :            :                 }
     519                 :            :         }
     520                 :            : 
     521                 :            :         /* Get list of valid crypto devs */
     522                 :          1 :         nb_devs = rte_cryptodev_devices_get(
     523                 :            :                                 rte_cryptodev_driver_name_get(gbl_driver_id),
     524                 :            :                                 valid_devs, RTE_CRYPTO_MAX_DEVS);
     525         [ -  + ]:          1 :         if (nb_devs < 1) {
     526                 :          0 :                 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
     527                 :          0 :                 return TEST_SKIPPED;
     528                 :            :         }
     529                 :            : 
     530                 :            :         /*
     531                 :            :          * Get first valid asymmetric device found in test suite param and
     532                 :            :          * break
     533                 :            :          */
     534         [ +  - ]:          1 :         for (i = 0; i < nb_devs ; i++) {
     535                 :          1 :                 rte_cryptodev_info_get(valid_devs[i], &info);
     536         [ +  - ]:          1 :                 if (info.feature_flags & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) {
     537                 :          1 :                         dev_id = ts_params->valid_devs[0] = valid_devs[i];
     538                 :          1 :                         break;
     539                 :            :                 }
     540                 :            :         }
     541                 :            : 
     542         [ -  + ]:          1 :         if (dev_id == -1) {
     543                 :          0 :                 RTE_LOG(ERR, USER1, "Device doesn't support asymmetric. "
     544                 :            :                         "Test skipped.\n");
     545                 :          0 :                 return TEST_FAILED;
     546                 :            :         }
     547                 :            : 
     548                 :            :         /* Set valid device count */
     549                 :          1 :         ts_params->valid_dev_count = nb_devs;
     550                 :            : 
     551                 :            :         /* configure device with num qp */
     552                 :          1 :         ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
     553                 :          1 :         ts_params->conf.socket_id = SOCKET_ID_ANY;
     554                 :          1 :         ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY |
     555                 :            :                         RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO;
     556         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
     557                 :            :                         &ts_params->conf),
     558                 :            :                         "Failed to configure cryptodev %u with %u qps",
     559                 :            :                         dev_id, ts_params->conf.nb_queue_pairs);
     560                 :            : 
     561                 :            :         /* configure qp */
     562                 :          1 :         ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
     563                 :          1 :         ts_params->qp_conf.mp_session = ts_params->session_mpool;
     564         [ +  + ]:          9 :         for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
     565         [ -  + ]:          8 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
     566                 :            :                         dev_id, qp_id, &ts_params->qp_conf,
     567                 :            :                         rte_cryptodev_socket_id(dev_id)),
     568                 :            :                         "Failed to setup queue pair %u on cryptodev %u ASYM",
     569                 :            :                         qp_id, dev_id);
     570                 :            :         }
     571                 :            : 
     572                 :          1 :         ts_params->session_mpool = rte_cryptodev_asym_session_pool_create(
     573                 :            :                         "test_asym_sess_mp", TEST_NUM_SESSIONS, 0, 0,
     574                 :            :                         SOCKET_ID_ANY);
     575                 :            : 
     576         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
     577                 :            :                         "session mempool allocation failed");
     578                 :            :         /* >8 End of device, op pool and session configuration for asymmetric crypto section. */
     579                 :            :         return TEST_SUCCESS;
     580                 :            : }
     581                 :            : 
     582                 :            : static void
     583                 :          1 : testsuite_teardown(void)
     584                 :            : {
     585                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     586                 :            : 
     587                 :            :         /* Reset device */
     588                 :          1 :         ts_params->qp_conf.mp_session = NULL;
     589                 :          1 :         ts_params->conf.ff_disable = 0;
     590         [ -  + ]:          1 :         if (rte_cryptodev_configure(ts_params->valid_devs[0], &ts_params->conf))
     591                 :          0 :                 RTE_LOG(DEBUG, USER1, "Could not reset cryptodev\n");
     592                 :            : 
     593         [ +  - ]:          1 :         if (ts_params->op_mpool != NULL) {
     594                 :          1 :                 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
     595                 :            :                 rte_mempool_avail_count(ts_params->op_mpool));
     596                 :            :         }
     597                 :            : 
     598                 :            :         /* Free session mempools */
     599         [ +  - ]:          1 :         if (ts_params->session_mpool != NULL) {
     600                 :          1 :                 rte_mempool_free(ts_params->session_mpool);
     601                 :          1 :                 ts_params->session_mpool = NULL;
     602                 :            :         }
     603                 :          1 : }
     604                 :            : 
     605                 :            : static int
     606                 :         32 : ut_setup_asym(void)
     607                 :            : {
     608                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     609                 :            :         uint16_t qp_id;
     610                 :            : 
     611                 :         32 :         memset(self, 0, sizeof(*self));
     612                 :         32 :         self->op = rte_crypto_op_alloc(params->op_mpool,
     613                 :            :                         RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
     614         [ -  + ]:         32 :         TEST_ASSERT_NOT_NULL(self->op,
     615                 :            :                 "Failed to allocate asymmetric crypto operation struct"
     616                 :            :         );
     617                 :            : 
     618                 :            :         /* Reconfigure device to default parameters */
     619                 :         32 :         ts_params->conf.socket_id = SOCKET_ID_ANY;
     620                 :            : 
     621         [ -  + ]:         32 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
     622                 :            :                         &ts_params->conf),
     623                 :            :                         "Failed to configure cryptodev %u",
     624                 :            :                         ts_params->valid_devs[0]);
     625                 :            : 
     626         [ +  + ]:        288 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
     627         [ -  + ]:        256 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
     628                 :            :                         ts_params->valid_devs[0], qp_id,
     629                 :            :                         &ts_params->qp_conf,
     630                 :            :                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
     631                 :            :                         "Failed to setup queue pair %u on cryptodev %u",
     632                 :            :                         qp_id, ts_params->valid_devs[0]);
     633                 :            :         }
     634                 :            : 
     635                 :            :         /* Start the device */
     636         [ -  + ]:         32 :         TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
     637                 :            :                                                 "Failed to start cryptodev %u",
     638                 :            :                                                 ts_params->valid_devs[0]);
     639                 :            : 
     640                 :            :         return TEST_SUCCESS;
     641                 :            : }
     642                 :            : 
     643                 :            : static void
     644                 :         32 : ut_teardown_asym(void)
     645                 :            : {
     646                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     647                 :         32 :         uint8_t dev_id = ts_params->valid_devs[0];
     648                 :            : 
     649         [ +  + ]:         32 :         if (self->sess != NULL)
     650                 :         16 :                 rte_cryptodev_asym_session_free(dev_id, self->sess);
     651                 :         32 :         rte_crypto_op_free(self->op);
     652                 :         32 :         self->sess = NULL;
     653                 :         32 :         self->op = NULL;
     654                 :         32 :         self->result_op = NULL;
     655                 :            : 
     656                 :            :         /* Stop the device */
     657                 :         32 :         rte_cryptodev_stop(ts_params->valid_devs[0]);
     658                 :         32 : }
     659                 :            : 
     660                 :          8 : static inline void print_asym_capa(
     661                 :            :                 const struct rte_cryptodev_asymmetric_xform_capability *capa)
     662                 :            : {
     663                 :            :         int i = 0;
     664                 :            : 
     665                 :          8 :         printf("\nxform type: %s\n===================\n",
     666                 :          8 :                         rte_cryptodev_asym_get_xform_string(capa->xform_type));
     667                 :            :         printf("operation supported -");
     668                 :            : 
     669         [ +  + ]:         40 :         for (i = 0; i < RTE_CRYPTO_ASYM_OP_LIST_END; i++) {
     670                 :            :                 /* check supported operations */
     671         [ +  + ]:         32 :                 if (rte_cryptodev_asym_xform_capability_check_optype(capa, i)) {
     672         [ +  + ]:         15 :                         if (capa->xform_type == RTE_CRYPTO_ASYM_XFORM_DH)
     673                 :          3 :                                 printf(" %s", rte_crypto_asym_ke_strings[i]);
     674                 :            :                         else
     675                 :         12 :                                 printf(" %s", rte_crypto_asym_op_strings[i]);
     676                 :            :                 }
     677                 :            :         }
     678         [ +  + ]:          8 :         switch (capa->xform_type) {
     679                 :          5 :         case RTE_CRYPTO_ASYM_XFORM_RSA:
     680                 :            :         case RTE_CRYPTO_ASYM_XFORM_MODINV:
     681                 :            :         case RTE_CRYPTO_ASYM_XFORM_MODEX:
     682                 :            :         case RTE_CRYPTO_ASYM_XFORM_DH:
     683                 :            :         case RTE_CRYPTO_ASYM_XFORM_DSA:
     684                 :          5 :                 printf(" modlen: min %d max %d increment %d",
     685                 :          5 :                                 capa->modlen.min,
     686                 :          5 :                                 capa->modlen.max,
     687                 :          5 :                                 capa->modlen.increment);
     688                 :            :         break;
     689                 :            :         case RTE_CRYPTO_ASYM_XFORM_ECDSA:
     690                 :            :         case RTE_CRYPTO_ASYM_XFORM_ECPM:
     691                 :            :         case RTE_CRYPTO_ASYM_XFORM_SM2:
     692                 :            :         default:
     693                 :            :                 break;
     694                 :            :         }
     695                 :            :         printf("\n");
     696                 :          8 : }
     697                 :            : 
     698                 :            : static int
     699                 :          1 : test_capability(void)
     700                 :            : {
     701                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     702                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     703                 :            :         struct rte_cryptodev_info dev_info;
     704                 :            :         const struct rte_cryptodev_capabilities *dev_capa;
     705                 :            :         int i = 0;
     706                 :            :         struct rte_cryptodev_asym_capability_idx idx;
     707                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
     708                 :            : 
     709                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
     710         [ -  + ]:          1 :         if (!(dev_info.feature_flags &
     711                 :            :                                 RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO)) {
     712                 :          0 :                 RTE_LOG(INFO, USER1,
     713                 :            :                                 "Device doesn't support asymmetric. Test Skipped\n");
     714                 :          0 :                 return TEST_SKIPPED;
     715                 :            :         }
     716                 :            : 
     717                 :            :         /* print xform capability */
     718                 :            :         for (i = 0;
     719         [ +  + ]:         42 :                 dev_info.capabilities[i].op != RTE_CRYPTO_OP_TYPE_UNDEFINED;
     720                 :         41 :                 i++) {
     721                 :            :                 dev_capa = &(dev_info.capabilities[i]);
     722         [ +  + ]:         41 :                 if (dev_info.capabilities[i].op ==
     723                 :            :                                 RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
     724                 :          8 :                         idx.type = dev_capa->asym.xform_capa.xform_type;
     725                 :            : 
     726                 :          8 :                         capa = rte_cryptodev_asym_capability_get(dev_id,
     727                 :            :                                 (const struct
     728                 :            :                                 rte_cryptodev_asym_capability_idx *) &idx);
     729         [ -  + ]:          8 :                         TEST_ASSERT_NOT_NULL(capa, "Failed to get asymmetric capability");
     730                 :          8 :                         print_asym_capa(capa);
     731                 :            :                         }
     732                 :            :         }
     733                 :            :         return TEST_SUCCESS;
     734                 :            : }
     735                 :            : 
     736                 :            : static int
     737                 :          1 : test_dh_gen_shared_sec(struct rte_crypto_asym_xform *xfrm)
     738                 :            : {
     739                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     740                 :          1 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
     741                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
     742                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     743                 :            :         struct rte_crypto_asym_op *asym_op = NULL;
     744                 :          1 :         struct rte_crypto_op *op = NULL, *result_op = NULL;
     745                 :          1 :         void *sess = NULL;
     746                 :            :         int ret, status = TEST_SUCCESS;
     747                 :            :         uint8_t output[TEST_DH_MOD_LEN];
     748                 :          1 :         struct rte_crypto_asym_xform xform = *xfrm;
     749                 :          1 :         uint8_t peer[] = "01234567890123456789012345678901234567890123456789";
     750                 :            : 
     751                 :            :         /* set up crypto op data structure */
     752                 :          1 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
     753         [ -  + ]:          1 :         if (!op) {
     754                 :          0 :                 RTE_LOG(ERR, USER1,
     755                 :            :                         "line %u FAILED: %s",
     756                 :            :                         __LINE__, "Failed to allocate asymmetric crypto "
     757                 :            :                         "operation struct");
     758                 :            :                 status = TEST_FAILED;
     759                 :          0 :                 goto error_exit;
     760                 :            :         }
     761                 :            :         asym_op = op->asym;
     762                 :            : 
     763                 :            :         /* Setup a xform and op to generate private key only */
     764                 :          1 :         xform.next = NULL;
     765                 :          1 :         asym_op->dh.ke_type = RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE;
     766                 :          1 :         asym_op->dh.priv_key.data = dh_test_params.priv_key.data;
     767                 :          1 :         asym_op->dh.priv_key.length = dh_test_params.priv_key.length;
     768                 :          1 :         asym_op->dh.pub_key.data = (uint8_t *)peer;
     769                 :          1 :         asym_op->dh.pub_key.length = sizeof(peer);
     770                 :          1 :         asym_op->dh.shared_secret.data = output;
     771                 :          1 :         asym_op->dh.shared_secret.length = sizeof(output);
     772                 :            : 
     773                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
     774         [ -  + ]:          1 :         if (ret < 0) {
     775                 :          0 :                 RTE_LOG(ERR, USER1,
     776                 :            :                                 "line %u FAILED: %s", __LINE__,
     777                 :            :                                 "Session creation failed");
     778         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
     779                 :          0 :                 goto error_exit;
     780                 :            :         }
     781                 :            : 
     782                 :            :         /* attach asymmetric crypto session to crypto operations */
     783         [ +  - ]:          1 :         rte_crypto_op_attach_asym_session(op, sess);
     784                 :            : 
     785                 :          1 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation");
     786                 :            : 
     787                 :            :         /* Process crypto operation */
     788         [ -  + ]:          1 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
     789                 :          0 :                 RTE_LOG(ERR, USER1,
     790                 :            :                         "line %u FAILED: %s",
     791                 :            :                         __LINE__, "Error sending packet for operation");
     792                 :            :                 status = TEST_FAILED;
     793                 :          0 :                 goto error_exit;
     794                 :            :         }
     795                 :            : 
     796         [ -  + ]:          1 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
     797                 :            :                 rte_pause();
     798                 :            : 
     799         [ -  + ]:          1 :         if (result_op == NULL) {
     800                 :          0 :                 RTE_LOG(ERR, USER1,
     801                 :            :                         "line %u FAILED: %s",
     802                 :            :                         __LINE__, "Failed to process asym crypto op");
     803                 :            :                 status = TEST_FAILED;
     804                 :          0 :                 goto error_exit;
     805                 :            :         }
     806                 :            : 
     807                 :          1 :         debug_hexdump(stdout, "shared secret:",
     808                 :          1 :                         asym_op->dh.shared_secret.data,
     809                 :            :                         asym_op->dh.shared_secret.length);
     810                 :            : 
     811                 :          1 : error_exit:
     812         [ +  - ]:          1 :         if (sess != NULL)
     813                 :          1 :                 rte_cryptodev_asym_session_free(dev_id, sess);
     814                 :          1 :         rte_crypto_op_free(op);
     815                 :          1 :         return status;
     816                 :            : }
     817                 :            : 
     818                 :            : static int
     819                 :          1 : test_dh_gen_priv_key(struct rte_crypto_asym_xform *xfrm)
     820                 :            : {
     821                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     822                 :          1 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
     823                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
     824                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     825                 :            :         struct rte_crypto_asym_op *asym_op = NULL;
     826                 :          1 :         struct rte_crypto_op *op = NULL, *result_op = NULL;
     827                 :          1 :         void *sess = NULL;
     828                 :            :         int ret, status = TEST_SUCCESS;
     829                 :            :         uint8_t output[TEST_DH_MOD_LEN];
     830                 :          1 :         struct rte_crypto_asym_xform xform = *xfrm;
     831                 :            : 
     832                 :            :         /* set up crypto op data structure */
     833                 :          1 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
     834         [ -  + ]:          1 :         if (!op) {
     835                 :          0 :                 RTE_LOG(ERR, USER1,
     836                 :            :                         "line %u FAILED: %s",
     837                 :            :                         __LINE__, "Failed to allocate asymmetric crypto "
     838                 :            :                         "operation struct");
     839                 :            :                 status = TEST_FAILED;
     840                 :          0 :                 goto error_exit;
     841                 :            :         }
     842                 :            :         asym_op = op->asym;
     843                 :            : 
     844                 :            :         /* Setup a xform and op to generate private key only */
     845                 :          1 :         xform.next = NULL;
     846                 :          1 :         asym_op->dh.ke_type = RTE_CRYPTO_ASYM_KE_PRIV_KEY_GENERATE;
     847                 :          1 :         asym_op->dh.priv_key.data = output;
     848                 :          1 :         asym_op->dh.priv_key.length = sizeof(output);
     849                 :            : 
     850                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
     851         [ -  + ]:          1 :         if (ret < 0) {
     852                 :          0 :                 RTE_LOG(ERR, USER1,
     853                 :            :                                 "line %u FAILED: %s", __LINE__,
     854                 :            :                                 "Session creation failed");
     855         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
     856                 :          0 :                 goto error_exit;
     857                 :            :         }
     858                 :            : 
     859                 :            :         /* attach asymmetric crypto session to crypto operations */
     860         [ +  - ]:          1 :         rte_crypto_op_attach_asym_session(op, sess);
     861                 :            : 
     862                 :          1 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation");
     863                 :            : 
     864                 :            :         /* Process crypto operation */
     865         [ -  + ]:          1 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
     866                 :          0 :                 RTE_LOG(ERR, USER1,
     867                 :            :                         "line %u FAILED: %s",
     868                 :            :                         __LINE__, "Error sending packet for operation");
     869                 :            :                 status = TEST_FAILED;
     870                 :          0 :                 goto error_exit;
     871                 :            :         }
     872                 :            : 
     873         [ -  + ]:          1 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
     874                 :            :                 rte_pause();
     875                 :            : 
     876         [ -  + ]:          1 :         if (result_op == NULL) {
     877                 :          0 :                 RTE_LOG(ERR, USER1,
     878                 :            :                         "line %u FAILED: %s",
     879                 :            :                         __LINE__, "Failed to process asym crypto op");
     880                 :            :                 status = TEST_FAILED;
     881                 :          0 :                 goto error_exit;
     882                 :            :         }
     883                 :            : 
     884                 :          1 :         debug_hexdump(stdout, "private key:",
     885                 :          1 :                         asym_op->dh.priv_key.data,
     886                 :            :                         asym_op->dh.priv_key.length);
     887                 :            : 
     888                 :            : 
     889                 :          1 : error_exit:
     890         [ +  - ]:          1 :         if (sess != NULL)
     891                 :          1 :                 rte_cryptodev_asym_session_free(dev_id, sess);
     892                 :          1 :         rte_crypto_op_free(op);
     893                 :            : 
     894                 :          1 :         return status;
     895                 :            : }
     896                 :            : 
     897                 :            : 
     898                 :            : static int
     899                 :          1 : test_dh_gen_pub_key(struct rte_crypto_asym_xform *xfrm)
     900                 :            : {
     901                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     902                 :          1 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
     903                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
     904                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     905                 :            :         struct rte_crypto_asym_op *asym_op = NULL;
     906                 :          1 :         struct rte_crypto_op *op = NULL, *result_op = NULL;
     907                 :          1 :         void *sess = NULL;
     908                 :            :         int ret, status = TEST_SUCCESS;
     909                 :            :         uint8_t output[TEST_DH_MOD_LEN];
     910                 :          1 :         struct rte_crypto_asym_xform xform = *xfrm;
     911                 :            : 
     912                 :            :         /* set up crypto op data structure */
     913                 :          1 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
     914         [ -  + ]:          1 :         if (!op) {
     915                 :          0 :                 RTE_LOG(ERR, USER1,
     916                 :            :                         "line %u FAILED: %s",
     917                 :            :                         __LINE__, "Failed to allocate asymmetric crypto "
     918                 :            :                         "operation struct");
     919                 :            :                 status = TEST_FAILED;
     920                 :          0 :                 goto error_exit;
     921                 :            :         }
     922                 :            :         asym_op = op->asym;
     923                 :            :         /* Setup a xform chain to generate public key
     924                 :            :          * using test private key
     925                 :            :          *
     926                 :            :          */
     927                 :          1 :         xform.next = NULL;
     928                 :            : 
     929                 :          1 :         asym_op->dh.ke_type = RTE_CRYPTO_ASYM_KE_PUB_KEY_GENERATE;
     930                 :          1 :         asym_op->dh.pub_key.data = output;
     931                 :          1 :         asym_op->dh.pub_key.length = sizeof(output);
     932                 :            :         /* load pre-defined private key */
     933                 :          1 :         asym_op->dh.priv_key.data = rte_malloc(NULL,
     934                 :            :                                         dh_test_params.priv_key.length,
     935                 :            :                                         0);
     936                 :          1 :         asym_op->dh.priv_key = dh_test_params.priv_key;
     937                 :            : 
     938                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
     939         [ -  + ]:          1 :         if (ret < 0) {
     940                 :          0 :                 RTE_LOG(ERR, USER1,
     941                 :            :                                 "line %u FAILED: %s", __LINE__,
     942                 :            :                                 "Session creation failed");
     943         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
     944                 :          0 :                 goto error_exit;
     945                 :            :         }
     946                 :            : 
     947                 :            :         /* attach asymmetric crypto session to crypto operations */
     948         [ +  - ]:          1 :         rte_crypto_op_attach_asym_session(op, sess);
     949                 :            : 
     950                 :          1 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation");
     951                 :            : 
     952                 :            :         /* Process crypto operation */
     953         [ -  + ]:          1 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
     954                 :          0 :                 RTE_LOG(ERR, USER1,
     955                 :            :                         "line %u FAILED: %s",
     956                 :            :                         __LINE__, "Error sending packet for operation");
     957                 :            :                 status = TEST_FAILED;
     958                 :          0 :                 goto error_exit;
     959                 :            :         }
     960                 :            : 
     961         [ -  + ]:          1 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
     962                 :            :                 rte_pause();
     963                 :            : 
     964         [ -  + ]:          1 :         if (result_op == NULL) {
     965                 :          0 :                 RTE_LOG(ERR, USER1,
     966                 :            :                         "line %u FAILED: %s",
     967                 :            :                         __LINE__, "Failed to process asym crypto op");
     968                 :            :                 status = TEST_FAILED;
     969                 :          0 :                 goto error_exit;
     970                 :            :         }
     971                 :            : 
     972                 :          1 :         debug_hexdump(stdout, "pub key:",
     973                 :          1 :                         asym_op->dh.pub_key.data, asym_op->dh.pub_key.length);
     974                 :            : 
     975                 :          1 :         debug_hexdump(stdout, "priv key:",
     976                 :          1 :                         asym_op->dh.priv_key.data, asym_op->dh.priv_key.length);
     977                 :            : 
     978                 :          1 : error_exit:
     979         [ +  - ]:          1 :         if (sess != NULL)
     980                 :          1 :                 rte_cryptodev_asym_session_free(dev_id, sess);
     981                 :          1 :         rte_crypto_op_free(op);
     982                 :            : 
     983                 :          1 :         return status;
     984                 :            : }
     985                 :            : 
     986                 :            : static int
     987                 :          1 : test_dh_gen_kp(struct rte_crypto_asym_xform *xfrm)
     988                 :            : {
     989                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
     990                 :          1 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
     991                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
     992                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     993                 :            :         struct rte_crypto_asym_op *asym_op = NULL;
     994                 :          1 :         struct rte_crypto_op *op = NULL, *result_op = NULL;
     995                 :          1 :         void *sess = NULL;
     996                 :            :         int ret, status = TEST_SUCCESS;
     997                 :            :         uint8_t out_pub_key[TEST_DH_MOD_LEN];
     998                 :            :         uint8_t out_prv_key[TEST_DH_MOD_LEN];
     999                 :            :         struct rte_crypto_asym_xform pub_key_xform;
    1000                 :          1 :         struct rte_crypto_asym_xform xform = *xfrm;
    1001                 :            : 
    1002                 :            :         /* set up crypto op data structure */
    1003                 :          1 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    1004         [ -  + ]:          1 :         if (!op) {
    1005                 :          0 :                 RTE_LOG(ERR, USER1,
    1006                 :            :                         "line %u FAILED: %s",
    1007                 :            :                         __LINE__, "Failed to allocate asymmetric crypto "
    1008                 :            :                         "operation struct");
    1009                 :            :                 status = TEST_FAILED;
    1010                 :          0 :                 goto error_exit;
    1011                 :            :         }
    1012                 :            :         asym_op = op->asym;
    1013                 :            :         /* Setup a xform chain to generate
    1014                 :            :          * private key first followed by
    1015                 :            :          * public key
    1016                 :            :          */
    1017                 :          1 :         pub_key_xform.xform_type = RTE_CRYPTO_ASYM_XFORM_DH;
    1018                 :          1 :         xform.next = &pub_key_xform;
    1019                 :            : 
    1020                 :          1 :         asym_op->dh.ke_type = RTE_CRYPTO_ASYM_KE_PUB_KEY_GENERATE;
    1021                 :          1 :         asym_op->dh.pub_key.data = out_pub_key;
    1022                 :          1 :         asym_op->dh.pub_key.length = sizeof(out_pub_key);
    1023                 :          1 :         asym_op->dh.priv_key.data = out_prv_key;
    1024                 :          1 :         asym_op->dh.priv_key.length = 0;
    1025                 :            : 
    1026                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    1027         [ -  + ]:          1 :         if (ret < 0) {
    1028                 :          0 :                 RTE_LOG(ERR, USER1,
    1029                 :            :                                 "line %u FAILED: %s", __LINE__,
    1030                 :            :                                 "Session creation failed");
    1031         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    1032                 :          0 :                 goto error_exit;
    1033                 :            :         }
    1034                 :            : 
    1035                 :            :         /* attach asymmetric crypto session to crypto operations */
    1036         [ +  - ]:          1 :         rte_crypto_op_attach_asym_session(op, sess);
    1037                 :            : 
    1038                 :          1 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation");
    1039                 :            : 
    1040                 :            :         /* Process crypto operation */
    1041         [ -  + ]:          1 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    1042                 :          0 :                 RTE_LOG(ERR, USER1,
    1043                 :            :                         "line %u FAILED: %s",
    1044                 :            :                         __LINE__, "Error sending packet for operation");
    1045                 :            :                 status = TEST_FAILED;
    1046                 :          0 :                 goto error_exit;
    1047                 :            :         }
    1048                 :            : 
    1049         [ -  + ]:          1 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    1050                 :            :                 rte_pause();
    1051                 :            : 
    1052         [ -  + ]:          1 :         if (result_op == NULL) {
    1053                 :          0 :                 RTE_LOG(ERR, USER1,
    1054                 :            :                         "line %u FAILED: %s",
    1055                 :            :                         __LINE__, "Failed to process asym crypto op");
    1056                 :            :                 status = TEST_FAILED;
    1057                 :          0 :                 goto error_exit;
    1058                 :            :         }
    1059                 :          1 :         debug_hexdump(stdout, "priv key:",
    1060                 :            :                         out_prv_key, asym_op->dh.priv_key.length);
    1061                 :          1 :         debug_hexdump(stdout, "pub key:",
    1062                 :            :                         out_pub_key, asym_op->dh.pub_key.length);
    1063                 :            : 
    1064                 :          1 : error_exit:
    1065         [ +  - ]:          1 :         if (sess != NULL)
    1066                 :          1 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    1067                 :          1 :         rte_crypto_op_free(op);
    1068                 :            : 
    1069                 :          1 :         return status;
    1070                 :            : }
    1071                 :            : 
    1072                 :            : static int
    1073                 :          1 : test_mod_inv(void)
    1074                 :            : {
    1075                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    1076                 :          1 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    1077                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    1078                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1079                 :            :         struct rte_crypto_asym_op *asym_op = NULL;
    1080                 :          1 :         struct rte_crypto_op *op = NULL, *result_op = NULL;
    1081                 :          1 :         void *sess = NULL;
    1082                 :            :         int status = TEST_SUCCESS;
    1083                 :            :         struct rte_cryptodev_asym_capability_idx cap_idx;
    1084                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capability;
    1085                 :          1 :         uint8_t input[TEST_DATA_SIZE] = {0};
    1086                 :            :         int ret = 0;
    1087                 :          1 :         uint8_t result[sizeof(mod_p)] = { 0 };
    1088                 :            : 
    1089         [ -  + ]:          1 :         if (rte_cryptodev_asym_get_xform_enum(
    1090                 :            :                 &modinv_xform.xform_type, "modinv") < 0) {
    1091                 :          0 :                 RTE_LOG(ERR, USER1,
    1092                 :            :                                  "Invalid ASYM algorithm specified\n");
    1093                 :          0 :                 return -1;
    1094                 :            :         }
    1095                 :            : 
    1096                 :          1 :         cap_idx.type = modinv_xform.xform_type;
    1097                 :          1 :         capability = rte_cryptodev_asym_capability_get(dev_id,
    1098                 :            :                                         &cap_idx);
    1099                 :            : 
    1100         [ -  + ]:          1 :         if (capability == NULL) {
    1101                 :          0 :                 RTE_LOG(INFO, USER1,
    1102                 :            :                         "Device doesn't support MOD INV. Test Skipped\n");
    1103                 :          0 :                 return TEST_SKIPPED;
    1104                 :            :         }
    1105                 :            : 
    1106         [ -  + ]:          1 :         if (rte_cryptodev_asym_xform_capability_check_modlen(
    1107                 :            :                 capability,
    1108                 :          1 :                 modinv_xform.modinv.modulus.length)) {
    1109                 :          0 :                 RTE_LOG(ERR, USER1,
    1110                 :            :                                  "Invalid MODULUS length specified\n");
    1111                 :          0 :                                 return TEST_SKIPPED;
    1112                 :            :                 }
    1113                 :            : 
    1114                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &modinv_xform, sess_mpool, &sess);
    1115         [ -  + ]:          1 :         if (ret < 0) {
    1116                 :          0 :                 RTE_LOG(ERR, USER1, "line %u "
    1117                 :            :                                 "FAILED: %s", __LINE__,
    1118                 :            :                                 "Session creation failed");
    1119         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    1120                 :          0 :                 goto error_exit;
    1121                 :            :         }
    1122                 :            : 
    1123                 :            :         /* generate crypto op data structure */
    1124                 :          1 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    1125         [ -  + ]:          1 :         if (!op) {
    1126                 :          0 :                 RTE_LOG(ERR, USER1,
    1127                 :            :                         "line %u FAILED: %s",
    1128                 :            :                         __LINE__, "Failed to allocate asymmetric crypto "
    1129                 :            :                         "operation struct");
    1130                 :            :                 status = TEST_FAILED;
    1131                 :          0 :                 goto error_exit;
    1132                 :            :         }
    1133                 :            : 
    1134                 :            :         asym_op = op->asym;
    1135                 :            :         memcpy(input, base, sizeof(base));
    1136                 :          1 :         asym_op->modinv.base.data = input;
    1137                 :          1 :         asym_op->modinv.base.length = sizeof(base);
    1138                 :          1 :         asym_op->modinv.result.data = result;
    1139                 :          1 :         asym_op->modinv.result.length = sizeof(result);
    1140                 :            : 
    1141                 :            :         /* attach asymmetric crypto session to crypto operations */
    1142         [ +  - ]:          1 :         rte_crypto_op_attach_asym_session(op, sess);
    1143                 :            : 
    1144                 :          1 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation");
    1145                 :            : 
    1146                 :            :         /* Process crypto operation */
    1147         [ -  + ]:          1 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    1148                 :          0 :                 RTE_LOG(ERR, USER1,
    1149                 :            :                         "line %u FAILED: %s",
    1150                 :            :                         __LINE__, "Error sending packet for operation");
    1151                 :            :                 status = TEST_FAILED;
    1152                 :          0 :                 goto error_exit;
    1153                 :            :         }
    1154                 :            : 
    1155         [ -  + ]:          1 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    1156                 :            :                 rte_pause();
    1157                 :            : 
    1158         [ -  + ]:          1 :         if (result_op == NULL) {
    1159                 :          0 :                 RTE_LOG(ERR, USER1,
    1160                 :            :                                 "line %u FAILED: %s",
    1161                 :            :                                 __LINE__, "Failed to process asym crypto op");
    1162                 :            :                 status = TEST_FAILED;
    1163                 :          0 :                 goto error_exit;
    1164                 :            :         }
    1165                 :            : 
    1166                 :          1 :         ret = verify_modinv(mod_inv, result_op);
    1167         [ +  - ]:          1 :         if (ret) {
    1168                 :          0 :                 RTE_LOG(ERR, USER1,
    1169                 :            :                          "operation verification failed\n");
    1170                 :            :                 status = TEST_FAILED;
    1171                 :            :         }
    1172                 :            : 
    1173                 :          1 : error_exit:
    1174         [ +  - ]:          1 :         if (sess)
    1175                 :          1 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    1176                 :            : 
    1177                 :          1 :         rte_crypto_op_free(op);
    1178                 :            : 
    1179         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(status, 0, "Test failed");
    1180                 :            : 
    1181                 :            :         return status;
    1182                 :            : }
    1183                 :            : 
    1184                 :            : static int
    1185                 :          1 : test_mod_exp(void)
    1186                 :            : {
    1187                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    1188                 :          1 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    1189                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    1190                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1191                 :            :         struct rte_crypto_asym_op *asym_op = NULL;
    1192                 :          1 :         struct rte_crypto_op *op = NULL, *result_op = NULL;
    1193                 :          1 :         void *sess = NULL;
    1194                 :            :         int status = TEST_SUCCESS;
    1195                 :            :         struct rte_cryptodev_asym_capability_idx cap_idx;
    1196                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capability;
    1197                 :          1 :         uint8_t input[TEST_DATA_SIZE] = {0};
    1198                 :            :         int ret = 0;
    1199                 :          1 :         uint8_t result[sizeof(mod_p)] = { 0 };
    1200                 :            : 
    1201         [ -  + ]:          1 :         if (rte_cryptodev_asym_get_xform_enum(&modex_xform.xform_type,
    1202                 :            :                 "modexp")
    1203                 :            :                 < 0) {
    1204                 :          0 :                 RTE_LOG(ERR, USER1,
    1205                 :            :                                 "Invalid ASYM algorithm specified\n");
    1206                 :          0 :                 return -1;
    1207                 :            :         }
    1208                 :            : 
    1209                 :            :         /* check for modlen capability */
    1210                 :          1 :         cap_idx.type = modex_xform.xform_type;
    1211                 :          1 :         capability = rte_cryptodev_asym_capability_get(dev_id, &cap_idx);
    1212                 :            : 
    1213         [ -  + ]:          1 :         if (capability == NULL) {
    1214                 :          0 :                 RTE_LOG(INFO, USER1,
    1215                 :            :                         "Device doesn't support MOD EXP. Test Skipped\n");
    1216                 :          0 :                 return TEST_SKIPPED;
    1217                 :            :         }
    1218                 :            : 
    1219         [ -  + ]:          1 :         if (rte_cryptodev_asym_xform_capability_check_modlen(
    1220                 :          1 :                         capability, modex_xform.modex.modulus.length)) {
    1221                 :          0 :                 RTE_LOG(ERR, USER1,
    1222                 :            :                                 "Invalid MODULUS length specified\n");
    1223                 :          0 :                                 return TEST_SKIPPED;
    1224                 :            :                 }
    1225                 :            : 
    1226                 :            :         /* Create op, create session, and process packets. 8< */
    1227                 :          1 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    1228         [ -  + ]:          1 :         if (!op) {
    1229                 :          0 :                 RTE_LOG(ERR, USER1,
    1230                 :            :                         "line %u FAILED: %s",
    1231                 :            :                         __LINE__, "Failed to allocate asymmetric crypto "
    1232                 :            :                         "operation struct");
    1233                 :            :                 status = TEST_FAILED;
    1234                 :          0 :                 goto error_exit;
    1235                 :            :         }
    1236                 :            : 
    1237                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &modex_xform, sess_mpool, &sess);
    1238         [ -  + ]:          1 :         if (ret < 0) {
    1239                 :          0 :                 RTE_LOG(ERR, USER1,
    1240                 :            :                                  "line %u "
    1241                 :            :                                 "FAILED: %s", __LINE__,
    1242                 :            :                                 "Session creation failed");
    1243         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    1244                 :          0 :                 goto error_exit;
    1245                 :            :         }
    1246                 :            : 
    1247                 :          1 :         asym_op = op->asym;
    1248                 :            :         memcpy(input, base, sizeof(base));
    1249                 :          1 :         asym_op->modex.base.data = input;
    1250                 :          1 :         asym_op->modex.base.length = sizeof(base);
    1251                 :          1 :         asym_op->modex.result.data = result;
    1252                 :          1 :         asym_op->modex.result.length = sizeof(result);
    1253                 :            :         /* attach asymmetric crypto session to crypto operations */
    1254         [ +  - ]:          1 :         rte_crypto_op_attach_asym_session(op, sess);
    1255                 :            : 
    1256                 :          1 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation");
    1257                 :            :         /* Process crypto operation */
    1258         [ -  + ]:          1 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    1259                 :          0 :                 RTE_LOG(ERR, USER1,
    1260                 :            :                                 "line %u FAILED: %s",
    1261                 :            :                                 __LINE__, "Error sending packet for operation");
    1262                 :            :                 status = TEST_FAILED;
    1263                 :          0 :                 goto error_exit;
    1264                 :            :         }
    1265                 :            : 
    1266         [ -  + ]:          1 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    1267                 :            :                 rte_pause();
    1268                 :            : 
    1269         [ -  + ]:          1 :         if (result_op == NULL) {
    1270                 :          0 :                 RTE_LOG(ERR, USER1,
    1271                 :            :                                 "line %u FAILED: %s",
    1272                 :            :                                 __LINE__, "Failed to process asym crypto op");
    1273                 :            :                 status = TEST_FAILED;
    1274                 :          0 :                 goto error_exit;
    1275                 :            :         }
    1276                 :            :         /* >8 End of create op, create session, and process packets section. */
    1277                 :          1 :         ret = verify_modexp(mod_exp, result_op);
    1278         [ +  - ]:          1 :         if (ret) {
    1279                 :          0 :                 RTE_LOG(ERR, USER1,
    1280                 :            :                          "operation verification failed\n");
    1281                 :            :                 status = TEST_FAILED;
    1282                 :            :         }
    1283                 :            : 
    1284                 :          1 : error_exit:
    1285         [ +  - ]:          1 :         if (sess != NULL)
    1286                 :          1 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    1287                 :            : 
    1288                 :          1 :         rte_crypto_op_free(op);
    1289                 :            : 
    1290         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(status, 0, "Test failed");
    1291                 :            : 
    1292                 :            :         return status;
    1293                 :            : }
    1294                 :            : 
    1295                 :            : static int
    1296                 :          1 : test_dh_key_generation(void)
    1297                 :            : {
    1298                 :            :         int status;
    1299                 :            : 
    1300                 :          1 :         debug_hexdump(stdout, "p:", dh_xform.dh.p.data, dh_xform.dh.p.length);
    1301                 :          1 :         debug_hexdump(stdout, "g:", dh_xform.dh.g.data, dh_xform.dh.g.length);
    1302                 :          1 :         debug_hexdump(stdout, "priv_key:", dh_test_params.priv_key.data,
    1303                 :            :                         dh_test_params.priv_key.length);
    1304                 :            : 
    1305                 :          1 :         RTE_LOG(INFO, USER1,
    1306                 :            :                 "Test Public and Private key pair generation\n");
    1307                 :            : 
    1308                 :          1 :         status = test_dh_gen_kp(&dh_xform);
    1309         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(status, 0, "Test failed");
    1310                 :            : 
    1311                 :          1 :         RTE_LOG(INFO, USER1,
    1312                 :            :                 "Test Public Key Generation using pre-defined priv key\n");
    1313                 :            : 
    1314                 :          1 :         status = test_dh_gen_pub_key(&dh_xform);
    1315         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(status, 0, "Test failed");
    1316                 :            : 
    1317                 :          1 :         RTE_LOG(INFO, USER1,
    1318                 :            :                 "Test Private Key Generation only\n");
    1319                 :            : 
    1320                 :          1 :         status = test_dh_gen_priv_key(&dh_xform);
    1321         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(status, 0, "Test failed");
    1322                 :            : 
    1323                 :          1 :         RTE_LOG(INFO, USER1,
    1324                 :            :                 "Test shared secret compute\n");
    1325                 :            : 
    1326                 :          1 :         status = test_dh_gen_shared_sec(&dh_xform);
    1327         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(status, 0, "Test failed");
    1328                 :            : 
    1329                 :            :         return status;
    1330                 :            : }
    1331                 :            : 
    1332                 :            : static int
    1333                 :          1 : test_dsa_sign(struct rte_crypto_dsa_op_param *dsa_op)
    1334                 :            : {
    1335                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    1336                 :          1 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    1337                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    1338                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1339                 :            :         struct rte_crypto_asym_op *asym_op = NULL;
    1340                 :          1 :         struct rte_crypto_op *op = NULL, *result_op = NULL;
    1341                 :          1 :         void *sess = NULL;
    1342                 :            :         int status = TEST_SUCCESS;
    1343                 :            :         int ret;
    1344                 :            : 
    1345                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool, &sess);
    1346         [ -  + ]:          1 :         if (ret < 0) {
    1347                 :          0 :                 RTE_LOG(ERR, USER1,
    1348                 :            :                                  "line %u FAILED: %s", __LINE__,
    1349                 :            :                                 "Session creation failed");
    1350         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    1351                 :          0 :                 goto error_exit;
    1352                 :            :         }
    1353                 :            :         /* set up crypto op data structure */
    1354                 :          1 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    1355         [ -  + ]:          1 :         if (!op) {
    1356                 :          0 :                 RTE_LOG(ERR, USER1,
    1357                 :            :                         "line %u FAILED: %s",
    1358                 :            :                         __LINE__, "Failed to allocate asymmetric crypto "
    1359                 :            :                         "operation struct");
    1360                 :            :                 status = TEST_FAILED;
    1361                 :          0 :                 goto error_exit;
    1362                 :            :         }
    1363                 :            :         asym_op = op->asym;
    1364                 :          1 :         asym_op->dsa = *dsa_op;
    1365                 :            : 
    1366                 :          1 :         debug_hexdump(stdout, "p: ", dsa_xform.dsa.p.data,
    1367                 :            :                         dsa_xform.dsa.p.length);
    1368                 :          1 :         debug_hexdump(stdout, "q: ", dsa_xform.dsa.q.data,
    1369                 :            :                         dsa_xform.dsa.q.length);
    1370                 :          1 :         debug_hexdump(stdout, "g: ", dsa_xform.dsa.g.data,
    1371                 :            :                         dsa_xform.dsa.g.length);
    1372                 :          1 :         debug_hexdump(stdout, "priv_key: ", dsa_xform.dsa.x.data,
    1373                 :            :                         dsa_xform.dsa.x.length);
    1374                 :            : 
    1375                 :            :         /* attach asymmetric crypto session to crypto operations */
    1376         [ +  - ]:          1 :         rte_crypto_op_attach_asym_session(op, sess);
    1377                 :          1 :         asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
    1378                 :          1 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation");
    1379                 :            : 
    1380                 :            :         /* Process crypto operation */
    1381         [ -  + ]:          1 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    1382                 :          0 :                 RTE_LOG(ERR, USER1,
    1383                 :            :                         "line %u FAILED: %s",
    1384                 :            :                         __LINE__, "Error sending packet for operation");
    1385                 :            :                 status = TEST_FAILED;
    1386                 :          0 :                 goto error_exit;
    1387                 :            :         }
    1388                 :            : 
    1389         [ -  + ]:          1 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    1390                 :            :                 rte_pause();
    1391                 :            : 
    1392         [ -  + ]:          1 :         if (result_op == NULL) {
    1393                 :          0 :                 RTE_LOG(ERR, USER1,
    1394                 :            :                         "line %u FAILED: %s",
    1395                 :            :                         __LINE__, "Failed to process asym crypto op");
    1396                 :            :                 status = TEST_FAILED;
    1397                 :          0 :                 goto error_exit;
    1398                 :            :         }
    1399                 :            : 
    1400                 :            :         asym_op = result_op->asym;
    1401                 :          1 :         dsa_op->r.length = asym_op->dsa.r.length;
    1402                 :          1 :         dsa_op->s.length = asym_op->dsa.s.length;
    1403                 :            : 
    1404                 :          1 :         debug_hexdump(stdout, "r:",
    1405                 :          1 :                         asym_op->dsa.r.data, asym_op->dsa.r.length);
    1406                 :          1 :         debug_hexdump(stdout, "s:",
    1407                 :          1 :                         asym_op->dsa.s.data, asym_op->dsa.s.length);
    1408                 :          1 : error_exit:
    1409         [ +  - ]:          1 :         if (sess != NULL)
    1410                 :          1 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    1411                 :          1 :         rte_crypto_op_free(op);
    1412                 :          1 :         return status;
    1413                 :            : }
    1414                 :            : 
    1415                 :            : static int
    1416                 :          1 : test_dsa_verify(struct rte_crypto_dsa_op_param *dsa_op)
    1417                 :            : {
    1418                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    1419                 :          1 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    1420                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    1421                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1422                 :            :         struct rte_crypto_asym_op *asym_op = NULL;
    1423                 :          1 :         struct rte_crypto_op *op = NULL, *result_op = NULL;
    1424                 :          1 :         void *sess = NULL;
    1425                 :            :         int status = TEST_SUCCESS;
    1426                 :            :         int ret;
    1427                 :            : 
    1428                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool, &sess);
    1429         [ -  + ]:          1 :         if (ret < 0) {
    1430                 :          0 :                 RTE_LOG(ERR, USER1,
    1431                 :            :                                  "line %u FAILED: %s", __LINE__,
    1432                 :            :                                 "Session creation failed");
    1433         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    1434                 :          0 :                 goto error_exit;
    1435                 :            :         }
    1436                 :            :         /* set up crypto op data structure */
    1437                 :          1 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    1438         [ -  + ]:          1 :         if (!op) {
    1439                 :          0 :                 RTE_LOG(ERR, USER1,
    1440                 :            :                         "line %u FAILED: %s",
    1441                 :            :                         __LINE__, "Failed to allocate asymmetric crypto "
    1442                 :            :                         "operation struct");
    1443                 :            :                 status = TEST_FAILED;
    1444                 :          0 :                 goto error_exit;
    1445                 :            :         }
    1446                 :            :         asym_op = op->asym;
    1447                 :          1 :         asym_op->dsa = *dsa_op;
    1448                 :            : 
    1449                 :          1 :         debug_hexdump(stdout, "p: ", dsa_xform.dsa.p.data,
    1450                 :            :                         dsa_xform.dsa.p.length);
    1451                 :          1 :         debug_hexdump(stdout, "q: ", dsa_xform.dsa.q.data,
    1452                 :            :                         dsa_xform.dsa.q.length);
    1453                 :          1 :         debug_hexdump(stdout, "g: ", dsa_xform.dsa.g.data,
    1454                 :            :                         dsa_xform.dsa.g.length);
    1455                 :            : 
    1456                 :            :         /* attach asymmetric crypto session to crypto operations */
    1457         [ +  - ]:          1 :         rte_crypto_op_attach_asym_session(op, sess);
    1458                 :            : 
    1459                 :          1 :         debug_hexdump(stdout, "r:",
    1460                 :          1 :                         asym_op->dsa.r.data, asym_op->dsa.r.length);
    1461                 :          1 :         debug_hexdump(stdout, "s:",
    1462                 :          1 :                         asym_op->dsa.s.data, asym_op->dsa.s.length);
    1463                 :            : 
    1464                 :          1 :         RTE_LOG(DEBUG, USER1, "Process ASYM verify operation");
    1465                 :            :         /* Test PMD DSA sign verification using signer public key */
    1466                 :          1 :         asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
    1467                 :            : 
    1468                 :            :         /* copy signer public key */
    1469                 :          1 :         asym_op->dsa.y.data = dsa_test_params.y.data;
    1470                 :          1 :         asym_op->dsa.y.length = dsa_test_params.y.length;
    1471                 :            : 
    1472                 :            :         /* Process crypto operation */
    1473         [ -  + ]:          1 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    1474                 :          0 :                 RTE_LOG(ERR, USER1,
    1475                 :            :                         "line %u FAILED: %s",
    1476                 :            :                         __LINE__, "Error sending packet for operation");
    1477                 :            :                 status = TEST_FAILED;
    1478                 :          0 :                 goto error_exit;
    1479                 :            :         }
    1480                 :            : 
    1481         [ -  + ]:          1 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    1482                 :            :                 rte_pause();
    1483                 :            : 
    1484         [ -  + ]:          1 :         if (result_op == NULL) {
    1485                 :          0 :                 RTE_LOG(ERR, USER1,
    1486                 :            :                         "line %u FAILED: %s",
    1487                 :            :                         __LINE__, "Failed to process asym crypto op");
    1488                 :            :                 status = TEST_FAILED;
    1489                 :          0 :                 goto error_exit;
    1490                 :            :         }
    1491                 :            : 
    1492         [ +  - ]:          1 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    1493                 :          0 :                 RTE_LOG(ERR, USER1,
    1494                 :            :                                 "line %u FAILED: %s",
    1495                 :            :                                 __LINE__, "Failed to process asym crypto op");
    1496                 :            :                 status = TEST_FAILED;
    1497                 :            :         }
    1498                 :          1 : error_exit:
    1499         [ +  - ]:          1 :         if (sess != NULL)
    1500                 :          1 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    1501                 :          1 :         rte_crypto_op_free(op);
    1502                 :          1 :         return status;
    1503                 :            : }
    1504                 :            : 
    1505                 :            : static int
    1506                 :          1 : test_dsa(void)
    1507                 :            : {
    1508                 :            :         int status;
    1509                 :            :         uint8_t r[TEST_DH_MOD_LEN];
    1510                 :            :         uint8_t s[TEST_DH_MOD_LEN];
    1511                 :            :         struct rte_crypto_dsa_op_param dsa_op;
    1512                 :          1 :         uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
    1513                 :            : 
    1514                 :          1 :         dsa_op.message.data = dgst;
    1515                 :          1 :         dsa_op.message.length = sizeof(dgst);
    1516                 :          1 :         dsa_op.r.data = r;
    1517                 :          1 :         dsa_op.s.data = s;
    1518                 :          1 :         dsa_op.r.length = sizeof(r);
    1519                 :          1 :         dsa_op.s.length = sizeof(s);
    1520                 :            : 
    1521                 :          1 :         status = test_dsa_sign(&dsa_op);
    1522         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(status, 0, "DSA sign test failed");
    1523                 :          1 :         status = test_dsa_verify(&dsa_op);
    1524         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(status, 0, "DSA verify test failed");
    1525                 :            :         return status;
    1526                 :            : }
    1527                 :            : 
    1528                 :            : static int
    1529                 :          0 : test_ecdsa_sign_verify(enum curve curve_id)
    1530                 :            : {
    1531                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    1532                 :          0 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    1533                 :          0 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    1534                 :            :         struct crypto_testsuite_ecdsa_params input_params;
    1535                 :          0 :         void *sess = NULL;
    1536                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
    1537                 :          0 :         struct rte_crypto_op *result_op = NULL;
    1538                 :            :         uint8_t output_buf_r[TEST_DATA_SIZE];
    1539                 :            :         uint8_t output_buf_s[TEST_DATA_SIZE];
    1540                 :            :         struct rte_crypto_asym_xform xform;
    1541                 :            :         struct rte_crypto_asym_op *asym_op;
    1542                 :            :         struct rte_cryptodev_info dev_info;
    1543                 :          0 :         struct rte_crypto_op *op = NULL;
    1544                 :            :         int ret, status = TEST_SUCCESS;
    1545                 :            : 
    1546   [ #  #  #  #  :          0 :         switch (curve_id) {
                #  #  # ]
    1547                 :          0 :         case SECP192R1:
    1548                 :          0 :                 input_params = ecdsa_param_secp192r1;
    1549                 :          0 :                 break;
    1550                 :          0 :         case SECP224R1:
    1551                 :          0 :                 input_params = ecdsa_param_secp224r1;
    1552                 :          0 :                 break;
    1553                 :          0 :         case SECP256R1:
    1554                 :          0 :                 input_params = ecdsa_param_secp256r1;
    1555                 :          0 :                 break;
    1556                 :          0 :         case SECP384R1:
    1557                 :          0 :                 input_params = ecdsa_param_secp384r1;
    1558                 :          0 :                 break;
    1559                 :          0 :         case SECP521R1:
    1560                 :          0 :                 input_params = ecdsa_param_secp521r1;
    1561                 :          0 :                 break;
    1562                 :          0 :         case SECP521R1_UA:
    1563                 :          0 :                 input_params = ecdsa_param_secp521r1_ua;
    1564                 :          0 :                 break;
    1565                 :          0 :         default:
    1566                 :          0 :                 RTE_LOG(ERR, USER1,
    1567                 :            :                                 "line %u FAILED: %s", __LINE__,
    1568                 :            :                                 "Unsupported curve id\n");
    1569                 :            :                 status = TEST_FAILED;
    1570                 :          0 :                 goto exit;
    1571                 :            :         }
    1572                 :            : 
    1573                 :          0 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1574                 :            : 
    1575                 :            :         /* Setup crypto op data structure */
    1576                 :          0 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    1577         [ #  # ]:          0 :         if (op == NULL) {
    1578                 :          0 :                 RTE_LOG(ERR, USER1,
    1579                 :            :                                 "line %u FAILED: %s", __LINE__,
    1580                 :            :                                 "Failed to allocate asymmetric crypto "
    1581                 :            :                                 "operation struct\n");
    1582                 :            :                 status = TEST_FAILED;
    1583                 :          0 :                 goto exit;
    1584                 :            :         }
    1585                 :            :         asym_op = op->asym;
    1586                 :            : 
    1587                 :            :         /* Setup asym xform */
    1588                 :          0 :         xform.next = NULL;
    1589                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECDSA;
    1590                 :          0 :         xform.ec.curve_id = input_params.curve;
    1591                 :          0 :         xform.ec.pkey.data = input_params.pkey.data;
    1592                 :          0 :         xform.ec.pkey.length = input_params.pkey.length;
    1593                 :          0 :         xform.ec.q.x.data = input_params.pubkey_qx.data;
    1594                 :          0 :         xform.ec.q.x.length = input_params.pubkey_qx.length;
    1595                 :          0 :         xform.ec.q.y.data = input_params.pubkey_qy.data;
    1596                 :          0 :         xform.ec.q.y.length = input_params.pubkey_qy.length;
    1597                 :            : 
    1598                 :          0 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    1599         [ #  # ]:          0 :         if (ret < 0) {
    1600                 :          0 :                 RTE_LOG(ERR, USER1,
    1601                 :            :                                 "line %u FAILED: %s", __LINE__,
    1602                 :            :                                 "Session creation failed\n");
    1603         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    1604                 :          0 :                 goto exit;
    1605                 :            :         }
    1606                 :            : 
    1607                 :            :         /* Attach asymmetric crypto session to crypto operations */
    1608         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(op, sess);
    1609                 :            : 
    1610                 :            :         /* Compute sign */
    1611                 :            : 
    1612                 :            :         /* Populate op with operational details */
    1613                 :          0 :         op->asym->ecdsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
    1614                 :          0 :         op->asym->ecdsa.message.data = input_params.digest.data;
    1615                 :          0 :         op->asym->ecdsa.message.length = input_params.digest.length;
    1616                 :          0 :         op->asym->ecdsa.k.data = input_params.scalar.data;
    1617                 :          0 :         op->asym->ecdsa.k.length = input_params.scalar.length;
    1618                 :            : 
    1619                 :            :         /* Init out buf */
    1620                 :          0 :         op->asym->ecdsa.r.data = output_buf_r;
    1621                 :          0 :         op->asym->ecdsa.s.data = output_buf_s;
    1622                 :            : 
    1623                 :          0 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
    1624                 :            : 
    1625                 :            :         /* Process crypto operation */
    1626         [ #  # ]:          0 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    1627                 :          0 :                 RTE_LOG(ERR, USER1,
    1628                 :            :                                 "line %u FAILED: %s", __LINE__,
    1629                 :            :                                 "Error sending packet for operation\n");
    1630                 :            :                 status = TEST_FAILED;
    1631                 :          0 :                 goto exit;
    1632                 :            :         }
    1633                 :            : 
    1634         [ #  # ]:          0 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    1635                 :            :                 rte_pause();
    1636                 :            : 
    1637         [ #  # ]:          0 :         if (result_op == NULL) {
    1638                 :          0 :                 RTE_LOG(ERR, USER1,
    1639                 :            :                                 "line %u FAILED: %s", __LINE__,
    1640                 :            :                                 "Failed to process asym crypto op\n");
    1641                 :            :                 status = TEST_FAILED;
    1642                 :          0 :                 goto exit;
    1643                 :            :         }
    1644                 :            : 
    1645         [ #  # ]:          0 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    1646                 :          0 :                 RTE_LOG(ERR, USER1,
    1647                 :            :                                 "line %u FAILED: %s", __LINE__,
    1648                 :            :                                 "Failed to process asym crypto op\n");
    1649                 :            :                 status = TEST_FAILED;
    1650                 :          0 :                 goto exit;
    1651                 :            :         }
    1652                 :            : 
    1653                 :            :         asym_op = result_op->asym;
    1654                 :            : 
    1655                 :          0 :         debug_hexdump(stdout, "r:",
    1656                 :          0 :                         asym_op->ecdsa.r.data, asym_op->ecdsa.r.length);
    1657                 :          0 :         debug_hexdump(stdout, "s:",
    1658                 :          0 :                         asym_op->ecdsa.s.data, asym_op->ecdsa.s.length);
    1659                 :            : 
    1660                 :          0 :         ret = verify_ecdsa_sign(input_params.sign_r.data,
    1661                 :            :                                 input_params.sign_s.data, result_op);
    1662         [ #  # ]:          0 :         if (ret) {
    1663                 :            :                 status = TEST_FAILED;
    1664                 :          0 :                 RTE_LOG(ERR, USER1,
    1665                 :            :                                 "line %u FAILED: %s", __LINE__,
    1666                 :            :                                 "ECDSA sign failed.\n");
    1667                 :          0 :                 goto exit;
    1668                 :            :         }
    1669                 :            : 
    1670                 :            :         /* Verify sign */
    1671                 :            : 
    1672                 :            :         /* Populate op with operational details */
    1673                 :          0 :         op->asym->ecdsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
    1674                 :          0 :         op->asym->ecdsa.r.data = asym_op->ecdsa.r.data;
    1675                 :          0 :         op->asym->ecdsa.r.length = asym_op->ecdsa.r.length;
    1676                 :          0 :         op->asym->ecdsa.s.data = asym_op->ecdsa.s.data;
    1677                 :          0 :         op->asym->ecdsa.s.length = asym_op->ecdsa.s.length;
    1678                 :            : 
    1679                 :            :         /* Enqueue sign result for verify */
    1680         [ #  # ]:          0 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    1681                 :            :                 status = TEST_FAILED;
    1682                 :          0 :                 RTE_LOG(ERR, USER1,
    1683                 :            :                                 "line %u FAILED: %s", __LINE__,
    1684                 :            :                                 "Error sending packet for operation\n");
    1685                 :          0 :                 goto exit;
    1686                 :            :         }
    1687                 :            : 
    1688         [ #  # ]:          0 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    1689                 :            :                 rte_pause();
    1690                 :            : 
    1691         [ #  # ]:          0 :         if (result_op == NULL) {
    1692                 :            :                 status = TEST_FAILED;
    1693                 :          0 :                 goto exit;
    1694                 :            :         }
    1695         [ #  # ]:          0 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    1696                 :            :                 status = TEST_FAILED;
    1697                 :          0 :                 RTE_LOG(ERR, USER1,
    1698                 :            :                                 "line %u FAILED: %s", __LINE__,
    1699                 :            :                                 "ECDSA verify failed.\n");
    1700                 :          0 :                 goto exit;
    1701                 :            :         }
    1702                 :            : 
    1703                 :          0 : exit:
    1704         [ #  # ]:          0 :         if (sess != NULL)
    1705                 :          0 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    1706                 :          0 :         rte_crypto_op_free(op);
    1707                 :          0 :         return status;
    1708                 :            : };
    1709                 :            : 
    1710                 :            : static int
    1711                 :          0 : test_ecdsa_sign_verify_all_curve(void)
    1712                 :            : {
    1713                 :            :         int status, overall_status = TEST_SUCCESS;
    1714                 :            :         enum curve curve_id;
    1715                 :            :         int test_index = 0;
    1716                 :            :         const char *msg;
    1717                 :            : 
    1718         [ #  # ]:          0 :         for (curve_id = SECP192R1; curve_id < END_OF_CURVE_LIST; curve_id++) {
    1719                 :          0 :                 if (curve_id == ED25519 || curve_id == ED448 ||
    1720   [ #  #  #  # ]:          0 :                     curve_id == ECGROUP19 || curve_id == ECGROUP20 ||
    1721                 :            :                     curve_id == ECGROUP21)
    1722                 :          0 :                         continue;
    1723                 :            : 
    1724                 :          0 :                 status = test_ecdsa_sign_verify(curve_id);
    1725         [ #  # ]:          0 :                 if (status == TEST_SUCCESS) {
    1726                 :            :                         msg = "succeeded";
    1727         [ #  # ]:          0 :                 } else if (status == TEST_SKIPPED) {
    1728                 :            :                         msg = "skipped";
    1729                 :            :                 } else {
    1730                 :            :                         msg = "failed";
    1731                 :            :                         overall_status = status;
    1732                 :            :                 }
    1733                 :          0 :                 printf("  %u) TestCase Sign/Veriy Curve %s  %s\n",
    1734                 :            :                        test_index ++, curve[curve_id], msg);
    1735                 :            :         }
    1736                 :          0 :         return overall_status;
    1737                 :            : }
    1738                 :            : 
    1739                 :            : static int
    1740                 :          0 : test_ecdsa_sign_verify_qat_curves(void)
    1741                 :            : {
    1742                 :            :         int status, overall_status = TEST_SUCCESS;
    1743                 :            :         enum curve curve_id;
    1744                 :            :         int test_index = 0;
    1745                 :            :         const char *msg;
    1746                 :            : 
    1747         [ #  # ]:          0 :         for (curve_id = SECP256R1; curve_id <= SECP521R1; curve_id++) {
    1748                 :            : 
    1749                 :          0 :                 status = test_ecdsa_sign_verify(curve_id);
    1750         [ #  # ]:          0 :                 if (status == TEST_SUCCESS) {
    1751                 :            :                         msg = "succeeded";
    1752                 :            :                 } else {
    1753                 :            :                         msg = "failed";
    1754                 :            :                         overall_status = status;
    1755                 :            :                 }
    1756                 :          0 :                 printf("  %u) TestCase Sign/Veriy Curve %s  %s\n",
    1757                 :            :                        test_index ++, curve[curve_id], msg);
    1758                 :            :         }
    1759                 :          0 :         return overall_status;
    1760                 :            : }
    1761                 :            : 
    1762                 :            : static int
    1763                 :          0 : test_ecpm(enum curve curve_id)
    1764                 :            : {
    1765                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    1766                 :          0 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    1767                 :          0 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    1768                 :            :         struct crypto_testsuite_ecpm_params input_params;
    1769                 :          0 :         void *sess = NULL;
    1770                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
    1771                 :          0 :         struct rte_crypto_op *result_op = NULL;
    1772                 :            :         uint8_t output_buf_x[TEST_DATA_SIZE];
    1773                 :            :         uint8_t output_buf_y[TEST_DATA_SIZE];
    1774                 :            :         struct rte_crypto_asym_xform xform;
    1775                 :            :         struct rte_crypto_asym_op *asym_op;
    1776                 :            :         struct rte_cryptodev_info dev_info;
    1777                 :          0 :         struct rte_crypto_op *op = NULL;
    1778                 :            :         int ret, status = TEST_SUCCESS;
    1779                 :            : 
    1780   [ #  #  #  #  :          0 :         switch (curve_id) {
                   #  # ]
    1781                 :          0 :         case SECP192R1:
    1782                 :          0 :                 input_params = ecpm_param_secp192r1;
    1783                 :          0 :                 break;
    1784                 :          0 :         case SECP224R1:
    1785                 :          0 :                 input_params = ecpm_param_secp224r1;
    1786                 :          0 :                 break;
    1787                 :          0 :         case SECP256R1:
    1788                 :          0 :                 input_params = ecpm_param_secp256r1;
    1789                 :          0 :                 break;
    1790                 :          0 :         case SECP384R1:
    1791                 :          0 :                 input_params = ecpm_param_secp384r1;
    1792                 :          0 :                 break;
    1793                 :          0 :         case SECP521R1:
    1794                 :          0 :                 input_params = ecpm_param_secp521r1;
    1795                 :          0 :                 break;
    1796                 :          0 :         default:
    1797                 :          0 :                 RTE_LOG(ERR, USER1,
    1798                 :            :                                 "line %u FAILED: %s", __LINE__,
    1799                 :            :                                 "Unsupported curve id\n");
    1800                 :            :                 status = TEST_FAILED;
    1801                 :          0 :                 goto exit;
    1802                 :            :         }
    1803                 :            : 
    1804                 :          0 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1805                 :            : 
    1806                 :            :         /* Setup crypto op data structure */
    1807                 :          0 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    1808         [ #  # ]:          0 :         if (op == NULL) {
    1809                 :          0 :                 RTE_LOG(ERR, USER1,
    1810                 :            :                                 "line %u FAILED: %s", __LINE__,
    1811                 :            :                                 "Failed to allocate asymmetric crypto "
    1812                 :            :                                 "operation struct\n");
    1813                 :            :                 status = TEST_FAILED;
    1814                 :          0 :                 goto exit;
    1815                 :            :         }
    1816                 :            :         asym_op = op->asym;
    1817                 :            : 
    1818                 :            :         /* Setup asym xform */
    1819                 :            :         memset(&xform, 0, sizeof(xform));
    1820                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECPM;
    1821                 :          0 :         xform.ec.curve_id = input_params.curve;
    1822                 :            : 
    1823                 :          0 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    1824         [ #  # ]:          0 :         if (ret < 0) {
    1825                 :          0 :                 RTE_LOG(ERR, USER1,
    1826                 :            :                                 "line %u FAILED: %s", __LINE__,
    1827                 :            :                                 "Session creation failed\n");
    1828         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    1829                 :          0 :                 goto exit;
    1830                 :            :         }
    1831                 :            : 
    1832                 :            :         /* Attach asymmetric crypto session to crypto operations */
    1833         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(op, sess);
    1834                 :            : 
    1835                 :            :         /* Populate op with operational details */
    1836                 :          0 :         op->asym->ecpm.p.x.data = input_params.gen_x.data;
    1837                 :          0 :         op->asym->ecpm.p.x.length = input_params.gen_x.length;
    1838                 :          0 :         op->asym->ecpm.p.y.data = input_params.gen_y.data;
    1839                 :          0 :         op->asym->ecpm.p.y.length = input_params.gen_y.length;
    1840                 :          0 :         op->asym->ecpm.scalar.data = input_params.privkey.data;
    1841                 :          0 :         op->asym->ecpm.scalar.length = input_params.privkey.length;
    1842                 :            : 
    1843                 :            :         /* Init out buf */
    1844                 :          0 :         op->asym->ecpm.r.x.data = output_buf_x;
    1845                 :          0 :         op->asym->ecpm.r.y.data = output_buf_y;
    1846                 :            : 
    1847                 :          0 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
    1848                 :            : 
    1849                 :            :         /* Process crypto operation */
    1850         [ #  # ]:          0 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    1851                 :          0 :                 RTE_LOG(ERR, USER1,
    1852                 :            :                                 "line %u FAILED: %s", __LINE__,
    1853                 :            :                                 "Error sending packet for operation\n");
    1854                 :            :                 status = TEST_FAILED;
    1855                 :          0 :                 goto exit;
    1856                 :            :         }
    1857                 :            : 
    1858         [ #  # ]:          0 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    1859                 :            :                 rte_pause();
    1860                 :            : 
    1861         [ #  # ]:          0 :         if (result_op == NULL) {
    1862                 :          0 :                 RTE_LOG(ERR, USER1,
    1863                 :            :                                 "line %u FAILED: %s", __LINE__,
    1864                 :            :                                 "Failed to process asym crypto op\n");
    1865                 :            :                 status = TEST_FAILED;
    1866                 :          0 :                 goto exit;
    1867                 :            :         }
    1868                 :            : 
    1869         [ #  # ]:          0 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    1870                 :          0 :                 RTE_LOG(ERR, USER1,
    1871                 :            :                                 "line %u FAILED: %s", __LINE__,
    1872                 :            :                                 "Failed to process asym crypto op\n");
    1873                 :            :                 status = TEST_FAILED;
    1874                 :          0 :                 goto exit;
    1875                 :            :         }
    1876                 :            : 
    1877                 :            :         asym_op = result_op->asym;
    1878                 :            : 
    1879                 :          0 :         debug_hexdump(stdout, "r x:",
    1880                 :          0 :                         asym_op->ecpm.r.x.data, asym_op->ecpm.r.x.length);
    1881                 :          0 :         debug_hexdump(stdout, "r y:",
    1882                 :          0 :                         asym_op->ecpm.r.y.data, asym_op->ecpm.r.y.length);
    1883                 :            : 
    1884                 :          0 :         ret = verify_ecpm(input_params.pubkey_x.data,
    1885                 :            :                                 input_params.pubkey_y.data, result_op);
    1886         [ #  # ]:          0 :         if (ret) {
    1887                 :            :                 status = TEST_FAILED;
    1888                 :          0 :                 RTE_LOG(ERR, USER1,
    1889                 :            :                                 "line %u FAILED: %s", __LINE__,
    1890                 :            :                                 "EC Point Multiplication failed.\n");
    1891                 :          0 :                 goto exit;
    1892                 :            :         }
    1893                 :            : 
    1894                 :          0 : exit:
    1895         [ #  # ]:          0 :         if (sess != NULL)
    1896                 :          0 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    1897                 :          0 :         rte_crypto_op_free(op);
    1898                 :          0 :         return status;
    1899                 :            : }
    1900                 :            : 
    1901                 :            : static int
    1902                 :          0 : test_ecpm_all_curve(void)
    1903                 :            : {
    1904                 :            :         int status, overall_status = TEST_SUCCESS;
    1905                 :            :         enum curve curve_id;
    1906                 :            :         int test_index = 0;
    1907                 :            :         const char *msg;
    1908                 :            : 
    1909         [ #  # ]:          0 :         for (curve_id = SECP192R1; curve_id < END_OF_CURVE_LIST; curve_id++) {
    1910                 :          0 :                 if (curve_id == SECP521R1_UA || curve_id == ECGROUP19 ||
    1911                 :            :                     curve_id == ECGROUP20 || curve_id == ECGROUP21 ||
    1912         [ #  # ]:          0 :                     curve_id == ED25519 || curve_id == ED448)
    1913                 :          0 :                         continue;
    1914                 :            : 
    1915                 :          0 :                 status = test_ecpm(curve_id);
    1916         [ #  # ]:          0 :                 if (status == TEST_SUCCESS) {
    1917                 :            :                         msg = "succeeded";
    1918         [ #  # ]:          0 :                 } else if (status == TEST_SKIPPED) {
    1919                 :            :                         msg = "skipped";
    1920                 :            :                 } else {
    1921                 :            :                         msg = "failed";
    1922                 :            :                         overall_status = status;
    1923                 :            :                 }
    1924                 :          0 :                 printf("  %u) TestCase EC Point Mul Curve %s  %s\n",
    1925                 :            :                        test_index ++, curve[curve_id], msg);
    1926                 :            :         }
    1927                 :          0 :         return overall_status;
    1928                 :            : }
    1929                 :            : 
    1930                 :            : static int
    1931                 :          0 : test_ecpm_qat_curves(void)
    1932                 :            : {
    1933                 :            :         int status, overall_status = TEST_SUCCESS;
    1934                 :            :         enum curve curve_id;
    1935                 :            :         int test_index = 0;
    1936                 :            :         const char *msg;
    1937                 :            : 
    1938         [ #  # ]:          0 :         for (curve_id = SECP256R1; curve_id <= SECP521R1; curve_id++) {
    1939                 :          0 :                 status = test_ecpm(curve_id);
    1940         [ #  # ]:          0 :                 if (status == TEST_SUCCESS) {
    1941                 :            :                         msg = "succeeded";
    1942                 :            :                 } else {
    1943                 :            :                         msg = "failed";
    1944                 :            :                         overall_status = status;
    1945                 :            :                 }
    1946                 :          0 :                 printf("  %u) TestCase EC Point Mul Curve %s  %s\n",
    1947                 :            :                        test_index ++, curve[curve_id], msg);
    1948                 :            :         }
    1949                 :          0 :         return overall_status;
    1950                 :            : }
    1951                 :            : 
    1952                 :            : static int
    1953                 :          0 : test_ecdh_priv_key_generate(enum curve curve_id)
    1954                 :            : {
    1955                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    1956                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    1957                 :          0 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    1958                 :          0 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    1959                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    1960                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
    1961                 :          0 :         struct rte_crypto_asym_xform xform = {0};
    1962                 :          0 :         struct rte_crypto_op *result_op = NULL;
    1963                 :            :         uint8_t output_buf[TEST_DATA_SIZE];
    1964                 :            :         struct rte_crypto_asym_op *asym_op;
    1965                 :          0 :         struct rte_crypto_op *op = NULL;
    1966                 :            :         int ret, status = TEST_SUCCESS;
    1967                 :            :         uint16_t output_buflen = 0;
    1968                 :          0 :         void *sess = NULL;
    1969                 :            :         int curve;
    1970                 :            : 
    1971                 :            :         /* Check ECDH capability */
    1972                 :          0 :         idx.type = RTE_CRYPTO_ASYM_XFORM_ECDH;
    1973                 :          0 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    1974         [ #  # ]:          0 :         if (capa == NULL)
    1975                 :            :                 return TEST_SKIPPED;
    1976                 :            : 
    1977         [ #  # ]:          0 :         if (!(capa->op_types & (1 <<  RTE_CRYPTO_ASYM_KE_PRIV_KEY_GENERATE)))
    1978                 :            :                 return TEST_SKIPPED;
    1979                 :            : 
    1980                 :            :         switch (curve_id) {
    1981                 :            :         case SECP192R1:
    1982                 :            :                 curve = RTE_CRYPTO_EC_GROUP_SECP192R1;
    1983                 :            :                 output_buflen = 24;
    1984                 :            :                 break;
    1985                 :            :         case SECP224R1:
    1986                 :            :                 curve = RTE_CRYPTO_EC_GROUP_SECP224R1;
    1987                 :            :                 output_buflen = 28;
    1988                 :            :                 break;
    1989                 :            :         case SECP256R1:
    1990                 :            :                 curve = RTE_CRYPTO_EC_GROUP_SECP256R1;
    1991                 :            :                 output_buflen = 32;
    1992                 :            :                 break;
    1993                 :            :         case SECP384R1:
    1994                 :            :                 curve = RTE_CRYPTO_EC_GROUP_SECP384R1;
    1995                 :            :                 output_buflen = 48;
    1996                 :            :                 break;
    1997                 :            :         case SECP521R1:
    1998                 :            :                 curve = RTE_CRYPTO_EC_GROUP_SECP521R1;
    1999                 :            :                 output_buflen = 66;
    2000                 :            :                 break;
    2001                 :          0 :         default:
    2002                 :          0 :                 RTE_LOG(ERR, USER1,
    2003                 :            :                                 "line %u FAILED: %s", __LINE__,
    2004                 :            :                                 "Unsupported curve id\n");
    2005                 :            :                 status = TEST_FAILED;
    2006                 :          0 :                 goto exit;
    2007                 :            :         }
    2008                 :            : 
    2009                 :            :         /* Setup crypto op data structure */
    2010                 :          0 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    2011         [ #  # ]:          0 :         if (op == NULL) {
    2012                 :          0 :                 RTE_LOG(ERR, USER1,
    2013                 :            :                                 "line %u FAILED: %s", __LINE__,
    2014                 :            :                                 "Failed to allocate asymmetric crypto "
    2015                 :            :                                 "operation struct\n");
    2016                 :            :                 status = TEST_FAILED;
    2017                 :          0 :                 goto exit;
    2018                 :            :         }
    2019                 :            :         asym_op = op->asym;
    2020                 :            : 
    2021                 :            :         /* Setup asym xform */
    2022                 :          0 :         xform.next = NULL;
    2023                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECDH;
    2024                 :          0 :         xform.ec.curve_id = curve;
    2025                 :            : 
    2026                 :          0 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    2027         [ #  # ]:          0 :         if (ret < 0) {
    2028                 :          0 :                 RTE_LOG(ERR, USER1,
    2029                 :            :                                 "line %u FAILED: %s", __LINE__,
    2030                 :            :                                 "Session creation failed\n");
    2031         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    2032                 :          0 :                 goto exit;
    2033                 :            :         }
    2034                 :            : 
    2035                 :            :         /* Attach asymmetric crypto session to crypto operations */
    2036         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(op, sess);
    2037                 :            : 
    2038                 :            :         /* Populate op with operational details */
    2039                 :          0 :         asym_op->ecdh.ke_type = RTE_CRYPTO_ASYM_KE_PRIV_KEY_GENERATE;
    2040                 :            : 
    2041                 :            :         /* Init out buf */
    2042                 :          0 :         asym_op->ecdh.priv_key.data = output_buf;
    2043                 :          0 :         asym_op->ecdh.priv_key.length = output_buflen;
    2044                 :            : 
    2045                 :          0 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
    2046                 :            : 
    2047                 :            :         /* Process crypto operation */
    2048         [ #  # ]:          0 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    2049                 :          0 :                 RTE_LOG(ERR, USER1,
    2050                 :            :                                 "line %u FAILED: %s", __LINE__,
    2051                 :            :                                 "Error sending packet for operation\n");
    2052                 :            :                 status = TEST_FAILED;
    2053                 :          0 :                 goto exit;
    2054                 :            :         }
    2055                 :            : 
    2056         [ #  # ]:          0 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    2057                 :            :                 rte_pause();
    2058                 :            : 
    2059         [ #  # ]:          0 :         if (result_op == NULL) {
    2060                 :          0 :                 RTE_LOG(ERR, USER1,
    2061                 :            :                                 "line %u FAILED: %s", __LINE__,
    2062                 :            :                                 "Failed to process asym crypto op\n");
    2063                 :            :                 status = TEST_FAILED;
    2064                 :          0 :                 goto exit;
    2065                 :            :         }
    2066                 :            : 
    2067         [ #  # ]:          0 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    2068                 :          0 :                 RTE_LOG(ERR, USER1,
    2069                 :            :                                 "line %u FAILED: %s", __LINE__,
    2070                 :            :                                 "Failed to process asym crypto op\n");
    2071                 :            :                 status = TEST_FAILED;
    2072                 :          0 :                 goto exit;
    2073                 :            :         }
    2074                 :            : 
    2075                 :            :         asym_op = result_op->asym;
    2076                 :            : 
    2077                 :          0 :         debug_hexdump(stdout, "priv_key:",
    2078                 :          0 :                 asym_op->ecdh.priv_key.data, asym_op->ecdh.priv_key.length);
    2079                 :            : 
    2080                 :          0 : exit:
    2081         [ #  # ]:          0 :         if (sess != NULL)
    2082                 :          0 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    2083                 :          0 :         rte_crypto_op_free(op);
    2084                 :          0 :         return status;
    2085                 :            : }
    2086                 :            : 
    2087                 :            : static int
    2088                 :          0 : test_ecdh_pub_key_generate(enum curve curve_id)
    2089                 :            : {
    2090                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    2091                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    2092                 :          0 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    2093                 :          0 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    2094                 :            :         struct crypto_testsuite_ecdh_params input_params;
    2095                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    2096                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
    2097                 :          0 :         struct rte_crypto_asym_xform xform = {0};
    2098                 :          0 :         struct rte_crypto_op *result_op = NULL;
    2099                 :            :         uint8_t output_buf_x[TEST_DATA_SIZE];
    2100                 :            :         uint8_t output_buf_y[TEST_DATA_SIZE];
    2101                 :            :         struct rte_crypto_asym_op *asym_op;
    2102                 :          0 :         struct rte_crypto_op *op = NULL;
    2103                 :            :         int ret, status = TEST_SUCCESS;
    2104                 :          0 :         void *sess = NULL;
    2105                 :            : 
    2106                 :            :         /* Check ECDH capability */
    2107                 :          0 :         idx.type = RTE_CRYPTO_ASYM_XFORM_ECDH;
    2108                 :          0 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    2109         [ #  # ]:          0 :         if (capa == NULL)
    2110                 :            :                 return TEST_SKIPPED;
    2111                 :            : 
    2112         [ #  # ]:          0 :         if (!(capa->op_types & (1 <<  RTE_CRYPTO_ASYM_KE_PUB_KEY_GENERATE)))
    2113                 :            :                 return TEST_SKIPPED;
    2114                 :            : 
    2115         [ #  # ]:          0 :         if (curve_id == ED25519 || curve_id == ED448) {
    2116                 :            :                 /* Check EdDSA capability */
    2117                 :          0 :                 idx.type = RTE_CRYPTO_ASYM_XFORM_EDDSA;
    2118                 :          0 :                 capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    2119         [ #  # ]:          0 :                 if (capa == NULL)
    2120                 :            :                         return TEST_SKIPPED;
    2121                 :            :         }
    2122                 :            : 
    2123   [ #  #  #  #  :          0 :         switch (curve_id) {
          #  #  #  #  #  
                   #  # ]
    2124                 :          0 :         case SECP192R1:
    2125                 :          0 :                 input_params = ecdh_param_secp192r1;
    2126                 :          0 :                 break;
    2127                 :          0 :         case SECP224R1:
    2128                 :          0 :                 input_params = ecdh_param_secp224r1;
    2129                 :          0 :                 break;
    2130                 :          0 :         case SECP256R1:
    2131                 :          0 :                 input_params = ecdh_param_secp256r1;
    2132                 :          0 :                 break;
    2133                 :          0 :         case SECP384R1:
    2134                 :          0 :                 input_params = ecdh_param_secp384r1;
    2135                 :          0 :                 break;
    2136                 :          0 :         case SECP521R1:
    2137                 :          0 :                 input_params = ecdh_param_secp521r1;
    2138                 :          0 :                 break;
    2139                 :          0 :         case ECGROUP19:
    2140                 :          0 :                 input_params = ecdh_param_group19;
    2141                 :          0 :                 break;
    2142                 :          0 :         case ECGROUP20:
    2143                 :          0 :                 input_params = ecdh_param_group20;
    2144                 :          0 :                 break;
    2145                 :          0 :         case ECGROUP21:
    2146                 :          0 :                 input_params = ecdh_param_group21;
    2147                 :          0 :                 break;
    2148                 :          0 :         case ED25519:
    2149                 :          0 :                 input_params = ecdh_param_ed25519;
    2150                 :          0 :                 break;
    2151                 :          0 :         case ED448:
    2152                 :          0 :                 input_params = ecdh_param_ed448;
    2153                 :          0 :                 break;
    2154                 :          0 :         default:
    2155                 :          0 :                 RTE_LOG(ERR, USER1,
    2156                 :            :                                 "line %u FAILED: %s", __LINE__,
    2157                 :            :                                 "Unsupported curve id\n");
    2158                 :            :                 status = TEST_FAILED;
    2159                 :          0 :                 goto exit;
    2160                 :            :         }
    2161                 :            : 
    2162                 :          0 :         debug_hexdump(stdout, "pkey:",
    2163                 :            :                 input_params.pkey_A.data, input_params.pkey_A.length);
    2164                 :            : 
    2165                 :            :         /* Setup crypto op data structure */
    2166                 :          0 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    2167         [ #  # ]:          0 :         if (op == NULL) {
    2168                 :          0 :                 RTE_LOG(ERR, USER1,
    2169                 :            :                                 "line %u FAILED: %s", __LINE__,
    2170                 :            :                                 "Failed to allocate asymmetric crypto "
    2171                 :            :                                 "operation struct\n");
    2172                 :            :                 status = TEST_FAILED;
    2173                 :          0 :                 goto exit;
    2174                 :            :         }
    2175                 :            :         asym_op = op->asym;
    2176                 :            : 
    2177                 :            :         /* Setup asym xform */
    2178                 :          0 :         xform.next = NULL;
    2179                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECDH;
    2180                 :          0 :         xform.ec.curve_id = input_params.curve;
    2181                 :          0 :         xform.ec.pkey.data = input_params.pkey_A.data;
    2182                 :          0 :         xform.ec.pkey.length = input_params.pkey_A.length;
    2183                 :            : 
    2184                 :          0 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    2185         [ #  # ]:          0 :         if (ret < 0) {
    2186                 :          0 :                 RTE_LOG(ERR, USER1,
    2187                 :            :                                 "line %u FAILED: %s", __LINE__,
    2188                 :            :                                 "Session creation failed\n");
    2189         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    2190                 :          0 :                 goto exit;
    2191                 :            :         }
    2192                 :            : 
    2193                 :            :         /* Attach asymmetric crypto session to crypto operations */
    2194         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(op, sess);
    2195                 :            : 
    2196                 :            :         /* Populate op with operational details */
    2197                 :          0 :         asym_op->ecdh.ke_type = RTE_CRYPTO_ASYM_KE_PUB_KEY_GENERATE;
    2198         [ #  # ]:          0 :         if (curve_id == ED25519 || curve_id == ED448)
    2199                 :          0 :                 asym_op->flags |= RTE_CRYPTO_ASYM_FLAG_PUB_KEY_COMPRESSED;
    2200                 :            : 
    2201                 :            :         /* Init out buf */
    2202                 :          0 :         asym_op->ecdh.pub_key.x.data = output_buf_x;
    2203         [ #  # ]:          0 :         if (curve_id == ED25519 || curve_id == ED448)
    2204                 :          0 :                 asym_op->ecdh.pub_key.y.data = NULL;
    2205                 :            :         else
    2206                 :          0 :                 asym_op->ecdh.pub_key.y.data = output_buf_y;
    2207                 :            : 
    2208                 :          0 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
    2209                 :            : 
    2210                 :            :         /* Process crypto operation */
    2211         [ #  # ]:          0 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    2212                 :          0 :                 RTE_LOG(ERR, USER1,
    2213                 :            :                                 "line %u FAILED: %s", __LINE__,
    2214                 :            :                                 "Error sending packet for operation\n");
    2215                 :            :                 status = TEST_FAILED;
    2216                 :          0 :                 goto exit;
    2217                 :            :         }
    2218                 :            : 
    2219         [ #  # ]:          0 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    2220                 :            :                 rte_pause();
    2221                 :            : 
    2222         [ #  # ]:          0 :         if (result_op == NULL) {
    2223                 :          0 :                 RTE_LOG(ERR, USER1,
    2224                 :            :                                 "line %u FAILED: %s", __LINE__,
    2225                 :            :                                 "Failed to process asym crypto op\n");
    2226                 :            :                 status = TEST_FAILED;
    2227                 :          0 :                 goto exit;
    2228                 :            :         }
    2229                 :            : 
    2230         [ #  # ]:          0 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    2231                 :          0 :                 RTE_LOG(ERR, USER1,
    2232                 :            :                                 "line %u FAILED: %s", __LINE__,
    2233                 :            :                                 "Failed to process asym crypto op\n");
    2234                 :            :                 status = TEST_FAILED;
    2235                 :          0 :                 goto exit;
    2236                 :            :         }
    2237                 :            : 
    2238                 :            :         asym_op = result_op->asym;
    2239                 :            : 
    2240                 :          0 :         debug_hexdump(stdout, "qx:",
    2241                 :          0 :                 asym_op->ecdh.pub_key.x.data, asym_op->ecdh.pub_key.x.length);
    2242                 :          0 :         debug_hexdump(stdout, "qy:",
    2243                 :          0 :                 asym_op->ecdh.pub_key.y.data, asym_op->ecdh.pub_key.y.length);
    2244                 :            : 
    2245         [ #  # ]:          0 :         if (curve_id == ED25519 || curve_id == ED448)
    2246                 :          0 :                 ret = memcmp(input_params.pubkey_qA_x.data, result_op->asym->ecdh.pub_key.x.data,
    2247                 :          0 :                            result_op->asym->ecdh.pub_key.x.length);
    2248                 :            :         else
    2249                 :          0 :                 ret = verify_ecdh_secret(input_params.pubkey_qA_x.data,
    2250                 :            :                                 input_params.pubkey_qA_y.data, result_op);
    2251                 :            : 
    2252         [ #  # ]:          0 :         if (ret) {
    2253                 :            :                 status = TEST_FAILED;
    2254                 :          0 :                 RTE_LOG(ERR, USER1,
    2255                 :            :                                 "line %u FAILED: %s", __LINE__,
    2256                 :            :                                 "ECDH public key generation failed.\n");
    2257                 :          0 :                 goto exit;
    2258                 :            :         }
    2259                 :            : 
    2260                 :          0 : exit:
    2261         [ #  # ]:          0 :         if (sess != NULL)
    2262                 :          0 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    2263                 :          0 :         rte_crypto_op_free(op);
    2264                 :          0 :         return status;
    2265                 :            : }
    2266                 :            : 
    2267                 :            : static int
    2268                 :          0 : test_ecdh_pub_key_verify(enum curve curve_id)
    2269                 :            : {
    2270                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    2271                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    2272                 :          0 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    2273                 :          0 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    2274                 :            :         struct crypto_testsuite_ecdh_params input_params;
    2275                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    2276                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
    2277                 :          0 :         struct rte_crypto_asym_xform xform = {0};
    2278                 :          0 :         struct rte_crypto_op *result_op = NULL;
    2279                 :            :         struct rte_crypto_asym_op *asym_op;
    2280                 :          0 :         struct rte_crypto_op *op = NULL;
    2281                 :            :         int ret, status = TEST_SUCCESS;
    2282                 :          0 :         void *sess = NULL;
    2283                 :            : 
    2284                 :            :         /* Check ECDH capability */
    2285                 :          0 :         idx.type = RTE_CRYPTO_ASYM_XFORM_ECDH;
    2286                 :          0 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    2287         [ #  # ]:          0 :         if (capa == NULL)
    2288                 :            :                 return TEST_SKIPPED;
    2289                 :            : 
    2290         [ #  # ]:          0 :         if (!(capa->op_types & (1 <<  RTE_CRYPTO_ASYM_KE_PUB_KEY_VERIFY)))
    2291                 :            :                 return TEST_SKIPPED;
    2292                 :            : 
    2293   [ #  #  #  #  :          0 :         switch (curve_id) {
             #  #  #  #  
                      # ]
    2294                 :          0 :         case SECP192R1:
    2295                 :          0 :                 input_params = ecdh_param_secp192r1;
    2296                 :          0 :                 break;
    2297                 :          0 :         case SECP224R1:
    2298                 :          0 :                 input_params = ecdh_param_secp224r1;
    2299                 :          0 :                 break;
    2300                 :          0 :         case SECP256R1:
    2301                 :          0 :                 input_params = ecdh_param_secp256r1;
    2302                 :          0 :                 break;
    2303                 :          0 :         case SECP384R1:
    2304                 :          0 :                 input_params = ecdh_param_secp384r1;
    2305                 :          0 :                 break;
    2306                 :          0 :         case SECP521R1:
    2307                 :          0 :                 input_params = ecdh_param_secp521r1;
    2308                 :          0 :                 break;
    2309                 :          0 :         case ECGROUP19:
    2310                 :          0 :                 input_params = ecdh_param_group19;
    2311                 :          0 :                 break;
    2312                 :          0 :         case ECGROUP20:
    2313                 :          0 :                 input_params = ecdh_param_group20;
    2314                 :          0 :                 break;
    2315                 :          0 :         case ECGROUP21:
    2316                 :          0 :                 input_params = ecdh_param_group21;
    2317                 :          0 :                 break;
    2318                 :          0 :         default:
    2319                 :          0 :                 RTE_LOG(ERR, USER1,
    2320                 :            :                                 "line %u FAILED: %s", __LINE__,
    2321                 :            :                                 "Unsupported curve id\n");
    2322                 :            :                 status = TEST_FAILED;
    2323                 :          0 :                 goto exit;
    2324                 :            :         }
    2325                 :            : 
    2326                 :          0 :         debug_hexdump(stdout, "qx:",
    2327                 :            :                 input_params.pubkey_qA_x.data, input_params.pubkey_qA_x.length);
    2328                 :          0 :         debug_hexdump(stdout, "qy:",
    2329                 :            :                 input_params.pubkey_qA_y.data, input_params.pubkey_qA_y.length);
    2330                 :            : 
    2331                 :            :         /* Setup crypto op data structure */
    2332                 :          0 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    2333         [ #  # ]:          0 :         if (op == NULL) {
    2334                 :          0 :                 RTE_LOG(ERR, USER1,
    2335                 :            :                                 "line %u FAILED: %s", __LINE__,
    2336                 :            :                                 "Failed to allocate asymmetric crypto "
    2337                 :            :                                 "operation struct\n");
    2338                 :            :                 status = TEST_FAILED;
    2339                 :          0 :                 goto exit;
    2340                 :            :         }
    2341                 :            :         asym_op = op->asym;
    2342                 :            : 
    2343                 :            :         /* Setup asym xform */
    2344                 :          0 :         xform.next = NULL;
    2345                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECDH;
    2346                 :          0 :         xform.ec.curve_id = input_params.curve;
    2347                 :            : 
    2348                 :          0 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    2349         [ #  # ]:          0 :         if (ret < 0) {
    2350                 :          0 :                 RTE_LOG(ERR, USER1,
    2351                 :            :                                 "line %u FAILED: %s", __LINE__,
    2352                 :            :                                 "Session creation failed\n");
    2353         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    2354                 :          0 :                 goto exit;
    2355                 :            :         }
    2356                 :            : 
    2357                 :            :         /* Attach asymmetric crypto session to crypto operations */
    2358         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(op, sess);
    2359                 :            : 
    2360                 :            :         /* Populate op with operational details */
    2361                 :          0 :         asym_op->ecdh.ke_type = RTE_CRYPTO_ASYM_KE_PUB_KEY_VERIFY;
    2362                 :          0 :         asym_op->ecdh.pub_key.x.data = input_params.pubkey_qA_x.data;
    2363                 :          0 :         asym_op->ecdh.pub_key.x.length = input_params.pubkey_qA_x.length;
    2364                 :          0 :         asym_op->ecdh.pub_key.y.data = input_params.pubkey_qA_y.data;
    2365                 :          0 :         asym_op->ecdh.pub_key.y.length = input_params.pubkey_qA_y.length;
    2366                 :            : 
    2367                 :          0 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
    2368                 :            : 
    2369                 :            :         /* Process crypto operation */
    2370         [ #  # ]:          0 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    2371                 :          0 :                 RTE_LOG(ERR, USER1,
    2372                 :            :                                 "line %u FAILED: %s", __LINE__,
    2373                 :            :                                 "Error sending packet for operation\n");
    2374                 :            :                 status = TEST_FAILED;
    2375                 :          0 :                 goto exit;
    2376                 :            :         }
    2377                 :            : 
    2378         [ #  # ]:          0 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    2379                 :            :                 rte_pause();
    2380                 :            : 
    2381         [ #  # ]:          0 :         if (result_op == NULL) {
    2382                 :          0 :                 RTE_LOG(ERR, USER1,
    2383                 :            :                                 "line %u FAILED: %s", __LINE__,
    2384                 :            :                                 "Failed to process asym crypto op\n");
    2385                 :            :                 status = TEST_FAILED;
    2386                 :          0 :                 goto exit;
    2387                 :            :         }
    2388                 :            : 
    2389         [ #  # ]:          0 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    2390                 :          0 :                 RTE_LOG(ERR, USER1,
    2391                 :            :                                 "line %u FAILED: %s", __LINE__,
    2392                 :            :                                 "Failed to process asym crypto op\n");
    2393                 :            :                 status = TEST_FAILED;
    2394                 :          0 :                 goto exit;
    2395                 :            :         }
    2396                 :            : 
    2397                 :          0 : exit:
    2398         [ #  # ]:          0 :         if (sess != NULL)
    2399                 :          0 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    2400                 :          0 :         rte_crypto_op_free(op);
    2401                 :          0 :         return status;
    2402                 :            : }
    2403                 :            : 
    2404                 :            : static int
    2405                 :          0 : test_ecdh_shared_secret(enum curve curve_id)
    2406                 :            : {
    2407                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    2408                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    2409                 :          0 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    2410                 :          0 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    2411                 :            :         struct crypto_testsuite_ecdh_params input_params;
    2412                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    2413                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
    2414                 :          0 :         struct rte_crypto_asym_xform xform = {0};
    2415                 :          0 :         struct rte_crypto_op *result_op = NULL;
    2416                 :            :         uint8_t output_buf_x[TEST_DATA_SIZE];
    2417                 :            :         uint8_t output_buf_y[TEST_DATA_SIZE];
    2418                 :            :         struct rte_crypto_asym_op *asym_op;
    2419                 :          0 :         struct rte_crypto_op *op = NULL;
    2420                 :            :         int ret, status = TEST_SUCCESS;
    2421                 :          0 :         void *sess = NULL;
    2422                 :            : 
    2423                 :            :         /* Check ECDH capability */
    2424                 :          0 :         idx.type = RTE_CRYPTO_ASYM_XFORM_ECDH;
    2425                 :          0 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    2426         [ #  # ]:          0 :         if (capa == NULL)
    2427                 :            :                 return TEST_SKIPPED;
    2428                 :            : 
    2429         [ #  # ]:          0 :         if (!(capa->op_types & (1 <<  RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE)))
    2430                 :            :                 return TEST_SKIPPED;
    2431                 :            : 
    2432   [ #  #  #  #  :          0 :         switch (curve_id) {
             #  #  #  #  
                      # ]
    2433                 :          0 :         case SECP192R1:
    2434                 :          0 :                 input_params = ecdh_param_secp192r1;
    2435                 :          0 :                 break;
    2436                 :          0 :         case SECP224R1:
    2437                 :          0 :                 input_params = ecdh_param_secp224r1;
    2438                 :          0 :                 break;
    2439                 :          0 :         case SECP256R1:
    2440                 :          0 :                 input_params = ecdh_param_secp256r1;
    2441                 :          0 :                 break;
    2442                 :          0 :         case SECP384R1:
    2443                 :          0 :                 input_params = ecdh_param_secp384r1;
    2444                 :          0 :                 break;
    2445                 :          0 :         case SECP521R1:
    2446                 :          0 :                 input_params = ecdh_param_secp521r1;
    2447                 :          0 :                 break;
    2448                 :          0 :         case ECGROUP19:
    2449                 :          0 :                 input_params = ecdh_param_group19;
    2450                 :          0 :                 break;
    2451                 :          0 :         case ECGROUP20:
    2452                 :          0 :                 input_params = ecdh_param_group20;
    2453                 :          0 :                 break;
    2454                 :          0 :         case ECGROUP21:
    2455                 :          0 :                 input_params = ecdh_param_group21;
    2456                 :          0 :                 break;
    2457                 :          0 :         default:
    2458                 :          0 :                 RTE_LOG(ERR, USER1,
    2459                 :            :                                 "line %u FAILED: %s", __LINE__,
    2460                 :            :                                 "Unsupported curve id\n");
    2461                 :            :                 status = TEST_FAILED;
    2462                 :          0 :                 goto exit;
    2463                 :            :         }
    2464                 :            : 
    2465                 :            :         /* zA = dA.QB */
    2466                 :          0 :         debug_hexdump(stdout, "pkey:",
    2467                 :            :                 input_params.pkey_A.data, input_params.pkey_A.length);
    2468                 :          0 :         debug_hexdump(stdout, "qx:",
    2469                 :            :                 input_params.pubkey_qB_x.data, input_params.pubkey_qB_x.length);
    2470                 :          0 :         debug_hexdump(stdout, "qy:",
    2471                 :            :                 input_params.pubkey_qB_y.data, input_params.pubkey_qB_y.length);
    2472                 :            : 
    2473                 :            :         /* Setup crypto op data structure */
    2474                 :          0 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    2475         [ #  # ]:          0 :         if (op == NULL) {
    2476                 :          0 :                 RTE_LOG(ERR, USER1,
    2477                 :            :                                 "line %u FAILED: %s", __LINE__,
    2478                 :            :                                 "Failed to allocate asymmetric crypto "
    2479                 :            :                                 "operation struct\n");
    2480                 :            :                 status = TEST_FAILED;
    2481                 :          0 :                 goto exit;
    2482                 :            :         }
    2483                 :            :         asym_op = op->asym;
    2484                 :            : 
    2485                 :            :         /* Setup asym xform */
    2486                 :          0 :         xform.next = NULL;
    2487                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECDH;
    2488                 :          0 :         xform.ec.curve_id = input_params.curve;
    2489                 :          0 :         xform.ec.pkey.data = input_params.pkey_A.data;
    2490                 :          0 :         xform.ec.pkey.length = input_params.pkey_A.length;
    2491                 :          0 :         xform.ec.q.x.data = input_params.pubkey_qB_x.data;
    2492                 :          0 :         xform.ec.q.x.length = input_params.pubkey_qB_x.length;
    2493                 :          0 :         xform.ec.q.y.data = input_params.pubkey_qB_y.data;
    2494                 :          0 :         xform.ec.q.y.length = input_params.pubkey_qB_y.length;
    2495                 :            : 
    2496                 :          0 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    2497         [ #  # ]:          0 :         if (ret < 0) {
    2498                 :          0 :                 RTE_LOG(ERR, USER1,
    2499                 :            :                                 "line %u FAILED: %s", __LINE__,
    2500                 :            :                                 "Session creation failed\n");
    2501         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    2502                 :          0 :                 goto exit;
    2503                 :            :         }
    2504                 :            : 
    2505                 :            :         /* Attach asymmetric crypto session to crypto operations */
    2506         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(op, sess);
    2507                 :            : 
    2508                 :            :         /* Populate op with operational details */
    2509                 :          0 :         asym_op->ecdh.ke_type = RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE;
    2510                 :            : 
    2511                 :            :         /* Init out buf */
    2512                 :          0 :         asym_op->ecdh.shared_secret.x.data = output_buf_x;
    2513                 :          0 :         asym_op->ecdh.shared_secret.y.data = output_buf_y;
    2514                 :            : 
    2515                 :          0 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
    2516                 :            : 
    2517                 :            :         /* Process crypto operation */
    2518         [ #  # ]:          0 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    2519                 :          0 :                 RTE_LOG(ERR, USER1,
    2520                 :            :                                 "line %u FAILED: %s", __LINE__,
    2521                 :            :                                 "Error sending packet for operation\n");
    2522                 :            :                 status = TEST_FAILED;
    2523                 :          0 :                 goto exit;
    2524                 :            :         }
    2525                 :            : 
    2526         [ #  # ]:          0 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    2527                 :            :                 rte_pause();
    2528                 :            : 
    2529         [ #  # ]:          0 :         if (result_op == NULL) {
    2530                 :          0 :                 RTE_LOG(ERR, USER1,
    2531                 :            :                                 "line %u FAILED: %s", __LINE__,
    2532                 :            :                                 "Failed to process asym crypto op\n");
    2533                 :            :                 status = TEST_FAILED;
    2534                 :          0 :                 goto exit;
    2535                 :            :         }
    2536                 :            : 
    2537         [ #  # ]:          0 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    2538                 :          0 :                 RTE_LOG(ERR, USER1,
    2539                 :            :                                 "line %u FAILED: %s", __LINE__,
    2540                 :            :                                 "Failed to process asym crypto op\n");
    2541                 :            :                 status = TEST_FAILED;
    2542                 :          0 :                 goto exit;
    2543                 :            :         }
    2544                 :            : 
    2545                 :            :         asym_op = result_op->asym;
    2546                 :            : 
    2547                 :          0 :         debug_hexdump(stdout, "secret_x:",
    2548                 :          0 :                 asym_op->ecdh.shared_secret.x.data, asym_op->ecdh.shared_secret.x.length);
    2549                 :          0 :         debug_hexdump(stdout, "secret_y:",
    2550                 :          0 :                 asym_op->ecdh.shared_secret.y.data, asym_op->ecdh.shared_secret.y.length);
    2551                 :            : 
    2552                 :          0 :         ret = verify_ecdh_secret(input_params.secret_x.data,
    2553                 :            :                                 input_params.secret_y.data, result_op);
    2554         [ #  # ]:          0 :         if (ret) {
    2555                 :            :                 status = TEST_FAILED;
    2556                 :          0 :                 RTE_LOG(ERR, USER1,
    2557                 :            :                                 "line %u FAILED: %s", __LINE__,
    2558                 :            :                                 "ECDH shared secret compute failed.\n");
    2559                 :          0 :                 goto exit;
    2560                 :            :         }
    2561                 :            : 
    2562         [ #  # ]:          0 :         if (sess != NULL)
    2563                 :          0 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    2564                 :          0 :         rte_crypto_op_free(op);
    2565                 :            : 
    2566                 :            :         /* zB = dB.QA */
    2567                 :          0 :         debug_hexdump(stdout, "pkey:",
    2568                 :            :                 input_params.pkey_B.data, input_params.pkey_B.length);
    2569                 :          0 :         debug_hexdump(stdout, "qx:",
    2570                 :            :                 input_params.pubkey_qA_x.data, input_params.pubkey_qA_x.length);
    2571                 :          0 :         debug_hexdump(stdout, "qy:",
    2572                 :            :                 input_params.pubkey_qA_y.data, input_params.pubkey_qA_y.length);
    2573                 :            : 
    2574                 :            :         /* Setup crypto op data structure */
    2575                 :          0 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    2576         [ #  # ]:          0 :         if (op == NULL) {
    2577                 :          0 :                 RTE_LOG(ERR, USER1,
    2578                 :            :                                 "line %u FAILED: %s", __LINE__,
    2579                 :            :                                 "Failed to allocate asymmetric crypto "
    2580                 :            :                                 "operation struct\n");
    2581                 :            :                 status = TEST_FAILED;
    2582                 :          0 :                 goto exit;
    2583                 :            :         }
    2584                 :            :         asym_op = op->asym;
    2585                 :            : 
    2586                 :            :         /* Setup asym xform */
    2587                 :          0 :         xform.next = NULL;
    2588                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECDH;
    2589                 :          0 :         xform.ec.curve_id = input_params.curve;
    2590                 :          0 :         xform.ec.pkey.data = input_params.pkey_B.data;
    2591                 :          0 :         xform.ec.pkey.length = input_params.pkey_B.length;
    2592                 :          0 :         xform.ec.q.x.data = input_params.pubkey_qA_x.data;
    2593                 :          0 :         xform.ec.q.x.length = input_params.pubkey_qA_x.length;
    2594                 :          0 :         xform.ec.q.y.data = input_params.pubkey_qA_y.data;
    2595                 :          0 :         xform.ec.q.y.length = input_params.pubkey_qA_y.length;
    2596                 :            : 
    2597                 :          0 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    2598         [ #  # ]:          0 :         if (ret < 0) {
    2599                 :          0 :                 RTE_LOG(ERR, USER1,
    2600                 :            :                                 "line %u FAILED: %s", __LINE__,
    2601                 :            :                                 "Session creation failed\n");
    2602         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    2603                 :          0 :                 goto exit;
    2604                 :            :         }
    2605                 :            : 
    2606                 :            :         /* Attach asymmetric crypto session to crypto operations */
    2607         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(op, sess);
    2608                 :            : 
    2609                 :            :         /* Populate op with operational details */
    2610                 :          0 :         asym_op->ecdh.ke_type = RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE;
    2611                 :            : 
    2612                 :            :         /* Init out buf */
    2613                 :          0 :         asym_op->ecdh.shared_secret.x.data = output_buf_x;
    2614                 :          0 :         asym_op->ecdh.shared_secret.y.data = output_buf_y;
    2615                 :            : 
    2616                 :          0 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
    2617                 :            : 
    2618                 :            :         /* Process crypto operation */
    2619         [ #  # ]:          0 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    2620                 :          0 :                 RTE_LOG(ERR, USER1,
    2621                 :            :                                 "line %u FAILED: %s", __LINE__,
    2622                 :            :                                 "Error sending packet for operation\n");
    2623                 :            :                 status = TEST_FAILED;
    2624                 :          0 :                 goto exit;
    2625                 :            :         }
    2626                 :            : 
    2627         [ #  # ]:          0 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    2628                 :            :                 rte_pause();
    2629                 :            : 
    2630         [ #  # ]:          0 :         if (result_op == NULL) {
    2631                 :          0 :                 RTE_LOG(ERR, USER1,
    2632                 :            :                                 "line %u FAILED: %s", __LINE__,
    2633                 :            :                                 "Failed to process asym crypto op\n");
    2634                 :            :                 status = TEST_FAILED;
    2635                 :          0 :                 goto exit;
    2636                 :            :         }
    2637                 :            : 
    2638         [ #  # ]:          0 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    2639                 :          0 :                 RTE_LOG(ERR, USER1,
    2640                 :            :                                 "line %u FAILED: %s", __LINE__,
    2641                 :            :                                 "Failed to process asym crypto op\n");
    2642                 :            :                 status = TEST_FAILED;
    2643                 :          0 :                 goto exit;
    2644                 :            :         }
    2645                 :            : 
    2646                 :            :         asym_op = result_op->asym;
    2647                 :            : 
    2648                 :          0 :         debug_hexdump(stdout, "secret_x:",
    2649                 :          0 :                         asym_op->ecdh.shared_secret.x.data, asym_op->ecdh.shared_secret.x.length);
    2650                 :          0 :         debug_hexdump(stdout, "secret_y:",
    2651                 :          0 :                         asym_op->ecdh.shared_secret.y.data, asym_op->ecdh.shared_secret.y.length);
    2652                 :            : 
    2653                 :          0 :         ret = verify_ecdh_secret(input_params.secret_x.data,
    2654                 :            :                                 input_params.secret_y.data, result_op);
    2655         [ #  # ]:          0 :         if (ret) {
    2656                 :            :                 status = TEST_FAILED;
    2657                 :          0 :                 RTE_LOG(ERR, USER1,
    2658                 :            :                                 "line %u FAILED: %s", __LINE__,
    2659                 :            :                                 "ECDH shared secret compute failed.\n");
    2660                 :          0 :                 goto exit;
    2661                 :            :         }
    2662                 :            : 
    2663                 :          0 : exit:
    2664         [ #  # ]:          0 :         if (sess != NULL)
    2665                 :          0 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    2666                 :          0 :         rte_crypto_op_free(op);
    2667                 :          0 :         return status;
    2668                 :            : }
    2669                 :            : 
    2670                 :            : static int
    2671                 :          0 : test_ecdh_all_curve(void)
    2672                 :            : {
    2673                 :            :         int status, overall_status = TEST_SUCCESS;
    2674                 :            :         enum curve curve_id;
    2675                 :            :         int test_index = 0;
    2676                 :            :         const char *msg;
    2677                 :            : 
    2678         [ #  # ]:          0 :         for (curve_id = SECP192R1; curve_id < END_OF_CURVE_LIST; curve_id++) {
    2679                 :          0 :                 if (curve_id == SECP521R1_UA || curve_id == ECGROUP19 ||
    2680                 :            :                     curve_id == ECGROUP20 || curve_id == ECGROUP21 ||
    2681         [ #  # ]:          0 :                     curve_id == ED25519 || curve_id == ED448)
    2682                 :          0 :                         continue;
    2683                 :            : 
    2684                 :          0 :                 status = test_ecdh_priv_key_generate(curve_id);
    2685         [ #  # ]:          0 :                 if (status == TEST_SUCCESS) {
    2686                 :            :                         msg = "succeeded";
    2687         [ #  # ]:          0 :                 } else if (status == TEST_SKIPPED) {
    2688                 :            :                         msg = "skipped";
    2689                 :            :                 } else {
    2690                 :            :                         msg = "failed";
    2691                 :            :                         overall_status = status;
    2692                 :            :                 }
    2693                 :          0 :                 printf("  %u) TestCase ECDH private key generation for Curve %s %s\n",
    2694                 :            :                        test_index ++, curve[curve_id], msg);
    2695                 :            :         }
    2696                 :            : 
    2697         [ #  # ]:          0 :         for (curve_id = SECP192R1; curve_id < END_OF_CURVE_LIST; curve_id++) {
    2698         [ #  # ]:          0 :                 if (curve_id == SECP521R1_UA)
    2699                 :          0 :                         continue;
    2700                 :            : 
    2701                 :          0 :                 status = test_ecdh_pub_key_generate(curve_id);
    2702         [ #  # ]:          0 :                 if (status == TEST_SUCCESS) {
    2703                 :            :                         msg = "succeeded";
    2704         [ #  # ]:          0 :                 } else if (status == TEST_SKIPPED) {
    2705                 :            :                         msg = "skipped";
    2706                 :            :                 } else {
    2707                 :            :                         msg = "failed";
    2708                 :            :                         overall_status = status;
    2709                 :            :                 }
    2710                 :          0 :                 printf("  %u) TestCase ECDH public key generation for Curve %s %s\n",
    2711                 :            :                        test_index ++, curve[curve_id], msg);
    2712                 :            :         }
    2713                 :            : 
    2714         [ #  # ]:          0 :         for (curve_id = SECP192R1; curve_id < END_OF_CURVE_LIST; curve_id++) {
    2715   [ #  #  #  # ]:          0 :                 if (curve_id == SECP521R1_UA || curve_id == ED25519 || curve_id == ED448)
    2716                 :          0 :                         continue;
    2717                 :            : 
    2718                 :          0 :                 status = test_ecdh_pub_key_verify(curve_id);
    2719         [ #  # ]:          0 :                 if (status == TEST_SUCCESS) {
    2720                 :            :                         msg = "succeeded";
    2721         [ #  # ]:          0 :                 } else if (status == TEST_SKIPPED) {
    2722                 :            :                         msg = "skipped";
    2723                 :            :                 } else {
    2724                 :            :                         msg = "failed";
    2725                 :            :                         overall_status = status;
    2726                 :            :                 }
    2727                 :          0 :                 printf("  %u) TestCase ECDH public key verification for Curve %s %s\n",
    2728                 :            :                        test_index ++, curve[curve_id], msg);
    2729                 :            :         }
    2730                 :            : 
    2731         [ #  # ]:          0 :         for (curve_id = SECP192R1; curve_id < END_OF_CURVE_LIST; curve_id++) {
    2732   [ #  #  #  # ]:          0 :                 if (curve_id == SECP521R1_UA || curve_id == ED25519 || curve_id == ED448)
    2733                 :          0 :                         continue;
    2734                 :            : 
    2735                 :          0 :                 status = test_ecdh_shared_secret(curve_id);
    2736         [ #  # ]:          0 :                 if (status == TEST_SUCCESS) {
    2737                 :            :                         msg = "succeeded";
    2738         [ #  # ]:          0 :                 } else if (status == TEST_SKIPPED) {
    2739                 :            :                         msg = "skipped";
    2740                 :            :                 } else {
    2741                 :            :                         msg = "failed";
    2742                 :            :                         overall_status = status;
    2743                 :            :                 }
    2744                 :          0 :                 printf("  %u) TestCase ECDH shared secret compute for Curve %s %s\n",
    2745                 :            :                        test_index ++, curve[curve_id], msg);
    2746                 :            :         }
    2747                 :            : 
    2748                 :          0 :         return overall_status;
    2749                 :            : }
    2750                 :            : 
    2751                 :            : static int
    2752                 :          0 : test_ecdh_qat_curves(void)
    2753                 :            : {
    2754                 :            :         int status, overall_status = TEST_SUCCESS;
    2755                 :            :         enum curve curve_id;
    2756                 :            :         int test_index = 0;
    2757                 :            :         const char *msg;
    2758                 :            : 
    2759         [ #  # ]:          0 :         for (curve_id = SECP256R1; curve_id <= SECP521R1; curve_id++) {
    2760                 :          0 :                 status = test_ecdh_pub_key_generate(curve_id);
    2761         [ #  # ]:          0 :                 if (status == TEST_SUCCESS) {
    2762                 :            :                         msg = "succeeded";
    2763         [ #  # ]:          0 :                 } else if (status == TEST_SKIPPED) {
    2764                 :            :                         msg = "skipped";
    2765                 :            :                 } else {
    2766                 :            :                         msg = "failed";
    2767                 :            :                         overall_status = status;
    2768                 :            :                 }
    2769                 :          0 :                 printf("  %u) TestCase ECDH public key generation for Curve %s %s\n",
    2770                 :            :                        test_index ++, curve[curve_id], msg);
    2771                 :            :         }
    2772                 :            : 
    2773         [ #  # ]:          0 :         for (curve_id = SECP256R1; curve_id <= SECP521R1; curve_id++) {
    2774                 :          0 :                 status = test_ecdh_pub_key_verify(curve_id);
    2775         [ #  # ]:          0 :                 if (status == TEST_SUCCESS) {
    2776                 :            :                         msg = "succeeded";
    2777         [ #  # ]:          0 :                 } else if (status == TEST_SKIPPED) {
    2778                 :            :                         msg = "skipped";
    2779                 :            :                 } else {
    2780                 :            :                         msg = "failed";
    2781                 :            :                         overall_status = status;
    2782                 :            :                 }
    2783                 :          0 :                 printf("  %u) TestCase ECDH public key verification for Curve %s %s\n",
    2784                 :            :                        test_index ++, curve[curve_id], msg);
    2785                 :            :         }
    2786                 :            : 
    2787         [ #  # ]:          0 :         for (curve_id = SECP256R1; curve_id <= SECP521R1; curve_id++) {
    2788                 :          0 :                 status = test_ecdh_shared_secret(curve_id);
    2789         [ #  # ]:          0 :                 if (status == TEST_SUCCESS) {
    2790                 :            :                         msg = "succeeded";
    2791         [ #  # ]:          0 :                 } else if (status == TEST_SKIPPED) {
    2792                 :            :                         msg = "skipped";
    2793                 :            :                 } else {
    2794                 :            :                         msg = "failed";
    2795                 :            :                         overall_status = status;
    2796                 :            :                 }
    2797                 :          0 :                 printf("  %u) TestCase ECDH shared secret compute for Curve %s %s\n",
    2798                 :            :                        test_index ++, curve[curve_id], msg);
    2799                 :            :         }
    2800                 :            : 
    2801                 :          0 :         return overall_status;
    2802                 :            : }
    2803                 :            : 
    2804                 :            : 
    2805                 :            : static int
    2806                 :          1 : test_sm2_sign(void)
    2807                 :            : {
    2808                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    2809                 :          1 :         struct crypto_testsuite_sm2_params input_params = sm2_param_fp256;
    2810                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    2811                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    2812                 :          1 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    2813                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    2814                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    2815                 :          1 :         struct rte_crypto_op *result_op = NULL;
    2816                 :            :         uint8_t output_buf_r[TEST_DATA_SIZE];
    2817                 :            :         uint8_t output_buf_s[TEST_DATA_SIZE];
    2818                 :            :         struct rte_crypto_asym_xform xform;
    2819                 :            :         struct rte_crypto_asym_op *asym_op;
    2820                 :          1 :         struct rte_crypto_op *op = NULL;
    2821                 :            :         int ret, status = TEST_SUCCESS;
    2822                 :          1 :         void *sess = NULL;
    2823                 :            : 
    2824                 :            :         /* Check SM2 capability */
    2825                 :          1 :         idx.type = RTE_CRYPTO_ASYM_XFORM_SM2;
    2826                 :          1 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    2827         [ +  - ]:          1 :         if (capa == NULL)
    2828                 :            :                 return -ENOTSUP;
    2829                 :            : 
    2830                 :            :         /* Setup crypto op data structure */
    2831                 :          1 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    2832         [ -  + ]:          1 :         if (op == NULL) {
    2833                 :          0 :                 RTE_LOG(ERR, USER1,
    2834                 :            :                                 "line %u FAILED: %s", __LINE__,
    2835                 :            :                                 "Failed to allocate asymmetric crypto "
    2836                 :            :                                 "operation struct\n");
    2837                 :            :                 status = TEST_FAILED;
    2838                 :          0 :                 goto exit;
    2839                 :            :         }
    2840                 :            : 
    2841                 :            :         asym_op = op->asym;
    2842                 :            : 
    2843                 :            :         /* Setup asym xform */
    2844                 :          1 :         xform.next = NULL;
    2845                 :          1 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
    2846                 :          1 :         xform.ec.curve_id = input_params.curve;
    2847                 :          1 :         xform.ec.pkey.data = input_params.pkey.data;
    2848                 :          1 :         xform.ec.pkey.length = input_params.pkey.length;
    2849                 :          1 :         xform.ec.q.x.data = input_params.pubkey_qx.data;
    2850                 :          1 :         xform.ec.q.x.length = input_params.pubkey_qx.length;
    2851                 :          1 :         xform.ec.q.y.data = input_params.pubkey_qy.data;
    2852                 :          1 :         xform.ec.q.y.length = input_params.pubkey_qy.length;
    2853                 :            : 
    2854                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    2855         [ -  + ]:          1 :         if (ret < 0) {
    2856                 :          0 :                 RTE_LOG(ERR, USER1,
    2857                 :            :                                 "line %u FAILED: %s", __LINE__,
    2858                 :            :                                 "Session creation failed\n");
    2859         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    2860                 :          0 :                 goto exit;
    2861                 :            :         }
    2862                 :            : 
    2863                 :            :         /* Attach asymmetric crypto session to crypto operations */
    2864         [ +  - ]:          1 :         rte_crypto_op_attach_asym_session(op, sess);
    2865                 :            : 
    2866                 :            :         /* Compute sign */
    2867                 :            : 
    2868                 :            :         /* Populate op with operational details */
    2869                 :          1 :         asym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
    2870         [ +  - ]:          1 :         if (rte_cryptodev_asym_xform_capability_check_opcap(capa,
    2871                 :            :                         RTE_CRYPTO_ASYM_OP_SIGN, RTE_CRYPTO_SM2_PH))
    2872                 :          1 :                 asym_op->sm2.hash = RTE_CRYPTO_AUTH_SM3;
    2873                 :            :         else
    2874                 :          0 :                 asym_op->sm2.hash = RTE_CRYPTO_AUTH_NULL;
    2875                 :            : 
    2876         [ +  - ]:          1 :         if (asym_op->sm2.hash == RTE_CRYPTO_AUTH_SM3) {
    2877                 :          1 :                 asym_op->sm2.message.data = input_params.message.data;
    2878                 :          1 :                 asym_op->sm2.message.length = input_params.message.length;
    2879                 :          1 :                 asym_op->sm2.id.data = input_params.id.data;
    2880                 :          1 :                 asym_op->sm2.id.length = input_params.id.length;
    2881                 :            :         } else {
    2882                 :          0 :                 asym_op->sm2.message.data = input_params.digest.data;
    2883                 :          0 :                 asym_op->sm2.message.length = input_params.digest.length;
    2884                 :          0 :                 asym_op->sm2.id.data = NULL;
    2885                 :          0 :                 asym_op->sm2.id.length = 0;
    2886                 :            :         }
    2887                 :            : 
    2888         [ +  - ]:          1 :         if (rte_cryptodev_asym_xform_capability_check_opcap(capa,
    2889                 :            :                         RTE_CRYPTO_ASYM_OP_ENCRYPT, RTE_CRYPTO_SM2_RNG)) {
    2890                 :          1 :                 asym_op->sm2.k.data = NULL;
    2891                 :          1 :                 asym_op->sm2.k.length = 0;
    2892                 :            :         } else {
    2893                 :          0 :                 asym_op->sm2.k.data = input_params.k.data;
    2894                 :          0 :                 asym_op->sm2.k.length = input_params.k.length;
    2895                 :            :         }
    2896                 :            : 
    2897                 :            :         /* Init out buf */
    2898                 :          1 :         asym_op->sm2.r.data = output_buf_r;
    2899                 :          1 :         asym_op->sm2.s.data = output_buf_s;
    2900                 :            : 
    2901                 :          1 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
    2902                 :            : 
    2903                 :            :         /* Process crypto operation */
    2904         [ -  + ]:          1 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    2905                 :          0 :                 RTE_LOG(ERR, USER1,
    2906                 :            :                                 "line %u FAILED: %s", __LINE__,
    2907                 :            :                                 "Error sending packet for operation\n");
    2908                 :            :                 status = TEST_FAILED;
    2909                 :          0 :                 goto exit;
    2910                 :            :         }
    2911                 :            : 
    2912         [ -  + ]:          1 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    2913                 :            :                 rte_pause();
    2914                 :            : 
    2915         [ -  + ]:          1 :         if (result_op == NULL) {
    2916                 :          0 :                 RTE_LOG(ERR, USER1,
    2917                 :            :                                 "line %u FAILED: %s", __LINE__,
    2918                 :            :                                 "Failed to process asym crypto op\n");
    2919                 :            :                 status = TEST_FAILED;
    2920                 :          0 :                 goto exit;
    2921                 :            :         }
    2922                 :            : 
    2923         [ -  + ]:          1 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    2924                 :          0 :                 RTE_LOG(ERR, USER1,
    2925                 :            :                                 "line %u FAILED: %s", __LINE__,
    2926                 :            :                                 "Failed to process asym crypto op\n");
    2927                 :            :                 status = TEST_FAILED;
    2928                 :          0 :                 goto exit;
    2929                 :            :         }
    2930                 :            : 
    2931                 :            :         asym_op = result_op->asym;
    2932                 :            : 
    2933                 :          1 :         debug_hexdump(stdout, "r:",
    2934                 :          1 :                         asym_op->sm2.r.data, asym_op->sm2.r.length);
    2935                 :          1 :         debug_hexdump(stdout, "s:",
    2936                 :          1 :                         asym_op->sm2.s.data, asym_op->sm2.s.length);
    2937                 :            : 
    2938         [ -  + ]:          1 :         if (!rte_cryptodev_asym_xform_capability_check_opcap(capa,
    2939                 :            :                         RTE_CRYPTO_ASYM_OP_SIGN, RTE_CRYPTO_SM2_RNG)) {
    2940                 :            :                 /* Verify sign (by comparison). */
    2941         [ #  # ]:          0 :                 if (memcmp(input_params.sign_r.data, asym_op->sm2.r.data,
    2942                 :            :                                    asym_op->sm2.r.length) != 0) {
    2943                 :            :                         status = TEST_FAILED;
    2944                 :          0 :                         RTE_LOG(ERR, USER1,
    2945                 :            :                                         "line %u FAILED: %s", __LINE__,
    2946                 :            :                                         "SM2 sign failed.\n");
    2947                 :          0 :                         goto exit;
    2948                 :            :                 }
    2949         [ #  # ]:          0 :                 if (memcmp(input_params.sign_s.data, asym_op->sm2.s.data,
    2950                 :            :                                    asym_op->sm2.s.length) != 0) {
    2951                 :            :                         status = TEST_FAILED;
    2952                 :          0 :                         RTE_LOG(ERR, USER1,
    2953                 :            :                                         "line %u FAILED: %s", __LINE__,
    2954                 :            :                                         "SM2 sign failed.\n");
    2955                 :          0 :                         goto exit;
    2956                 :            :                 }
    2957                 :            :         } else {
    2958                 :            :                 /* Verify sign (in roundtrip).
    2959                 :            :                  * Due to random number used per message, sign op
    2960                 :            :                  * would produce different output for same message
    2961                 :            :                  * every time. Hence, we can't have expected output
    2962                 :            :                  * to match, instead reverse op to verify.
    2963                 :            :                  */
    2964                 :            : 
    2965                 :            :                 /* Populate op with operational details */
    2966                 :          1 :                 asym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
    2967                 :            : 
    2968                 :            :                 /* Enqueue sign result for verify */
    2969         [ -  + ]:          1 :                 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    2970                 :            :                         status = TEST_FAILED;
    2971                 :          0 :                         RTE_LOG(ERR, USER1,
    2972                 :            :                                         "line %u FAILED: %s", __LINE__,
    2973                 :            :                                         "Error sending packet for operation\n");
    2974                 :          0 :                         goto exit;
    2975                 :            :                 }
    2976                 :            : 
    2977         [ -  + ]:          1 :                 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    2978                 :            :                         rte_pause();
    2979                 :            : 
    2980         [ -  + ]:          1 :                 if (result_op == NULL) {
    2981                 :            :                         status = TEST_FAILED;
    2982                 :          0 :                         goto exit;
    2983                 :            :                 }
    2984         [ +  - ]:          1 :                 if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    2985                 :            :                         status = TEST_FAILED;
    2986                 :          0 :                         RTE_LOG(ERR, USER1,
    2987                 :            :                                         "line %u FAILED: %s", __LINE__,
    2988                 :            :                                         "SM2 verify failed.\n");
    2989                 :          0 :                         goto exit;
    2990                 :            :                 }
    2991                 :            :         }
    2992                 :            : 
    2993                 :          1 : exit:
    2994         [ +  - ]:          1 :         if (sess != NULL)
    2995                 :          1 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    2996                 :          1 :         rte_crypto_op_free(op);
    2997                 :          1 :         return status;
    2998                 :            : };
    2999                 :            : 
    3000                 :            : static int
    3001                 :          1 : test_sm2_verify(void)
    3002                 :            : {
    3003                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    3004                 :          1 :         struct crypto_testsuite_sm2_params input_params = sm2_param_fp256;
    3005                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    3006                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    3007                 :          1 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    3008                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    3009                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    3010                 :          1 :         struct rte_crypto_op *result_op = NULL;
    3011                 :            :         struct rte_crypto_asym_xform xform;
    3012                 :            :         struct rte_crypto_asym_op *asym_op;
    3013                 :          1 :         struct rte_crypto_op *op = NULL;
    3014                 :            :         int ret, status = TEST_SUCCESS;
    3015                 :          1 :         void *sess = NULL;
    3016                 :            : 
    3017                 :            :         /* Check SM2 capability */
    3018                 :          1 :         idx.type = RTE_CRYPTO_ASYM_XFORM_SM2;
    3019                 :          1 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    3020         [ +  - ]:          1 :         if (capa == NULL)
    3021                 :            :                 return -ENOTSUP;
    3022                 :            : 
    3023                 :            :         /* Setup crypto op data structure */
    3024                 :          1 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    3025         [ -  + ]:          1 :         if (op == NULL) {
    3026                 :          0 :                 RTE_LOG(ERR, USER1,
    3027                 :            :                                 "line %u FAILED: %s", __LINE__,
    3028                 :            :                                 "Failed to allocate asymmetric crypto "
    3029                 :            :                                 "operation struct\n");
    3030                 :            :                 status = TEST_FAILED;
    3031                 :          0 :                 goto exit;
    3032                 :            :         }
    3033                 :            : 
    3034                 :            :         asym_op = op->asym;
    3035                 :            : 
    3036                 :            :         /* Setup asym xform */
    3037                 :          1 :         xform.next = NULL;
    3038                 :          1 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
    3039                 :          1 :         xform.ec.curve_id = input_params.curve;
    3040                 :          1 :         xform.ec.pkey.data = input_params.pkey.data;
    3041                 :          1 :         xform.ec.pkey.length = input_params.pkey.length;
    3042                 :          1 :         xform.ec.q.x.data = input_params.pubkey_qx.data;
    3043                 :          1 :         xform.ec.q.x.length = input_params.pubkey_qx.length;
    3044                 :          1 :         xform.ec.q.y.data = input_params.pubkey_qy.data;
    3045                 :          1 :         xform.ec.q.y.length = input_params.pubkey_qy.length;
    3046                 :            : 
    3047                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    3048         [ -  + ]:          1 :         if (ret < 0) {
    3049                 :          0 :                 RTE_LOG(ERR, USER1,
    3050                 :            :                                 "line %u FAILED: %s", __LINE__,
    3051                 :            :                                 "Session creation failed\n");
    3052         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    3053                 :          0 :                 goto exit;
    3054                 :            :         }
    3055                 :            : 
    3056                 :            :         /* Attach asymmetric crypto session to crypto operations */
    3057         [ +  - ]:          1 :         rte_crypto_op_attach_asym_session(op, sess);
    3058                 :            : 
    3059                 :            :         /* Verify given sign */
    3060                 :            : 
    3061                 :            :         /* Populate op with operational details */
    3062                 :          1 :         asym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
    3063                 :            : 
    3064         [ +  - ]:          1 :         if (rte_cryptodev_asym_xform_capability_check_opcap(capa,
    3065                 :            :                         RTE_CRYPTO_ASYM_OP_VERIFY, RTE_CRYPTO_SM2_PH))
    3066                 :          1 :                 asym_op->sm2.hash = RTE_CRYPTO_AUTH_SM3;
    3067                 :            :         else
    3068                 :          0 :                 asym_op->sm2.hash = RTE_CRYPTO_AUTH_NULL;
    3069                 :            : 
    3070         [ +  - ]:          1 :         if (asym_op->sm2.hash == RTE_CRYPTO_AUTH_SM3) {
    3071                 :          1 :                 asym_op->sm2.message.data = input_params.message.data;
    3072                 :          1 :                 asym_op->sm2.message.length = input_params.message.length;
    3073                 :          1 :                 asym_op->sm2.id.data = input_params.id.data;
    3074                 :          1 :                 asym_op->sm2.id.length = input_params.id.length;
    3075                 :            :         } else {
    3076                 :          0 :                 asym_op->sm2.message.data = input_params.digest.data;
    3077                 :          0 :                 asym_op->sm2.message.length = input_params.digest.length;
    3078                 :          0 :                 asym_op->sm2.id.data = NULL;
    3079                 :          0 :                 asym_op->sm2.id.length = 0;
    3080                 :            :         }
    3081                 :            : 
    3082                 :          1 :         asym_op->sm2.r.data = input_params.sign_r.data;
    3083                 :          1 :         asym_op->sm2.r.length = input_params.sign_r.length;
    3084                 :          1 :         asym_op->sm2.s.data = input_params.sign_s.data;
    3085                 :          1 :         asym_op->sm2.s.length = input_params.sign_s.length;
    3086                 :            : 
    3087                 :          1 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
    3088                 :            : 
    3089                 :            :         /* Process crypto operation */
    3090         [ -  + ]:          1 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    3091                 :          0 :                 RTE_LOG(ERR, USER1,
    3092                 :            :                                 "line %u FAILED: %s", __LINE__,
    3093                 :            :                                 "Error sending packet for operation\n");
    3094                 :            :                 status = TEST_FAILED;
    3095                 :          0 :                 goto exit;
    3096                 :            :         }
    3097                 :            : 
    3098         [ -  + ]:          1 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    3099                 :            :                 rte_pause();
    3100                 :            : 
    3101         [ -  + ]:          1 :         if (result_op == NULL) {
    3102                 :          0 :                 RTE_LOG(ERR, USER1,
    3103                 :            :                                 "line %u FAILED: %s", __LINE__,
    3104                 :            :                                 "Failed to process asym crypto op\n");
    3105                 :            :                 status = TEST_FAILED;
    3106                 :          0 :                 goto exit;
    3107                 :            :         }
    3108                 :            : 
    3109         [ +  - ]:          1 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    3110                 :          0 :                 RTE_LOG(ERR, USER1,
    3111                 :            :                                 "line %u FAILED: %s", __LINE__,
    3112                 :            :                                 "Failed to process asym crypto op\n");
    3113                 :            :                 status = TEST_FAILED;
    3114                 :          0 :                 goto exit;
    3115                 :            :         }
    3116                 :            : 
    3117                 :          1 : exit:
    3118         [ +  - ]:          1 :         if (sess != NULL)
    3119                 :          1 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    3120                 :          1 :         rte_crypto_op_free(op);
    3121                 :          1 :         return status;
    3122                 :            : };
    3123                 :            : 
    3124                 :            : static int
    3125                 :          1 : test_sm2_enc(void)
    3126                 :            : {
    3127                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    3128                 :          1 :         struct crypto_testsuite_sm2_params input_params = sm2_param_fp256;
    3129                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    3130                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    3131                 :          1 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    3132                 :            :         uint8_t output_buf[TEST_DATA_SIZE], *pbuf = NULL;
    3133                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    3134                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    3135                 :          1 :         struct rte_crypto_op *result_op = NULL;
    3136                 :            :         struct rte_crypto_asym_xform xform;
    3137                 :            :         struct rte_crypto_asym_op *asym_op;
    3138                 :          1 :         struct rte_crypto_op *op = NULL;
    3139                 :            :         int ret, status = TEST_SUCCESS;
    3140                 :          1 :         void *sess = NULL;
    3141                 :            : 
    3142                 :            :         /* Check SM2 capability */
    3143                 :          1 :         idx.type = RTE_CRYPTO_ASYM_XFORM_SM2;
    3144                 :          1 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    3145         [ +  - ]:          1 :         if (capa == NULL)
    3146                 :            :                 return -ENOTSUP;
    3147         [ +  - ]:          1 :         if (!rte_cryptodev_asym_xform_capability_check_opcap(capa,
    3148                 :            :                         RTE_CRYPTO_ASYM_OP_ENCRYPT, 0))
    3149                 :            :                 return TEST_SKIPPED;
    3150                 :            : 
    3151                 :            :         /* Setup crypto op data structure */
    3152                 :          1 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    3153         [ -  + ]:          1 :         if (op == NULL) {
    3154                 :          0 :                 RTE_LOG(ERR, USER1,
    3155                 :            :                                 "line %u FAILED: %s", __LINE__,
    3156                 :            :                                 "Failed to allocate asymmetric crypto "
    3157                 :            :                                 "operation struct\n");
    3158                 :            :                 status = TEST_FAILED;
    3159                 :          0 :                 goto exit;
    3160                 :            :         }
    3161                 :            :         asym_op = op->asym;
    3162                 :            : 
    3163                 :            :         /* Setup asym xform */
    3164                 :          1 :         xform.next = NULL;
    3165                 :          1 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
    3166                 :          1 :         xform.ec.curve_id = input_params.curve;
    3167                 :          1 :         xform.ec.pkey.data = input_params.pkey.data;
    3168                 :          1 :         xform.ec.pkey.length = input_params.pkey.length;
    3169                 :          1 :         xform.ec.q.x.data = input_params.pubkey_qx.data;
    3170                 :          1 :         xform.ec.q.x.length = input_params.pubkey_qx.length;
    3171                 :          1 :         xform.ec.q.y.data = input_params.pubkey_qy.data;
    3172                 :          1 :         xform.ec.q.y.length = input_params.pubkey_qy.length;
    3173                 :            : 
    3174                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    3175         [ -  + ]:          1 :         if (ret < 0) {
    3176                 :          0 :                 RTE_LOG(ERR, USER1,
    3177                 :            :                                 "line %u FAILED: %s", __LINE__,
    3178                 :            :                                 "Session creation failed\n");
    3179         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    3180                 :          0 :                 goto exit;
    3181                 :            :         }
    3182                 :            : 
    3183                 :            :         /* Attach asymmetric crypto session to crypto operations */
    3184         [ +  - ]:          1 :         rte_crypto_op_attach_asym_session(op, sess);
    3185                 :            : 
    3186                 :            :         /* Compute encrypt */
    3187                 :            : 
    3188                 :            :         /* Populate op with operational details */
    3189                 :          1 :         asym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
    3190         [ -  + ]:          1 :         if (rte_cryptodev_asym_xform_capability_check_opcap(capa,
    3191                 :            :                         RTE_CRYPTO_ASYM_OP_ENCRYPT, RTE_CRYPTO_SM2_PH))
    3192                 :          0 :                 asym_op->sm2.hash = RTE_CRYPTO_AUTH_SM3;
    3193                 :            :         else
    3194                 :          1 :                 asym_op->sm2.hash = RTE_CRYPTO_AUTH_NULL;
    3195                 :            : 
    3196                 :          1 :         asym_op->sm2.message.data = input_params.message.data;
    3197                 :          1 :         asym_op->sm2.message.length = input_params.message.length;
    3198                 :            : 
    3199         [ +  - ]:          1 :         if (rte_cryptodev_asym_xform_capability_check_opcap(capa,
    3200                 :            :                         RTE_CRYPTO_ASYM_OP_ENCRYPT, RTE_CRYPTO_SM2_RNG)) {
    3201                 :          1 :                 asym_op->sm2.k.data = NULL;
    3202                 :          1 :                 asym_op->sm2.k.length = 0;
    3203                 :            :         } else {
    3204                 :          0 :                 asym_op->sm2.k.data = input_params.k.data;
    3205                 :          0 :                 asym_op->sm2.k.length = input_params.k.length;
    3206                 :            :         }
    3207                 :            : 
    3208                 :            :         /* Init out buf */
    3209                 :          1 :         asym_op->sm2.cipher.data = output_buf;
    3210                 :            : 
    3211                 :          1 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
    3212                 :            : 
    3213                 :            :         /* Process crypto operation */
    3214         [ -  + ]:          1 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    3215                 :          0 :                 RTE_LOG(ERR, USER1,
    3216                 :            :                                 "line %u FAILED: %s", __LINE__,
    3217                 :            :                                 "Error sending packet for operation\n");
    3218                 :            :                 status = TEST_FAILED;
    3219                 :          0 :                 goto exit;
    3220                 :            :         }
    3221                 :            : 
    3222         [ -  + ]:          1 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    3223                 :            :                 rte_pause();
    3224                 :            : 
    3225         [ -  + ]:          1 :         if (result_op == NULL) {
    3226                 :          0 :                 RTE_LOG(ERR, USER1,
    3227                 :            :                                 "line %u FAILED: %s", __LINE__,
    3228                 :            :                                 "Failed to process asym crypto op\n");
    3229                 :            :                 status = TEST_FAILED;
    3230                 :          0 :                 goto exit;
    3231                 :            :         }
    3232                 :            : 
    3233         [ -  + ]:          1 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    3234                 :          0 :                 RTE_LOG(ERR, USER1,
    3235                 :            :                                 "line %u FAILED: %s", __LINE__,
    3236                 :            :                                 "Failed to process asym crypto op\n");
    3237                 :            :                 status = TEST_FAILED;
    3238                 :          0 :                 goto exit;
    3239                 :            :         }
    3240                 :            : 
    3241                 :            :         asym_op = result_op->asym;
    3242                 :            : 
    3243                 :          1 :         debug_hexdump(stdout, "cipher:",
    3244                 :          1 :                         asym_op->sm2.cipher.data, asym_op->sm2.cipher.length);
    3245                 :            : 
    3246         [ -  + ]:          1 :         if (!rte_cryptodev_asym_xform_capability_check_opcap(capa,
    3247                 :            :                         RTE_CRYPTO_ASYM_OP_ENCRYPT, RTE_CRYPTO_SM2_RNG)) {
    3248         [ #  # ]:          0 :                 if (memcmp(input_params.cipher.data, asym_op->sm2.cipher.data,
    3249                 :            :                                    asym_op->sm2.cipher.length) != 0) {
    3250                 :            :                         status = TEST_FAILED;
    3251                 :          0 :                         RTE_LOG(ERR, USER1, "line %u FAILED: %s", __LINE__,
    3252                 :            :                                         "SM2 encrypt failed.\n");
    3253                 :          0 :                         goto exit;
    3254                 :            :                 }
    3255                 :            :         } else {
    3256                 :            :                 /* Verify cipher (in roundtrip).
    3257                 :            :                  * Due to random number used per message, encrypt op
    3258                 :            :                  * would produce different output for same message
    3259                 :            :                  * every time. Hence, we can't have expected output
    3260                 :            :                  * to match, instead reverse op to decrypt.
    3261                 :            :                  */
    3262                 :            : 
    3263                 :            :                 /* Populate op with operational details */
    3264                 :          1 :                 op->asym->sm2.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
    3265                 :          1 :                 pbuf = rte_malloc(NULL, TEST_DATA_SIZE, 0);
    3266                 :          1 :                 op->asym->sm2.message.data = pbuf;
    3267                 :          1 :                 op->asym->sm2.message.length = TEST_DATA_SIZE;
    3268                 :            : 
    3269                 :            :                 /* Enqueue cipher result for decrypt */
    3270         [ -  + ]:          1 :                 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    3271                 :            :                         status = TEST_FAILED;
    3272                 :          0 :                         RTE_LOG(ERR, USER1,
    3273                 :            :                                         "line %u FAILED: %s", __LINE__,
    3274                 :            :                                         "Error sending packet for operation\n");
    3275                 :          0 :                         goto exit;
    3276                 :            :                 }
    3277                 :            : 
    3278         [ -  + ]:          1 :                 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    3279                 :            :                         rte_pause();
    3280                 :            : 
    3281         [ -  + ]:          1 :                 if (result_op == NULL) {
    3282                 :            :                         status = TEST_FAILED;
    3283                 :          0 :                         goto exit;
    3284                 :            :                 }
    3285         [ -  + ]:          1 :                 if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    3286                 :            :                         status = TEST_FAILED;
    3287                 :          0 :                         RTE_LOG(ERR, USER1,
    3288                 :            :                                         "line %u FAILED: %s", __LINE__,
    3289                 :            :                                         "SM2 encrypt failed.\n");
    3290                 :          0 :                         goto exit;
    3291                 :            :                 }
    3292                 :            : 
    3293                 :            :                 asym_op = result_op->asym;
    3294         [ +  - ]:          1 :                 if (memcmp(input_params.message.data, asym_op->sm2.message.data,
    3295                 :            :                                asym_op->sm2.message.length) != 0) {
    3296                 :            :                         status = TEST_FAILED;
    3297                 :          0 :                         RTE_LOG(ERR, USER1, "line %u FAILED: %s", __LINE__,
    3298                 :            :                                         "SM2 encrypt failed.\n");
    3299                 :          0 :                         goto exit;
    3300                 :            :                 }
    3301                 :            :         }
    3302                 :          1 : exit:
    3303                 :          1 :         rte_free(pbuf);
    3304                 :            : 
    3305         [ +  - ]:          1 :         if (sess != NULL)
    3306                 :          1 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    3307                 :          1 :         rte_crypto_op_free(op);
    3308                 :          1 :         return status;
    3309                 :            : };
    3310                 :            : 
    3311                 :            : static int
    3312                 :          1 : test_sm2_dec(void)
    3313                 :            : {
    3314                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    3315                 :          1 :         struct crypto_testsuite_sm2_params input_params = sm2_param_fp256;
    3316                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    3317                 :          1 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    3318                 :          1 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    3319                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    3320                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    3321                 :          1 :         struct rte_crypto_op *result_op = NULL;
    3322                 :            :         uint8_t output_buf_m[TEST_DATA_SIZE];
    3323                 :            :         struct rte_crypto_asym_xform xform;
    3324                 :            :         struct rte_crypto_asym_op *asym_op;
    3325                 :          1 :         struct rte_crypto_op *op = NULL;
    3326                 :            :         int ret, status = TEST_SUCCESS;
    3327                 :          1 :         void *sess = NULL;
    3328                 :            : 
    3329                 :            :         /* Check SM2 capability */
    3330                 :          1 :         idx.type = RTE_CRYPTO_ASYM_XFORM_SM2;
    3331                 :          1 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    3332         [ +  - ]:          1 :         if (capa == NULL)
    3333                 :            :                 return -ENOTSUP;
    3334         [ +  - ]:          1 :         if (!rte_cryptodev_asym_xform_capability_check_opcap(capa,
    3335                 :            :                         RTE_CRYPTO_ASYM_OP_DECRYPT, 0))
    3336                 :            :                 return TEST_SKIPPED;
    3337                 :            : 
    3338                 :            :         /* Setup crypto op data structure */
    3339                 :          1 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    3340         [ -  + ]:          1 :         if (op == NULL) {
    3341                 :          0 :                 RTE_LOG(ERR, USER1,
    3342                 :            :                                 "line %u FAILED: %s", __LINE__,
    3343                 :            :                                 "Failed to allocate asymmetric crypto "
    3344                 :            :                                 "operation struct\n");
    3345                 :            :                 status = TEST_FAILED;
    3346                 :          0 :                 goto exit;
    3347                 :            :         }
    3348                 :            :         asym_op = op->asym;
    3349                 :            : 
    3350                 :            :         /* Setup asym xform */
    3351                 :          1 :         xform.next = NULL;
    3352                 :          1 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
    3353                 :          1 :         xform.ec.curve_id = input_params.curve;
    3354                 :          1 :         xform.ec.pkey.data = input_params.pkey.data;
    3355                 :          1 :         xform.ec.pkey.length = input_params.pkey.length;
    3356                 :          1 :         xform.ec.q.x.data = input_params.pubkey_qx.data;
    3357                 :          1 :         xform.ec.q.x.length = input_params.pubkey_qx.length;
    3358                 :          1 :         xform.ec.q.y.data = input_params.pubkey_qy.data;
    3359                 :          1 :         xform.ec.q.y.length = input_params.pubkey_qy.length;
    3360                 :            : 
    3361                 :          1 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    3362         [ -  + ]:          1 :         if (ret < 0) {
    3363                 :          0 :                 RTE_LOG(ERR, USER1,
    3364                 :            :                                 "line %u FAILED: %s", __LINE__,
    3365                 :            :                                 "Session creation failed\n");
    3366         [ #  # ]:          0 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    3367                 :          0 :                 goto exit;
    3368                 :            :         }
    3369                 :            : 
    3370                 :            :         /* Attach asymmetric crypto session to crypto operations */
    3371         [ +  - ]:          1 :         rte_crypto_op_attach_asym_session(op, sess);
    3372                 :            : 
    3373                 :            :         /* Compute decrypt */
    3374                 :            : 
    3375                 :            :         /* Populate op with operational details */
    3376                 :          1 :         asym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
    3377         [ -  + ]:          1 :         if (rte_cryptodev_asym_xform_capability_check_opcap(capa,
    3378                 :            :                         RTE_CRYPTO_ASYM_OP_DECRYPT, RTE_CRYPTO_SM2_PH))
    3379                 :          0 :                 asym_op->sm2.hash = RTE_CRYPTO_AUTH_SM3;
    3380                 :            :         else
    3381                 :          1 :                 asym_op->sm2.hash = RTE_CRYPTO_AUTH_NULL;
    3382                 :            : 
    3383                 :          1 :         asym_op->sm2.cipher.data = input_params.cipher.data;
    3384                 :          1 :         asym_op->sm2.cipher.length = input_params.cipher.length;
    3385                 :            : 
    3386                 :            :         /* Init out buf */
    3387                 :          1 :         asym_op->sm2.message.data = output_buf_m;
    3388                 :          1 :         asym_op->sm2.message.length = RTE_DIM(output_buf_m);
    3389                 :            : 
    3390                 :          1 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
    3391                 :            : 
    3392                 :            :         /* Process crypto operation */
    3393         [ -  + ]:          1 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    3394                 :          0 :                 RTE_LOG(ERR, USER1,
    3395                 :            :                                 "line %u FAILED: %s", __LINE__,
    3396                 :            :                                 "Error sending packet for operation\n");
    3397                 :            :                 status = TEST_FAILED;
    3398                 :          0 :                 goto exit;
    3399                 :            :         }
    3400                 :            : 
    3401         [ -  + ]:          1 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    3402                 :            :                 rte_pause();
    3403                 :            : 
    3404         [ -  + ]:          1 :         if (result_op == NULL) {
    3405                 :          0 :                 RTE_LOG(ERR, USER1,
    3406                 :            :                                 "line %u FAILED: %s", __LINE__,
    3407                 :            :                                 "Failed to process asym crypto op\n");
    3408                 :            :                 status = TEST_FAILED;
    3409                 :          0 :                 goto exit;
    3410                 :            :         }
    3411                 :            : 
    3412         [ -  + ]:          1 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    3413                 :          0 :                 RTE_LOG(ERR, USER1,
    3414                 :            :                                 "line %u FAILED: %s", __LINE__,
    3415                 :            :                                 "Failed to process asym crypto op\n");
    3416                 :            :                 status = TEST_FAILED;
    3417                 :          0 :                 goto exit;
    3418                 :            :         }
    3419                 :            : 
    3420                 :            :         asym_op = result_op->asym;
    3421                 :            : 
    3422                 :          1 :         debug_hexdump(stdout, "message:",
    3423                 :          1 :                         asym_op->sm2.message.data, asym_op->sm2.message.length);
    3424                 :            : 
    3425                 :          1 :         if (memcmp(input_params.message.data, asym_op->sm2.message.data,
    3426         [ +  - ]:          1 :                         op->asym->sm2.message.length)) {
    3427                 :            :                 status = TEST_FAILED;
    3428                 :          0 :                 RTE_LOG(ERR, USER1,
    3429                 :            :                                 "line %u FAILED: %s", __LINE__,
    3430                 :            :                                 "SM2 decrypt failed.\n");
    3431                 :          0 :                 goto exit;
    3432                 :            :         }
    3433                 :          1 : exit:
    3434         [ +  - ]:          1 :         if (sess != NULL)
    3435                 :          1 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    3436                 :          1 :         rte_crypto_op_free(op);
    3437                 :          1 :         return status;
    3438                 :            : };
    3439                 :            : 
    3440                 :            : static int
    3441                 :          9 : test_eddsa_sign(struct crypto_testsuite_eddsa_params *input_params)
    3442                 :            : {
    3443                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    3444                 :          9 :         enum rte_crypto_edward_instance instance = input_params->instance;
    3445                 :          9 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    3446                 :          9 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    3447                 :          9 :         uint8_t dev_id = ts_params->valid_devs[0];
    3448                 :          9 :         struct rte_crypto_op *result_op = NULL;
    3449                 :            :         uint8_t output_buf_r[TEST_DATA_SIZE];
    3450                 :            :         struct rte_crypto_asym_xform xform;
    3451                 :            :         struct rte_crypto_asym_op *asym_op;
    3452                 :          9 :         struct rte_crypto_op *op = NULL;
    3453                 :            :         int ret, status = TEST_FAILED;
    3454                 :          9 :         void *sess = NULL;
    3455                 :            :         bool ctx = false;
    3456                 :            : 
    3457         [ +  + ]:          9 :         if (instance == RTE_CRYPTO_EDCURVE_25519CTX)
    3458                 :            :                 ctx = true;
    3459                 :            : 
    3460                 :            :         /* Setup crypto op data structure */
    3461                 :          9 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    3462         [ -  + ]:          9 :         if (op == NULL) {
    3463                 :          0 :                 RTE_LOG(ERR, USER1,
    3464                 :            :                                 "line %u FAILED: %s", __LINE__,
    3465                 :            :                                 "Failed to allocate asymmetric crypto "
    3466                 :            :                                 "operation struct\n");
    3467                 :            :                 status = TEST_FAILED;
    3468                 :          0 :                 goto exit;
    3469                 :            :         }
    3470                 :            : 
    3471                 :            :         asym_op = op->asym;
    3472                 :            : 
    3473                 :            :         /* Setup asym xform */
    3474                 :          9 :         xform.next = NULL;
    3475                 :          9 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_EDDSA;
    3476                 :          9 :         xform.ec.curve_id = input_params->curve;
    3477                 :          9 :         xform.ec.pkey.data = input_params->pkey.data;
    3478                 :          9 :         xform.ec.pkey.length = input_params->pkey.length;
    3479                 :          9 :         xform.ec.q.x.data = input_params->pubkey.data;
    3480                 :          9 :         xform.ec.q.x.length = input_params->pubkey.length;
    3481                 :            : 
    3482                 :          9 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    3483         [ +  - ]:          9 :         if (ret < 0) {
    3484                 :          9 :                 RTE_LOG(ERR, USER1,
    3485                 :            :                                 "line %u FAILED: %s", __LINE__,
    3486                 :            :                                 "Session creation failed\n");
    3487         [ -  + ]:          9 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    3488                 :          9 :                 goto exit;
    3489                 :            :         }
    3490                 :            : 
    3491                 :            :         /* Attach asymmetric crypto session to crypto operations */
    3492         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(op, sess);
    3493                 :            : 
    3494                 :            :         /* Compute sign */
    3495                 :            : 
    3496                 :            :         /* Populate op with operational details */
    3497                 :          0 :         asym_op->eddsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
    3498                 :          0 :         asym_op->eddsa.instance = input_params->instance;
    3499                 :          0 :         asym_op->eddsa.message.data = input_params->message.data;
    3500                 :          0 :         asym_op->eddsa.message.length = input_params->message.length;
    3501                 :          0 :         asym_op->eddsa.context.length = 0;
    3502         [ #  # ]:          0 :         if (ctx) {
    3503                 :          0 :                 asym_op->eddsa.context.data = input_params->context.data;
    3504                 :          0 :                 asym_op->eddsa.context.length = input_params->context.length;
    3505                 :            :         }
    3506                 :            : 
    3507                 :            :         /* Init out buf */
    3508                 :          0 :         asym_op->eddsa.sign.data = output_buf_r;
    3509                 :            : 
    3510                 :          0 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
    3511                 :            : 
    3512                 :            :         /* Process crypto operation */
    3513         [ #  # ]:          0 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    3514                 :          0 :                 RTE_LOG(ERR, USER1,
    3515                 :            :                                 "line %u FAILED: %s", __LINE__,
    3516                 :            :                                 "Error sending packet for operation\n");
    3517                 :          0 :                 goto exit;
    3518                 :            :         }
    3519                 :            : 
    3520         [ #  # ]:          0 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    3521                 :            :                 rte_pause();
    3522                 :            : 
    3523         [ #  # ]:          0 :         if (result_op == NULL) {
    3524                 :          0 :                 RTE_LOG(ERR, USER1,
    3525                 :            :                                 "line %u FAILED: %s", __LINE__,
    3526                 :            :                                 "Failed to process asym crypto op\n");
    3527                 :          0 :                 goto exit;
    3528                 :            :         }
    3529                 :            : 
    3530         [ #  # ]:          0 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    3531                 :          0 :                 RTE_LOG(ERR, USER1,
    3532                 :            :                                 "line %u FAILED: %s", __LINE__,
    3533                 :            :                                 "Failed to process asym crypto op\n");
    3534                 :          0 :                 goto exit;
    3535                 :            :         }
    3536                 :            : 
    3537                 :            :         asym_op = result_op->asym;
    3538                 :            : 
    3539                 :          0 :         debug_hexdump(stdout, "sign:",
    3540                 :          0 :                         asym_op->eddsa.sign.data, asym_op->eddsa.sign.length);
    3541                 :            : 
    3542                 :            :         /* Verify sign (by comparison). */
    3543         [ #  # ]:          0 :         if (memcmp(input_params->sign.data, asym_op->eddsa.sign.data,
    3544                 :            :                            asym_op->eddsa.sign.length) != 0) {
    3545                 :          0 :                 RTE_LOG(ERR, USER1,
    3546                 :            :                                 "line %u FAILED: %s", __LINE__,
    3547                 :            :                                 "EdDSA sign failed.\n");
    3548                 :          0 :                 goto exit;
    3549                 :            :         }
    3550                 :            : 
    3551                 :            :         status = TEST_SUCCESS;
    3552                 :          9 : exit:
    3553         [ +  - ]:          9 :         if (sess != NULL)
    3554                 :          9 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    3555                 :          9 :         rte_crypto_op_free(op);
    3556                 :          9 :         return status;
    3557                 :            : };
    3558                 :            : 
    3559                 :            : static int
    3560                 :          9 : test_eddsa_verify(struct crypto_testsuite_eddsa_params *input_params)
    3561                 :            : {
    3562                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    3563                 :          9 :         enum rte_crypto_edward_instance instance = input_params->instance;
    3564                 :          9 :         struct rte_mempool *sess_mpool = ts_params->session_mpool;
    3565                 :          9 :         struct rte_mempool *op_mpool = ts_params->op_mpool;
    3566                 :          9 :         uint8_t dev_id = ts_params->valid_devs[0];
    3567                 :          9 :         struct rte_crypto_op *result_op = NULL;
    3568                 :            :         struct rte_crypto_asym_xform xform;
    3569                 :            :         struct rte_crypto_asym_op *asym_op;
    3570                 :          9 :         struct rte_crypto_op *op = NULL;
    3571                 :            :         int ret, status = TEST_FAILED;
    3572                 :          9 :         void *sess = NULL;
    3573                 :            :         bool ctx = false;
    3574                 :            : 
    3575         [ +  + ]:          9 :         if (instance == RTE_CRYPTO_EDCURVE_25519CTX)
    3576                 :            :                 ctx = true;
    3577                 :            : 
    3578                 :            :         /* Setup crypto op data structure */
    3579                 :          9 :         op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
    3580         [ -  + ]:          9 :         if (op == NULL) {
    3581                 :          0 :                 RTE_LOG(ERR, USER1,
    3582                 :            :                                 "line %u FAILED: %s", __LINE__,
    3583                 :            :                                 "Failed to allocate asymmetric crypto "
    3584                 :            :                                 "operation struct\n");
    3585                 :          0 :                 goto exit;
    3586                 :            :         }
    3587                 :            : 
    3588                 :            :         asym_op = op->asym;
    3589                 :            : 
    3590                 :            :         /* Setup asym xform */
    3591                 :          9 :         xform.next = NULL;
    3592                 :          9 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_EDDSA;
    3593                 :          9 :         xform.ec.curve_id = input_params->curve;
    3594                 :          9 :         xform.ec.pkey.length = 0;
    3595                 :          9 :         xform.ec.q.x.data = input_params->pubkey.data;
    3596                 :          9 :         xform.ec.q.x.length = input_params->pubkey.length;
    3597                 :            : 
    3598                 :          9 :         ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
    3599         [ +  - ]:          9 :         if (ret < 0) {
    3600                 :          9 :                 RTE_LOG(ERR, USER1,
    3601                 :            :                                 "line %u FAILED: %s", __LINE__,
    3602                 :            :                                 "Session creation failed\n");
    3603         [ -  + ]:          9 :                 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    3604                 :          9 :                 goto exit;
    3605                 :            :         }
    3606                 :            : 
    3607                 :            :         /* Attach asymmetric crypto session to crypto operations */
    3608         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(op, sess);
    3609                 :            : 
    3610                 :            :         /* Compute sign */
    3611                 :            : 
    3612                 :            :         /* Populate op with operational details */
    3613                 :          0 :         asym_op->eddsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
    3614                 :          0 :         asym_op->eddsa.instance = input_params->instance;
    3615                 :          0 :         asym_op->eddsa.message.data = input_params->message.data;
    3616                 :          0 :         asym_op->eddsa.message.length = input_params->message.length;
    3617                 :          0 :         asym_op->eddsa.context.length = 0;
    3618         [ #  # ]:          0 :         if (ctx) {
    3619                 :          0 :                 asym_op->eddsa.context.data = input_params->context.data;
    3620                 :          0 :                 asym_op->eddsa.context.length = input_params->context.length;
    3621                 :            :         }
    3622                 :            : 
    3623                 :          0 :         asym_op->eddsa.sign.data = input_params->sign.data;
    3624                 :          0 :         asym_op->eddsa.sign.length = input_params->sign.length;
    3625                 :            : 
    3626                 :          0 :         RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
    3627                 :            : 
    3628                 :            :         /* Process crypto operation */
    3629         [ #  # ]:          0 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
    3630                 :          0 :                 RTE_LOG(ERR, USER1,
    3631                 :            :                                 "line %u FAILED: %s", __LINE__,
    3632                 :            :                                 "Error sending packet for operation\n");
    3633                 :          0 :                 goto exit;
    3634                 :            :         }
    3635                 :            : 
    3636         [ #  # ]:          0 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
    3637                 :            :                 rte_pause();
    3638                 :            : 
    3639         [ #  # ]:          0 :         if (result_op == NULL) {
    3640                 :          0 :                 RTE_LOG(ERR, USER1,
    3641                 :            :                                 "line %u FAILED: %s", __LINE__,
    3642                 :            :                                 "Failed to process asym crypto op\n");
    3643                 :          0 :                 goto exit;
    3644                 :            :         }
    3645                 :            : 
    3646         [ #  # ]:          0 :         if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    3647                 :          0 :                 RTE_LOG(ERR, USER1,
    3648                 :            :                                 "line %u FAILED: %s", __LINE__,
    3649                 :            :                                 "Failed to process asym crypto op\n");
    3650                 :          0 :                 goto exit;
    3651                 :            :         }
    3652                 :            : 
    3653                 :            :         status = TEST_SUCCESS;
    3654                 :          9 : exit:
    3655         [ +  - ]:          9 :         if (sess != NULL)
    3656                 :          9 :                 rte_cryptodev_asym_session_free(dev_id, sess);
    3657                 :          9 :         rte_crypto_op_free(op);
    3658                 :          9 :         return status;
    3659                 :            : };
    3660                 :            : 
    3661                 :            : static int
    3662                 :          1 : test_eddsa_sign_verify_all_curve(void)
    3663                 :            : {
    3664                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    3665                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    3666                 :            :         struct crypto_testsuite_eddsa_params input_params;
    3667                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    3668                 :            :         int status, overall_status = TEST_SUCCESS;
    3669                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    3670                 :            :         uint8_t i, tc = 0;
    3671                 :            :         const char *msg;
    3672                 :            : 
    3673                 :            :         /* Check EdDSA capability */
    3674                 :          1 :         idx.type = RTE_CRYPTO_ASYM_XFORM_EDDSA;
    3675                 :          1 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    3676         [ +  - ]:          1 :         if (capa == NULL)
    3677                 :            :                 return TEST_SKIPPED;
    3678                 :            : 
    3679                 :            :         /* Sign tests */
    3680         [ +  + ]:          9 :         for (i = 0; i < RTE_DIM(eddsa_test_params); i++) {
    3681                 :          8 :                 memcpy(&input_params, &eddsa_test_params[i],
    3682                 :            :                                 sizeof(input_params));
    3683                 :          8 :                 status = test_eddsa_sign(&input_params);
    3684         [ +  - ]:          8 :                 if (status == TEST_SUCCESS) {
    3685                 :            :                         msg = "succeeded";
    3686                 :            :                 } else {
    3687                 :            :                         msg = "failed";
    3688                 :            :                         overall_status = status;
    3689                 :            :                 }
    3690                 :          8 :                 printf("  %u) TestCase Sign %s  %s\n",
    3691                 :          8 :                        tc++, input_params.description, msg);
    3692                 :            :         }
    3693                 :            : 
    3694                 :            :         /* Verify tests */
    3695         [ +  + ]:          9 :         for (i = 0; i < RTE_DIM(eddsa_test_params); i++) {
    3696                 :          8 :                 memcpy(&input_params, &eddsa_test_params[i],
    3697                 :            :                                 sizeof(input_params));
    3698                 :          8 :                 status = test_eddsa_verify(&input_params);
    3699         [ +  - ]:          8 :                 if (status == TEST_SUCCESS) {
    3700                 :            :                         msg = "succeeded";
    3701                 :            :                 } else {
    3702                 :            :                         msg = "failed";
    3703                 :            :                         overall_status = status;
    3704                 :            :                 }
    3705                 :          8 :                 printf("  %u) TestCase Verify %s  %s\n",
    3706                 :          8 :                        tc++, input_params.description, msg);
    3707                 :            :         }
    3708                 :            : 
    3709                 :            :         /* Negative tests */
    3710                 :            :         memcpy(&input_params, &eddsa_test_params[1],
    3711                 :            :                         sizeof(input_params));
    3712                 :          1 :         input_params.pubkey.data[0] ^= 0x01;
    3713                 :            : 
    3714                 :          1 :         status = test_eddsa_sign(&input_params);
    3715         [ +  - ]:          1 :         if (status == TEST_FAILED) {
    3716                 :            :                 msg = "succeeded";
    3717                 :            :         } else {
    3718                 :            :                 msg = "failed";
    3719                 :            :                 overall_status = status;
    3720                 :            :         }
    3721                 :          1 :         printf("  %u) TestCase Negative Sign %s  %s\n",
    3722                 :          1 :                         tc++, input_params.description, msg);
    3723                 :            : 
    3724                 :          1 :         status = test_eddsa_verify(&input_params);
    3725         [ +  - ]:          1 :         if (status == TEST_FAILED) {
    3726                 :            :                 msg = "succeeded";
    3727                 :            :         } else {
    3728                 :            :                 msg = "failed";
    3729                 :            :                 overall_status = status;
    3730                 :            :         }
    3731                 :          1 :         printf("  %u) TestCase Negative Verify %s  %s\n",
    3732                 :            :                         tc++, input_params.description, msg);
    3733                 :            : 
    3734                 :          1 :         return overall_status;
    3735                 :            : }
    3736                 :            : 
    3737                 :         16 : static int send_one(void)
    3738                 :            : {
    3739                 :            :         int ticks = 0;
    3740                 :            : 
    3741         [ -  + ]:         16 :         if (rte_cryptodev_enqueue_burst(params->valid_devs[0], 0,
    3742                 :         16 :                         &self->op, 1) != 1) {
    3743                 :          0 :                 RTE_LOG(ERR, USER1,
    3744                 :            :                         "line %u FAILED: Error sending packet for operation on device %d",
    3745                 :            :                         __LINE__, params->valid_devs[0]);
    3746                 :          0 :                 return TEST_FAILED;
    3747                 :            :         }
    3748                 :         16 :         while (rte_cryptodev_dequeue_burst(params->valid_devs[0], 0,
    3749         [ -  + ]:         16 :                         &self->result_op, 1) == 0) {
    3750                 :            :                 rte_delay_ms(1);
    3751                 :          0 :                 ticks++;
    3752         [ #  # ]:          0 :                 if (ticks >= DEQ_TIMEOUT) {
    3753                 :          0 :                         RTE_LOG(ERR, USER1,
    3754                 :            :                                 "line %u FAILED: Cannot dequeue the crypto op on device %d",
    3755                 :            :                                 __LINE__, params->valid_devs[0]);
    3756                 :          0 :                         return TEST_FAILED;
    3757                 :            :                 }
    3758                 :            :         }
    3759         [ -  + ]:         16 :         TEST_ASSERT_NOT_NULL(self->result_op,
    3760                 :            :                 "Failed to process asym crypto op");
    3761         [ -  + ]:         16 :         TEST_ASSERT_SUCCESS(self->result_op->status,
    3762                 :            :                 "Failed to process asym crypto op, error status received");
    3763                 :            :         return TEST_SUCCESS;
    3764                 :            : }
    3765                 :            : 
    3766                 :          0 : static int send_one_no_status_check(void)
    3767                 :            : {
    3768                 :            :         int ticks = 0;
    3769                 :            : 
    3770         [ #  # ]:          0 :         if (rte_cryptodev_enqueue_burst(params->valid_devs[0], 0,
    3771                 :          0 :                         &self->op, 1) != 1) {
    3772                 :          0 :                 RTE_LOG(ERR, USER1,
    3773                 :            :                         "line %u FAILED: Error sending packet for operation on device %d",
    3774                 :            :                         __LINE__, params->valid_devs[0]);
    3775                 :          0 :                 return TEST_FAILED;
    3776                 :            :         }
    3777                 :          0 :         while (rte_cryptodev_dequeue_burst(params->valid_devs[0], 0,
    3778         [ #  # ]:          0 :                         &self->result_op, 1) == 0) {
    3779                 :            :                 rte_delay_ms(1);
    3780                 :          0 :                 ticks++;
    3781         [ #  # ]:          0 :                 if (ticks >= DEQ_TIMEOUT) {
    3782                 :          0 :                         RTE_LOG(ERR, USER1,
    3783                 :            :                                 "line %u FAILED: Cannot dequeue the crypto op on device %d",
    3784                 :            :                                 __LINE__, params->valid_devs[0]);
    3785                 :          0 :                         return TEST_FAILED;
    3786                 :            :                 }
    3787                 :            :         }
    3788         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(self->result_op,
    3789                 :            :                 "Failed to process asym crypto op");
    3790                 :            :         return TEST_SUCCESS;
    3791                 :            : }
    3792                 :            : 
    3793                 :            : static int
    3794                 :         11 : modular_cmpeq(const uint8_t *a, size_t a_len, const uint8_t *b, size_t b_len)
    3795                 :            : {
    3796                 :            :         const uint8_t *new_a, *new_b;
    3797                 :            :         size_t i, j;
    3798                 :            : 
    3799                 :            :         /* Strip leading NUL bytes */
    3800         [ +  - ]:         11 :         for (i = 0; i < a_len; i++)
    3801         [ +  - ]:         11 :                 if (a[i] != 0)
    3802                 :            :                         break;
    3803                 :            : 
    3804         [ +  - ]:         11 :         for (j = 0; j < b_len; j++)
    3805         [ -  + ]:         11 :                 if (b[j] != 0)
    3806                 :            :                         break;
    3807                 :            : 
    3808         [ +  - ]:         11 :         if (a_len - i != b_len - j)
    3809                 :            :                 return 1;
    3810                 :            : 
    3811                 :         11 :         new_a = &a[i];
    3812                 :         11 :         new_b = &b[j];
    3813         [ -  + ]:         11 :         if (memcmp(new_a, new_b, a_len - i))
    3814                 :          0 :                 return 1;
    3815                 :            : 
    3816                 :            :         return 0;
    3817                 :            : }
    3818                 :            : 
    3819                 :            : static int
    3820                 :         11 : modular_exponentiation(const void *test_data)
    3821                 :            : {
    3822                 :            :         const struct modex_test_data *vector = test_data;
    3823                 :         11 :         uint8_t input[TEST_DATA_SIZE] = { 0 };
    3824                 :         11 :         uint8_t exponent[TEST_DATA_SIZE] = { 0 };
    3825                 :         11 :         uint8_t modulus[TEST_DATA_SIZE] = { 0 };
    3826                 :         11 :         uint8_t result[TEST_DATA_SIZE] = { 0 };
    3827                 :         11 :         struct rte_crypto_asym_xform xform = { };
    3828                 :         11 :         const uint8_t dev_id = params->valid_devs[0];
    3829                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *cap;
    3830                 :            :         struct rte_cryptodev_asym_capability_idx cap_idx;
    3831                 :            : 
    3832                 :         11 :         cap_idx.type = RTE_CRYPTO_ASYM_XFORM_MODEX;
    3833                 :         11 :         cap = rte_cryptodev_asym_capability_get(dev_id, &cap_idx);
    3834   [ +  -  -  + ]:         22 :         if (cap == NULL || rte_cryptodev_asym_xform_capability_check_modlen(
    3835                 :         11 :                         cap, vector->modulus.len))
    3836                 :          0 :                 return TEST_SKIPPED;
    3837                 :            : 
    3838                 :         11 :         memcpy(input, vector->base.data, vector->base.len);
    3839                 :         11 :         memcpy(exponent, vector->exponent.data, vector->exponent.len);
    3840                 :         11 :         memcpy(modulus, vector->modulus.data, vector->modulus.len);
    3841                 :            : 
    3842                 :         11 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
    3843                 :         11 :         xform.modex.exponent.data = exponent;
    3844                 :         11 :         xform.modex.exponent.length = vector->exponent.len;
    3845                 :         11 :         xform.modex.modulus.data = modulus;
    3846                 :         11 :         xform.modex.modulus.length = vector->modulus.len;
    3847                 :            : 
    3848         [ -  + ]:         11 :         if (rte_cryptodev_asym_session_create(dev_id, &xform,
    3849                 :         11 :                         params->session_mpool, &self->sess) < 0) {
    3850                 :          0 :                 RTE_LOG(ERR, USER1, "line %u FAILED: Session creation failed",
    3851                 :            :                         __LINE__);
    3852                 :          0 :                 return TEST_FAILED;
    3853                 :            :         }
    3854         [ +  - ]:         11 :         rte_crypto_op_attach_asym_session(self->op, self->sess);
    3855                 :         11 :         self->op->asym->modex.base.data = input;
    3856                 :         11 :         self->op->asym->modex.base.length = vector->base.len;
    3857                 :         11 :         self->op->asym->modex.result.data = result;
    3858                 :            : 
    3859         [ -  + ]:         11 :         TEST_ASSERT_SUCCESS(send_one(),
    3860                 :            :                 "Failed to process crypto op");
    3861         [ -  + ]:         11 :         TEST_ASSERT_SUCCESS(modular_cmpeq(vector->reminder.data, vector->reminder.len,
    3862                 :            :                         self->result_op->asym->modex.result.data,
    3863                 :            :                         self->result_op->asym->modex.result.length),
    3864                 :            :                         "operation verification failed\n");
    3865                 :            : 
    3866                 :            :         return TEST_SUCCESS;
    3867                 :            : }
    3868                 :            : 
    3869                 :            : static int
    3870                 :          1 : modular_multiplicative_inverse(const void *test_data)
    3871                 :            : {
    3872                 :            :         const struct modinv_test_data *vector = test_data;
    3873                 :          1 :         uint8_t input[TEST_DATA_SIZE] = { 0 };
    3874                 :          1 :         uint8_t modulus[TEST_DATA_SIZE] = { 0 };
    3875                 :          1 :         uint8_t result[TEST_DATA_SIZE] = { 0 };
    3876                 :          1 :         struct rte_crypto_asym_xform xform = { };
    3877                 :          1 :         const uint8_t dev_id = params->valid_devs[0];
    3878                 :            : 
    3879                 :          1 :         memcpy(input, vector->base.data, vector->base.len);
    3880                 :          1 :         memcpy(modulus, vector->modulus.data, vector->modulus.len);
    3881                 :          1 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_MODINV;
    3882                 :          1 :         xform.modex.modulus.data = modulus;
    3883                 :          1 :         xform.modex.modulus.length = vector->modulus.len;
    3884         [ -  + ]:          1 :         if (rte_cryptodev_asym_session_create(dev_id, &xform,
    3885                 :          1 :                         params->session_mpool, &self->sess) < 0) {
    3886                 :          0 :                 RTE_LOG(ERR, USER1, "line %u FAILED: Session creation failed",
    3887                 :            :                         __LINE__);
    3888                 :          0 :                 return TEST_FAILED;
    3889                 :            :         }
    3890         [ +  - ]:          1 :         rte_crypto_op_attach_asym_session(self->op, self->sess);
    3891                 :            : 
    3892                 :          1 :         self->op->asym->modinv.base.data = input;
    3893                 :          1 :         self->op->asym->modinv.base.length = vector->base.len;
    3894                 :          1 :         self->op->asym->modinv.result.data = result;
    3895                 :          1 :         self->op->asym->modinv.result.length = vector->modulus.len;
    3896                 :            : 
    3897         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(send_one(),
    3898                 :            :                 "Failed to process crypto op");
    3899         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->inverse.data,
    3900                 :            :                 self->result_op->asym->modinv.result.data,
    3901                 :            :                 self->result_op->asym->modinv.result.length,
    3902                 :            :                 "Incorrect reminder\n");
    3903                 :            : 
    3904                 :            :         return TEST_SUCCESS;
    3905                 :            : }
    3906                 :            : 
    3907                 :            : static int
    3908                 :          0 : mlkem_keygen(const void *test_data)
    3909                 :            : {
    3910                 :            :         const struct crypto_testsuite_mlkem_params *vector = test_data;
    3911                 :          0 :         const uint8_t dev_id = params->valid_devs[0];
    3912                 :          0 :         struct rte_crypto_asym_xform xform = {0};
    3913                 :          0 :         uint8_t ek[TEST_DATA_SIZE] = {0};
    3914                 :          0 :         uint8_t dk[TEST_DATA_SIZE] = {0};
    3915                 :            : 
    3916                 :          0 :         xform.mlkem.type = vector->type;
    3917                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ML_KEM;
    3918         [ #  # ]:          0 :         if (rte_cryptodev_asym_session_create(dev_id, &xform,
    3919                 :          0 :                         params->session_mpool, &self->sess) < 0) {
    3920                 :          0 :                 RTE_LOG(ERR, USER1, "line %u FAILED: Session creation failed",
    3921                 :            :                         __LINE__);
    3922                 :          0 :                 return TEST_FAILED;
    3923                 :            :         }
    3924                 :            : 
    3925         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(self->op, self->sess);
    3926                 :          0 :         self->op->asym->mlkem.op = RTE_CRYPTO_ML_KEM_OP_KEYGEN;
    3927                 :          0 :         self->op->asym->mlkem.keygen.d.data = vector->d.data;
    3928                 :          0 :         self->op->asym->mlkem.keygen.d.length = vector->d.length;
    3929                 :          0 :         self->op->asym->mlkem.keygen.z.data = vector->z.data;
    3930                 :          0 :         self->op->asym->mlkem.keygen.z.length = vector->z.length;
    3931                 :          0 :         self->op->asym->mlkem.keygen.dk.data = dk;
    3932                 :          0 :         self->op->asym->mlkem.keygen.dk.length = 0;
    3933                 :          0 :         self->op->asym->mlkem.keygen.ek.data = ek;
    3934                 :          0 :         self->op->asym->mlkem.keygen.ek.length = 0;
    3935         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one(),
    3936                 :            :                 "Failed to process crypto op (ML-KEM KeyGen)");
    3937                 :          0 :         debug_hexdump(stdout, "Decapsulation key",
    3938                 :          0 :                 self->result_op->asym->mlkem.keygen.dk.data,
    3939                 :          0 :                 self->result_op->asym->mlkem.keygen.dk.length);
    3940                 :          0 :         debug_hexdump(stdout, "Encapsulation key",
    3941                 :          0 :                 self->result_op->asym->mlkem.keygen.ek.data,
    3942                 :          0 :                 self->result_op->asym->mlkem.keygen.ek.length);
    3943                 :            : 
    3944                 :            :         /* Verify the result with the test vector */
    3945         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(self->result_op->asym->mlkem.keygen.dk.length,
    3946                 :            :                 rte_crypto_ml_kem_privkey_size[vector->type],
    3947                 :            :                 "Incorrect Decapsulation key length\n");
    3948         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(self->result_op->asym->mlkem.keygen.ek.length,
    3949                 :            :                 rte_crypto_ml_kem_pubkey_size[vector->type],
    3950                 :            :                 "Incorrect Encapsulation key length\n");
    3951                 :            : 
    3952                 :            :         /* If the seed is all zero, keys are deterministic */
    3953                 :          0 :         if (memcmp(vector->d.data, (uint8_t [32]) {0},
    3954         [ #  # ]:          0 :                         vector->d.length) == 0) {
    3955         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->dk.data,
    3956                 :            :                         self->result_op->asym->mlkem.keygen.dk.data,
    3957                 :            :                         self->result_op->asym->mlkem.keygen.dk.length,
    3958                 :            :                         "Incorrect Decapsulation key\n");
    3959         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->ek.data,
    3960                 :            :                         self->result_op->asym->mlkem.keygen.ek.data,
    3961                 :            :                         self->result_op->asym->mlkem.keygen.ek.length,
    3962                 :            :                         "Incorrect Encapsulation key\n");
    3963                 :          0 :                 RTE_LOG(DEBUG, USER1, "Deterministic keygen test passed\n");
    3964                 :            :         }
    3965                 :            : 
    3966                 :          0 :         rte_cryptodev_asym_session_free(dev_id, self->sess);
    3967                 :          0 :         return TEST_SUCCESS;
    3968                 :            : }
    3969                 :            : 
    3970                 :            : static int
    3971                 :          0 : mlkem_encap(const void *test_data)
    3972                 :            : {
    3973                 :            :         const struct crypto_testsuite_mlkem_params *vector = test_data;
    3974                 :          0 :         const uint8_t dev_id = params->valid_devs[0];
    3975                 :          0 :         struct rte_crypto_asym_xform xform = {0};
    3976                 :          0 :         uint8_t cipher[TEST_DATA_SIZE] = {0};
    3977                 :          0 :         uint8_t skcopy[TEST_DATA_SIZE] = {0};
    3978                 :          0 :         uint8_t sk[TEST_DATA_SIZE] = {0};
    3979                 :            :         size_t cipher_len;
    3980                 :            : 
    3981                 :          0 :         xform.mlkem.type = vector->type;
    3982                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ML_KEM;
    3983         [ #  # ]:          0 :         if (rte_cryptodev_asym_session_create(dev_id, &xform,
    3984                 :          0 :                         params->session_mpool, &self->sess) < 0) {
    3985                 :          0 :                 RTE_LOG(ERR, USER1, "line %u FAILED: Session creation failed",
    3986                 :            :                         __LINE__);
    3987                 :          0 :                 return TEST_FAILED;
    3988                 :            :         }
    3989                 :            : 
    3990         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(self->op, self->sess);
    3991                 :            : 
    3992                 :            :         /* Encapsulate */
    3993                 :          0 :         self->op->asym->mlkem.op = RTE_CRYPTO_ML_KEM_OP_ENCAP;
    3994                 :          0 :         self->op->asym->mlkem.encap.message.data = vector->message.data;
    3995                 :          0 :         self->op->asym->mlkem.encap.message.length = vector->message.length;
    3996                 :          0 :         self->op->asym->mlkem.encap.ek.data = vector->ek.data;
    3997                 :          0 :         self->op->asym->mlkem.encap.ek.length = vector->ek.length;
    3998                 :          0 :         self->op->asym->mlkem.encap.cipher.data = cipher;
    3999                 :          0 :         self->op->asym->mlkem.encap.cipher.length =
    4000                 :          0 :                 rte_crypto_ml_kem_cipher_size[vector->type];
    4001                 :          0 :         self->op->asym->mlkem.encap.sk.data = sk;
    4002                 :          0 :         self->op->asym->mlkem.encap.sk.length = 32;
    4003                 :            : 
    4004         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one(),
    4005                 :            :                 "Failed to process crypto op (ML-KEM Encap)");
    4006                 :          0 :         debug_hexdump(stdout, "Cipher",
    4007                 :          0 :                 self->result_op->asym->mlkem.encap.cipher.data,
    4008                 :          0 :                 self->result_op->asym->mlkem.encap.cipher.length);
    4009                 :          0 :         debug_hexdump(stdout, "Shared secret from encap",
    4010                 :          0 :                 self->result_op->asym->mlkem.encap.sk.data,
    4011                 :          0 :                 self->result_op->asym->mlkem.encap.sk.length);
    4012                 :            : 
    4013                 :            :         /* Verify the result with the test vector */
    4014         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(self->result_op->asym->mlkem.encap.cipher.length,
    4015                 :            :                 rte_crypto_ml_kem_cipher_size[vector->type],
    4016                 :            :                 "Incorrect Cipher length\n");
    4017         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(self->result_op->asym->mlkem.encap.sk.length, 32,
    4018                 :            :                 "Incorrect Shared key length\n");
    4019                 :            : 
    4020                 :            :         /* If random message is set, cipher and shared secret are deterministic */
    4021         [ #  # ]:          0 :         if (vector->message.length != 0) {
    4022         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->cipher.data,
    4023                 :            :                         self->result_op->asym->mlkem.encap.cipher.data,
    4024                 :            :                         self->result_op->asym->mlkem.encap.cipher.length,
    4025                 :            :                         "Incorrect Cipher\n");
    4026                 :            : 
    4027         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->sk.data,
    4028                 :            :                         self->result_op->asym->mlkem.encap.sk.data,
    4029                 :            :                         self->result_op->asym->mlkem.encap.sk.length,
    4030                 :            :                         "Incorrect Shared secret\n");
    4031                 :          0 :                 RTE_LOG(DEBUG, USER1, "Deterministic encap test passed\n");
    4032                 :            :         }
    4033                 :            : 
    4034                 :            :         /* Decapsulate and verify */
    4035                 :          0 :         cipher_len = self->result_op->asym->mlkem.encap.cipher.length;
    4036                 :          0 :         memcpy(skcopy, self->result_op->asym->mlkem.encap.sk.data,
    4037                 :            :                 self->result_op->asym->mlkem.encap.sk.length);
    4038                 :            :         memset(sk, 0, sizeof(sk));
    4039                 :            : 
    4040                 :          0 :         self->op->asym->mlkem.op = RTE_CRYPTO_ML_KEM_OP_DECAP;
    4041                 :          0 :         self->op->asym->mlkem.decap.dk.data = vector->dk.data;
    4042                 :          0 :         self->op->asym->mlkem.decap.dk.length = vector->dk.length;
    4043                 :          0 :         self->op->asym->mlkem.decap.cipher.data = cipher;
    4044                 :          0 :         self->op->asym->mlkem.decap.cipher.length = cipher_len;
    4045                 :          0 :         self->op->asym->mlkem.decap.sk.data = sk;
    4046                 :          0 :         self->op->asym->mlkem.decap.sk.length = 32;
    4047                 :            : 
    4048         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one(),
    4049                 :            :                 "Failed to process crypto op (ML-KEM Decap)");
    4050                 :            : 
    4051                 :          0 :         debug_hexdump(stdout, "Shared secret from decap",
    4052                 :          0 :                 self->result_op->asym->mlkem.decap.sk.data,
    4053                 :          0 :                 self->result_op->asym->mlkem.decap.sk.length);
    4054                 :            : 
    4055                 :            :         /* Verify the result with the test vector */
    4056         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(self->result_op->asym->mlkem.decap.sk.length, 32,
    4057                 :            :                 "Incorrect Shared secret length\n");
    4058         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(self->result_op->asym->mlkem.decap.sk.data,
    4059                 :            :                 skcopy, self->result_op->asym->mlkem.decap.sk.length,
    4060                 :            :                 "Incorrect Shared secret\n");
    4061                 :            : 
    4062                 :            :         /* Negative test */
    4063                 :          0 :         cipher[0] ^= 0x01;
    4064                 :            :         memset(sk, 0, sizeof(sk));
    4065                 :            : 
    4066                 :          0 :         self->op->asym->mlkem.op = RTE_CRYPTO_ML_KEM_OP_DECAP;
    4067                 :          0 :         self->op->asym->mlkem.decap.dk.data = vector->dk.data;
    4068                 :          0 :         self->op->asym->mlkem.decap.dk.length = vector->dk.length;
    4069                 :          0 :         self->op->asym->mlkem.decap.cipher.data = cipher;
    4070                 :          0 :         self->op->asym->mlkem.decap.cipher.length = cipher_len;
    4071                 :          0 :         self->op->asym->mlkem.decap.sk.data = sk;
    4072                 :          0 :         self->op->asym->mlkem.decap.sk.length = 32;
    4073                 :            : 
    4074         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one(),
    4075                 :            :                 "Failed to process crypto op (ML-KEM Decap)");
    4076                 :            : 
    4077                 :          0 :         debug_hexdump(stdout, "Shared secret from negative test",
    4078                 :          0 :                 self->result_op->asym->mlkem.decap.sk.data,
    4079                 :          0 :                 self->result_op->asym->mlkem.decap.sk.length);
    4080                 :            : 
    4081                 :            :         /* Verify the result with the test vector */
    4082         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(self->result_op->asym->mlkem.decap.sk.length, 32,
    4083                 :            :                 "Incorrect Shared secret length\n");
    4084                 :            : 
    4085         [ #  # ]:          0 :         if (!memcmp(self->result_op->asym->mlkem.decap.sk.data, skcopy, 32)) {
    4086                 :          0 :                 rte_cryptodev_asym_session_free(dev_id, self->sess);
    4087                 :          0 :                 return TEST_FAILED;
    4088                 :            :         }
    4089                 :            : 
    4090                 :          0 :         rte_cryptodev_asym_session_free(dev_id, self->sess);
    4091                 :          0 :         return TEST_SUCCESS;
    4092                 :            : }
    4093                 :            : 
    4094                 :            : static int
    4095                 :          0 : mlkem_decap(const void *test_data)
    4096                 :            : {
    4097                 :            :         const struct crypto_testsuite_mlkem_params *vector = test_data;
    4098                 :          0 :         const uint8_t dev_id = params->valid_devs[0];
    4099                 :          0 :         struct rte_crypto_asym_xform xform = {0};
    4100                 :          0 :         uint8_t cipher[TEST_DATA_SIZE] = {0};
    4101                 :          0 :         uint8_t sk[TEST_DATA_SIZE] = {0};
    4102                 :            :         size_t cipher_len;
    4103                 :            : 
    4104                 :          0 :         xform.mlkem.type = vector->type;
    4105                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ML_KEM;
    4106         [ #  # ]:          0 :         if (rte_cryptodev_asym_session_create(dev_id, &xform,
    4107                 :          0 :                         params->session_mpool, &self->sess) < 0) {
    4108                 :          0 :                 RTE_LOG(ERR, USER1, "line %u FAILED: Session creation failed",
    4109                 :            :                         __LINE__);
    4110                 :          0 :                 return TEST_FAILED;
    4111                 :            :         }
    4112                 :            : 
    4113         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(self->op, self->sess);
    4114                 :            : 
    4115                 :            :         /* Decapsulate and verify */
    4116                 :          0 :         self->op->asym->mlkem.op = RTE_CRYPTO_ML_KEM_OP_DECAP;
    4117                 :          0 :         self->op->asym->mlkem.decap.dk.data = vector->dk.data;
    4118                 :          0 :         self->op->asym->mlkem.decap.dk.length = vector->dk.length;
    4119                 :          0 :         self->op->asym->mlkem.decap.cipher.data = vector->cipher.data;
    4120                 :          0 :         self->op->asym->mlkem.decap.cipher.length = vector->cipher.length;
    4121                 :          0 :         self->op->asym->mlkem.decap.sk.data = sk;
    4122                 :          0 :         self->op->asym->mlkem.decap.sk.length = 32;
    4123                 :            : 
    4124         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one(),
    4125                 :            :                 "Failed to process crypto op (ML-KEM Decap)");
    4126                 :            : 
    4127                 :          0 :         debug_hexdump(stdout, "Shared secret from decap",
    4128                 :          0 :                 self->result_op->asym->mlkem.decap.sk.data,
    4129                 :          0 :                 self->result_op->asym->mlkem.decap.sk.length);
    4130                 :            : 
    4131                 :            :         /* Verify the result with the test vector */
    4132         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(self->result_op->asym->mlkem.decap.sk.length, 32,
    4133                 :            :                 "Incorrect Shared secret length\n");
    4134         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(self->result_op->asym->mlkem.decap.sk.data,
    4135                 :            :                 vector->sk.data, vector->sk.length,
    4136                 :            :                 "Incorrect Shared secret\n");
    4137                 :            : 
    4138                 :            :         /* Negative test */
    4139                 :          0 :         memcpy(cipher, vector->cipher.data, vector->cipher.length);
    4140                 :            :         cipher_len = vector->cipher.length;
    4141                 :          0 :         cipher[0] ^= 0x01;
    4142                 :            :         memset(sk, 0, sizeof(sk));
    4143                 :            : 
    4144                 :          0 :         self->op->asym->mlkem.op = RTE_CRYPTO_ML_KEM_OP_DECAP;
    4145                 :          0 :         self->op->asym->mlkem.decap.dk.data = vector->dk.data;
    4146                 :          0 :         self->op->asym->mlkem.decap.dk.length = vector->dk.length;
    4147                 :          0 :         self->op->asym->mlkem.decap.cipher.data = cipher;
    4148                 :          0 :         self->op->asym->mlkem.decap.cipher.length = cipher_len;
    4149                 :          0 :         self->op->asym->mlkem.decap.sk.data = sk;
    4150                 :          0 :         self->op->asym->mlkem.decap.sk.length = 32;
    4151                 :            : 
    4152         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one(),
    4153                 :            :                 "Failed to process crypto op (ML-KEM Decap)");
    4154                 :            : 
    4155                 :          0 :         debug_hexdump(stdout, "Shared secret from negative test",
    4156                 :          0 :                 self->result_op->asym->mlkem.decap.sk.data,
    4157                 :          0 :                 self->result_op->asym->mlkem.decap.sk.length);
    4158                 :            : 
    4159                 :            :         /* Verify the result with the test vector */
    4160         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(self->result_op->asym->mlkem.decap.sk.length, 32,
    4161                 :            :                 "Incorrect Shared secret length\n");
    4162                 :            : 
    4163                 :          0 :         if (!memcmp(self->result_op->asym->mlkem.decap.sk.data,
    4164         [ #  # ]:          0 :                 vector->sk.data, vector->sk.length)) {
    4165                 :          0 :                 rte_cryptodev_asym_session_free(dev_id, self->sess);
    4166                 :          0 :                 return TEST_FAILED;
    4167                 :            :         }
    4168                 :            : 
    4169                 :          0 :         rte_cryptodev_asym_session_free(dev_id, self->sess);
    4170                 :          0 :         return TEST_SUCCESS;
    4171                 :            : }
    4172                 :            : 
    4173                 :            : static int
    4174                 :          0 : mldsa_keygen(const void *test_data)
    4175                 :            : {
    4176                 :            :         const struct crypto_testsuite_mldsa_params *vector = test_data;
    4177                 :          0 :         const uint8_t dev_id = params->valid_devs[0];
    4178                 :          0 :         struct rte_crypto_asym_xform xform = {0};
    4179                 :          0 :         uint8_t privkey[TEST_DATA_SIZE] = {0};
    4180                 :          0 :         uint8_t pubkey[TEST_DATA_SIZE] = {0};
    4181                 :            : 
    4182                 :          0 :         xform.mldsa.type = vector->type;
    4183                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ML_DSA;
    4184         [ #  # ]:          0 :         if (rte_cryptodev_asym_session_create(dev_id, &xform,
    4185                 :          0 :                         params->session_mpool, &self->sess) < 0) {
    4186                 :          0 :                 RTE_LOG(ERR, USER1, "line %u FAILED: Session creation failed",
    4187                 :            :                         __LINE__);
    4188                 :          0 :                 return TEST_FAILED;
    4189                 :            :         }
    4190                 :            : 
    4191         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(self->op, self->sess);
    4192                 :          0 :         self->op->asym->mldsa.op = RTE_CRYPTO_ML_DSA_OP_KEYGEN;
    4193                 :          0 :         self->op->asym->mldsa.keygen.seed.data = vector->seed.data;
    4194                 :          0 :         self->op->asym->mldsa.keygen.seed.length = vector->seed.length;
    4195                 :          0 :         self->op->asym->mldsa.keygen.privkey.data = privkey;
    4196                 :          0 :         self->op->asym->mldsa.keygen.privkey.length = 0;
    4197                 :          0 :         self->op->asym->mldsa.keygen.pubkey.data = pubkey;
    4198                 :          0 :         self->op->asym->mldsa.keygen.pubkey.length = 0;
    4199         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one(),
    4200                 :            :                 "Failed to process crypto op (ML-DSA KeyGen)");
    4201                 :            : 
    4202                 :          0 :         debug_hexdump(stdout, "Private key",
    4203                 :          0 :                 self->result_op->asym->mldsa.keygen.privkey.data,
    4204                 :          0 :                 self->result_op->asym->mldsa.keygen.privkey.length);
    4205                 :          0 :         debug_hexdump(stdout, "Public key",
    4206                 :          0 :                 self->result_op->asym->mldsa.keygen.pubkey.data,
    4207                 :          0 :                 self->result_op->asym->mldsa.keygen.pubkey.length);
    4208                 :            : 
    4209                 :            :         /* Verify the result with the test vector */
    4210         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(self->result_op->asym->mldsa.keygen.privkey.length,
    4211                 :            :                 rte_crypto_ml_dsa_privkey_size[vector->type],
    4212                 :            :                 "Incorrect Private key length\n");
    4213         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(self->result_op->asym->mldsa.keygen.pubkey.length,
    4214                 :            :                 rte_crypto_ml_dsa_pubkey_size[vector->type],
    4215                 :            :                 "Incorrect Public key length\n");
    4216                 :            : 
    4217                 :            :         /* If the seed is all zero, keys are deterministic */
    4218                 :          0 :         if (memcmp(vector->seed.data, (uint8_t [32]) {0},
    4219         [ #  # ]:          0 :                         vector->seed.length) == 0) {
    4220         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->privkey.data,
    4221                 :            :                         self->result_op->asym->mldsa.keygen.privkey.data,
    4222                 :            :                         self->result_op->asym->mldsa.keygen.privkey.length,
    4223                 :            :                         "Incorrect Private key\n");
    4224         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->pubkey.data,
    4225                 :            :                         self->result_op->asym->mldsa.keygen.pubkey.data,
    4226                 :            :                         self->result_op->asym->mldsa.keygen.pubkey.length,
    4227                 :            :                         "Incorrect Public key\n");
    4228                 :          0 :                 RTE_LOG(DEBUG, USER1, "Deterministic keygen test passed\n");
    4229                 :            :         }
    4230                 :            : 
    4231                 :          0 :         rte_cryptodev_asym_session_free(dev_id, self->sess);
    4232                 :          0 :         return TEST_SUCCESS;
    4233                 :            : }
    4234                 :            : 
    4235                 :            : static int
    4236                 :          0 : mldsa_sign(const void *test_data)
    4237                 :            : {
    4238                 :            :         const struct crypto_testsuite_mldsa_params *vector = test_data;
    4239                 :          0 :         const uint8_t dev_id = params->valid_devs[0];
    4240                 :          0 :         struct rte_crypto_asym_xform xform = {0};
    4241                 :            :         struct rte_cryptodev_info dev_info;
    4242                 :          0 :         uint8_t sign[TEST_DATA_SIZE] = {0};
    4243                 :            :         size_t sign_len;
    4244                 :            : 
    4245                 :          0 :         xform.mldsa.type = vector->type;
    4246                 :          0 :         xform.mldsa.sign_deterministic = vector->sign_deterministic;
    4247                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ML_DSA;
    4248                 :            : 
    4249                 :          0 :         rte_cryptodev_info_get(dev_id, &dev_info);
    4250                 :            : 
    4251                 :            :         /* Check if prehash is supported */
    4252         [ #  # ]:          0 :         if (vector->hash) {
    4253         [ #  # ]:          0 :                 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MLDSA_SIGN_PREHASH)) {
    4254                 :          0 :                         RTE_LOG(DEBUG, USER1,
    4255                 :            :                                 "Device doesn't support prehash in ML-DSA signature generation. Test skipped\n");
    4256                 :          0 :                         return TEST_SKIPPED;
    4257                 :            :                 }
    4258                 :            :         }
    4259                 :            : 
    4260         [ #  # ]:          0 :         if (rte_cryptodev_asym_session_create(dev_id, &xform,
    4261                 :          0 :                         params->session_mpool, &self->sess) < 0) {
    4262                 :          0 :                 RTE_LOG(ERR, USER1, "line %u FAILED: Session creation failed",
    4263                 :            :                         __LINE__);
    4264                 :          0 :                 return TEST_FAILED;
    4265                 :            :         }
    4266                 :            : 
    4267         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(self->op, self->sess);
    4268                 :            : 
    4269                 :            :         /* Sign */
    4270                 :          0 :         self->op->asym->mldsa.op = RTE_CRYPTO_ML_DSA_OP_SIGN;
    4271                 :          0 :         self->op->asym->mldsa.siggen.seed.data = vector->seed.data;
    4272                 :          0 :         self->op->asym->mldsa.siggen.seed.length = vector->seed.length;
    4273                 :          0 :         self->op->asym->mldsa.siggen.privkey.data = vector->privkey.data;
    4274                 :          0 :         self->op->asym->mldsa.siggen.privkey.length = vector->privkey.length;
    4275                 :          0 :         self->op->asym->mldsa.siggen.message.data = vector->message.data;
    4276                 :          0 :         self->op->asym->mldsa.siggen.message.length = vector->message.length;
    4277                 :          0 :         self->op->asym->mldsa.siggen.ctx.data = vector->context.data;
    4278                 :          0 :         self->op->asym->mldsa.siggen.ctx.length = vector->context.length;
    4279                 :          0 :         self->op->asym->mldsa.siggen.mu.data = vector->mu.data;
    4280                 :          0 :         self->op->asym->mldsa.siggen.mu.length = vector->mu.length;
    4281                 :          0 :         self->op->asym->mldsa.siggen.sign.data = sign;
    4282                 :          0 :         self->op->asym->mldsa.siggen.sign.length =
    4283                 :          0 :                 rte_crypto_ml_dsa_sign_size[vector->type];
    4284                 :          0 :         self->op->asym->mldsa.siggen.hash = vector->hash;
    4285                 :            : 
    4286         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one(),
    4287                 :            :                 "Failed to process crypto op (ML-DSA Sign)");
    4288                 :            : 
    4289                 :          0 :         debug_hexdump(stdout, "Signature",
    4290                 :          0 :                 self->result_op->asym->mldsa.siggen.sign.data,
    4291                 :          0 :                 self->result_op->asym->mldsa.siggen.sign.length);
    4292                 :            : 
    4293                 :            :         /* Verify the result with the test vector */
    4294         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(self->result_op->asym->mldsa.siggen.sign.length,
    4295                 :            :                 rte_crypto_ml_dsa_sign_size[vector->type],
    4296                 :            :                 "Incorrect Signature length\n");
    4297                 :            : 
    4298                 :            :         /* Verify signature if it is deterministic */
    4299         [ #  # ]:          0 :         if (vector->sign_deterministic) {
    4300         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->sign.data,
    4301                 :            :                         self->result_op->asym->mldsa.siggen.sign.data,
    4302                 :            :                         self->result_op->asym->mldsa.siggen.sign.length,
    4303                 :            :                         "Incorrect Signature\n");
    4304                 :          0 :                 RTE_LOG(DEBUG, USER1, "Deterministic signature test passed\n");
    4305                 :            :         }
    4306                 :            : 
    4307                 :            :         /* Verify the signature */
    4308                 :          0 :         sign_len = self->result_op->asym->mldsa.siggen.sign.length;
    4309                 :            : 
    4310                 :          0 :         self->op->asym->mldsa.op = RTE_CRYPTO_ML_DSA_OP_VERIFY;
    4311                 :          0 :         self->op->asym->mldsa.sigver.message.data = vector->message.data;
    4312                 :          0 :         self->op->asym->mldsa.sigver.message.length = vector->message.length;
    4313                 :          0 :         self->op->asym->mldsa.sigver.ctx.data = vector->context.data;
    4314                 :          0 :         self->op->asym->mldsa.sigver.ctx.length = vector->context.length;
    4315                 :          0 :         self->op->asym->mldsa.sigver.mu.data = vector->mu.data;
    4316                 :          0 :         self->op->asym->mldsa.sigver.mu.length = vector->mu.length;
    4317                 :          0 :         self->op->asym->mldsa.sigver.pubkey.data = vector->pubkey.data;
    4318                 :          0 :         self->op->asym->mldsa.sigver.pubkey.length = vector->pubkey.length;
    4319                 :          0 :         self->op->asym->mldsa.sigver.sign.data = sign;
    4320                 :          0 :         self->op->asym->mldsa.sigver.sign.length = sign_len;
    4321                 :            : 
    4322         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one(),
    4323                 :            :                 "Failed to process crypto op (ML-DSA Verify)");
    4324                 :            : 
    4325                 :            :         /* Verify the result */
    4326         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(self->result_op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    4327                 :            :                 "Failed to verify the signature");
    4328                 :            : 
    4329                 :            :         /* Negative test */
    4330                 :          0 :         sign[0] ^= 0x01;
    4331                 :            : 
    4332                 :          0 :         self->op->asym->mldsa.op = RTE_CRYPTO_ML_DSA_OP_VERIFY;
    4333                 :          0 :         self->op->asym->mldsa.sigver.message.data = vector->message.data;
    4334                 :          0 :         self->op->asym->mldsa.sigver.message.length = vector->message.length;
    4335                 :          0 :         self->op->asym->mldsa.sigver.ctx.data = vector->context.data;
    4336                 :          0 :         self->op->asym->mldsa.sigver.ctx.length = vector->context.length;
    4337                 :          0 :         self->op->asym->mldsa.sigver.mu.data = vector->mu.data;
    4338                 :          0 :         self->op->asym->mldsa.sigver.mu.length = vector->mu.length;
    4339                 :          0 :         self->op->asym->mldsa.sigver.pubkey.data = vector->pubkey.data;
    4340                 :          0 :         self->op->asym->mldsa.sigver.pubkey.length = vector->pubkey.length;
    4341                 :          0 :         self->op->asym->mldsa.sigver.sign.data = sign;
    4342                 :          0 :         self->op->asym->mldsa.sigver.sign.length = sign_len;
    4343                 :            : 
    4344         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one_no_status_check(),
    4345                 :            :                 "Failed to process crypto op (ML-DSA Verify)");
    4346                 :            : 
    4347                 :            :         /* Verify the result */
    4348         [ #  # ]:          0 :         if (self->result_op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
    4349                 :          0 :                 rte_cryptodev_asym_session_free(dev_id, self->sess);
    4350                 :          0 :                 return TEST_FAILED;
    4351                 :            :         }
    4352                 :            : 
    4353                 :          0 :         rte_cryptodev_asym_session_free(dev_id, self->sess);
    4354                 :          0 :         return TEST_SUCCESS;
    4355                 :            : }
    4356                 :            : 
    4357                 :            : static int
    4358                 :          0 : mldsa_verify(const void *test_data)
    4359                 :            : {
    4360                 :            :         const struct crypto_testsuite_mldsa_params *vector = test_data;
    4361                 :          0 :         const uint8_t dev_id = params->valid_devs[0];
    4362                 :          0 :         struct rte_crypto_asym_xform xform = {0};
    4363                 :          0 :         uint8_t sign[TEST_DATA_SIZE] = {0};
    4364                 :            :         size_t sign_len;
    4365                 :            : 
    4366                 :          0 :         xform.mldsa.type = vector->type;
    4367                 :          0 :         xform.mldsa.sign_deterministic = vector->sign_deterministic;
    4368                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ML_DSA;
    4369         [ #  # ]:          0 :         if (rte_cryptodev_asym_session_create(dev_id, &xform,
    4370                 :          0 :                         params->session_mpool, &self->sess) < 0) {
    4371                 :          0 :                 RTE_LOG(ERR, USER1, "line %u FAILED: Session creation failed",
    4372                 :            :                         __LINE__);
    4373                 :          0 :                 return TEST_FAILED;
    4374                 :            :         }
    4375                 :            : 
    4376         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(self->op, self->sess);
    4377                 :            : 
    4378                 :            :         /* Verify the signature */
    4379                 :          0 :         self->op->asym->mldsa.op = RTE_CRYPTO_ML_DSA_OP_VERIFY;
    4380                 :          0 :         self->op->asym->mldsa.sigver.message.data = vector->message.data;
    4381                 :          0 :         self->op->asym->mldsa.sigver.message.length = vector->message.length;
    4382                 :          0 :         self->op->asym->mldsa.sigver.ctx.data = vector->context.data;
    4383                 :          0 :         self->op->asym->mldsa.sigver.ctx.length = vector->context.length;
    4384                 :          0 :         self->op->asym->mldsa.sigver.mu.data = vector->mu.data;
    4385                 :          0 :         self->op->asym->mldsa.sigver.mu.length = vector->mu.length;
    4386                 :          0 :         self->op->asym->mldsa.sigver.pubkey.data = vector->pubkey.data;
    4387                 :          0 :         self->op->asym->mldsa.sigver.pubkey.length = vector->pubkey.length;
    4388                 :          0 :         self->op->asym->mldsa.sigver.sign.data = vector->sign.data;
    4389                 :          0 :         self->op->asym->mldsa.sigver.sign.length = vector->sign.length;
    4390                 :            : 
    4391         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one(),
    4392                 :            :                 "Failed to process crypto op (ML-DSA Verify)");
    4393                 :            : 
    4394                 :            :         /* Verify the result */
    4395         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(self->result_op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    4396                 :            :                 "Failed to verify the signature");
    4397                 :            : 
    4398                 :            :         /* Negative test */
    4399                 :          0 :         memcpy(sign, vector->sign.data, vector->sign.length);
    4400                 :            :         sign_len = vector->sign.length;
    4401                 :          0 :         sign[0] ^= 0x01;
    4402                 :            : 
    4403                 :          0 :         self->op->asym->mldsa.op = RTE_CRYPTO_ML_DSA_OP_VERIFY;
    4404                 :          0 :         self->op->asym->mldsa.sigver.message.data = vector->message.data;
    4405                 :          0 :         self->op->asym->mldsa.sigver.message.length = vector->message.length;
    4406                 :          0 :         self->op->asym->mldsa.sigver.ctx.data = vector->context.data;
    4407                 :          0 :         self->op->asym->mldsa.sigver.ctx.length = vector->context.length;
    4408                 :          0 :         self->op->asym->mldsa.sigver.mu.data = vector->mu.data;
    4409                 :          0 :         self->op->asym->mldsa.sigver.mu.length = vector->mu.length;
    4410                 :          0 :         self->op->asym->mldsa.sigver.pubkey.data = vector->pubkey.data;
    4411                 :          0 :         self->op->asym->mldsa.sigver.pubkey.length = vector->pubkey.length;
    4412                 :          0 :         self->op->asym->mldsa.sigver.sign.data = sign;
    4413                 :          0 :         self->op->asym->mldsa.sigver.sign.length = sign_len;
    4414                 :            : 
    4415         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one_no_status_check(),
    4416                 :            :                 "Failed to process crypto op (ML-DSA Verify)");
    4417                 :            : 
    4418                 :            :         /* Verify the result */
    4419         [ #  # ]:          0 :         if (self->result_op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
    4420                 :          0 :                 rte_cryptodev_asym_session_free(dev_id, self->sess);
    4421                 :          0 :                 return TEST_FAILED;
    4422                 :            :         }
    4423                 :            : 
    4424                 :          0 :         rte_cryptodev_asym_session_free(dev_id, self->sess);
    4425                 :          0 :         return TEST_SUCCESS;
    4426                 :            : }
    4427                 :            : 
    4428                 :            : static int
    4429                 :          0 : test_mlkem_keygen(void)
    4430                 :            : {
    4431                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    4432                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    4433                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    4434                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
    4435                 :            :         int overall_status = TEST_SUCCESS;
    4436                 :            :         int ret;
    4437                 :            : 
    4438                 :            :         /* Check if ML-KEM is supported */
    4439                 :          0 :         idx.type = RTE_CRYPTO_ASYM_XFORM_ML_KEM;
    4440                 :          0 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    4441         [ #  # ]:          0 :         if (capa == NULL) {
    4442                 :          0 :                 RTE_LOG(DEBUG, USER1,
    4443                 :            :                         "Device doesn't support ML-KEM. Test skipped\n");
    4444                 :          0 :                 return TEST_SKIPPED;
    4445                 :            :         }
    4446                 :            : 
    4447         [ #  # ]:          0 :         if (!(capa->op_types & (1 <<  RTE_CRYPTO_ML_KEM_OP_KEYGEN))) {
    4448                 :          0 :                 RTE_LOG(DEBUG, USER1,
    4449                 :            :                         "Device doesn't support ML-KEM keygen operation. Test skipped\n");
    4450                 :          0 :                 return TEST_SKIPPED;
    4451                 :            :         }
    4452                 :            : 
    4453         [ #  # ]:          0 :         for (uint8_t i = 0; i < RTE_DIM(mlkem_keygen_test_vectors); i++) {
    4454                 :          0 :                 if (!(capa->mlkem_capa[RTE_CRYPTO_ML_KEM_OP_KEYGEN] &
    4455         [ #  # ]:          0 :                         (1 << mlkem_keygen_test_vectors[i].type))) {
    4456                 :          0 :                         RTE_LOG(DEBUG, USER1,
    4457                 :            :                                 "Device doesn't support ML-KEM param %u. TestCase %s skipped\n",
    4458                 :            :                                 mlkem_keygen_test_vectors[i].type,
    4459                 :            :                                 mlkem_keygen_test_vectors[i].name);
    4460                 :          0 :                         printf("  %u) TestCase %s: skipped\n", i,
    4461                 :            :                                 mlkem_keygen_test_vectors[i].name);
    4462                 :          0 :                         continue;
    4463                 :            :                 }
    4464                 :          0 :                 ret = mlkem_keygen(&mlkem_keygen_test_vectors[i]);
    4465         [ #  # ]:          0 :                 if (ret == TEST_SUCCESS || ret == TEST_SKIPPED) {
    4466         [ #  # ]:          0 :                         printf("  %u) TestCase %s: %s\n", i, mlkem_keygen_test_vectors[i].name,
    4467                 :            :                                 (ret == TEST_SKIPPED) ? "skipped" : "passed");
    4468                 :          0 :                                 continue;
    4469                 :            :                 }
    4470                 :            : 
    4471                 :          0 :                 printf("  %u) TestCase %s: failed\n", i, mlkem_keygen_test_vectors[i].name);
    4472                 :            :                 overall_status = TEST_FAILED;
    4473                 :            :         }
    4474                 :            : 
    4475                 :            :         return overall_status;
    4476                 :            : }
    4477                 :            : 
    4478                 :            : static int
    4479                 :          0 : test_mlkem_encap(void)
    4480                 :            : {
    4481                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    4482                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    4483                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    4484                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
    4485                 :            :         int overall_status = TEST_SUCCESS;
    4486                 :            :         int ret;
    4487                 :            : 
    4488                 :            :         /* Check if ML-KEM is supported */
    4489                 :          0 :         idx.type = RTE_CRYPTO_ASYM_XFORM_ML_KEM;
    4490                 :          0 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    4491         [ #  # ]:          0 :         if (capa == NULL) {
    4492                 :          0 :                 RTE_LOG(DEBUG, USER1,
    4493                 :            :                         "Device doesn't support ML-KEM. Test skipped\n");
    4494                 :          0 :                 return TEST_SKIPPED;
    4495                 :            :         }
    4496                 :            : 
    4497         [ #  # ]:          0 :         if (!(capa->op_types & (1 <<  RTE_CRYPTO_ML_KEM_OP_ENCAP))) {
    4498                 :          0 :                 RTE_LOG(DEBUG, USER1,
    4499                 :            :                         "Device doesn't support ML-KEM encap operation. Test skipped\n");
    4500                 :          0 :                 return TEST_SKIPPED;
    4501                 :            :         }
    4502                 :            : 
    4503         [ #  # ]:          0 :         for (uint8_t i = 0; i < RTE_DIM(mlkem_encap_test_vectors); i++) {
    4504                 :          0 :                 if (!(capa->mlkem_capa[RTE_CRYPTO_ML_KEM_OP_ENCAP] &
    4505         [ #  # ]:          0 :                         (1 << mlkem_encap_test_vectors[i].type))) {
    4506                 :          0 :                         RTE_LOG(DEBUG, USER1,
    4507                 :            :                                 "Device doesn't support ML-KEM param %u. TestCase %s skipped\n",
    4508                 :            :                                 mlkem_encap_test_vectors[i].type,
    4509                 :            :                                 mlkem_encap_test_vectors[i].name);
    4510                 :          0 :                         printf("  %u) TestCase %s: skipped\n", i,
    4511                 :            :                                 mlkem_encap_test_vectors[i].name);
    4512                 :          0 :                         continue;
    4513                 :            :                 }
    4514                 :          0 :                 ret = mlkem_encap(&mlkem_encap_test_vectors[i]);
    4515         [ #  # ]:          0 :                 if (ret == TEST_SUCCESS || ret == TEST_SKIPPED) {
    4516         [ #  # ]:          0 :                         printf("  %u) TestCase %s: %s\n", i, mlkem_encap_test_vectors[i].name,
    4517                 :            :                                 (ret == TEST_SKIPPED) ? "skipped" : "passed");
    4518                 :          0 :                                 continue;
    4519                 :            :                 }
    4520                 :            : 
    4521                 :          0 :                 printf("  %u) TestCase %s: failed\n", i, mlkem_encap_test_vectors[i].name);
    4522                 :            :                 overall_status = TEST_FAILED;
    4523                 :            :         }
    4524                 :            : 
    4525                 :            :         return overall_status;
    4526                 :            : }
    4527                 :            : 
    4528                 :            : static int
    4529                 :          0 : test_mlkem_decap(void)
    4530                 :            : {
    4531                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    4532                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    4533                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    4534                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
    4535                 :            :         int overall_status = TEST_SUCCESS;
    4536                 :            :         int ret;
    4537                 :            : 
    4538                 :            :         /* Check if ML-KEM is supported */
    4539                 :          0 :         idx.type = RTE_CRYPTO_ASYM_XFORM_ML_KEM;
    4540                 :          0 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    4541         [ #  # ]:          0 :         if (capa == NULL) {
    4542                 :          0 :                 RTE_LOG(DEBUG, USER1,
    4543                 :            :                         "Device doesn't support ML-KEM. Test skipped\n");
    4544                 :          0 :                 return TEST_SKIPPED;
    4545                 :            :         }
    4546                 :            : 
    4547         [ #  # ]:          0 :         if (!(capa->op_types & (1 <<  RTE_CRYPTO_ML_KEM_OP_DECAP))) {
    4548                 :          0 :                 RTE_LOG(DEBUG, USER1,
    4549                 :            :                         "Device doesn't support ML-KEM decap operation. Test skipped\n");
    4550                 :          0 :                 return TEST_SKIPPED;
    4551                 :            :         }
    4552                 :            : 
    4553         [ #  # ]:          0 :         for (uint8_t i = 0; i < RTE_DIM(mlkem_decap_test_vectors); i++) {
    4554                 :          0 :                 if (!(capa->mlkem_capa[RTE_CRYPTO_ML_KEM_OP_DECAP] &
    4555         [ #  # ]:          0 :                         (1 << mlkem_decap_test_vectors[i].type))) {
    4556                 :          0 :                         RTE_LOG(DEBUG, USER1,
    4557                 :            :                                 "Device doesn't support ML-KEM param %u. TestCase %s skipped\n",
    4558                 :            :                                 mlkem_decap_test_vectors[i].type,
    4559                 :            :                                 mlkem_decap_test_vectors[i].name);
    4560                 :          0 :                         printf("  %u) TestCase %s: skipped\n", i,
    4561                 :            :                                 mlkem_decap_test_vectors[i].name);
    4562                 :          0 :                         continue;
    4563                 :            :                 }
    4564                 :          0 :                 ret = mlkem_decap(&mlkem_decap_test_vectors[i]);
    4565         [ #  # ]:          0 :                 if (ret == TEST_SUCCESS || ret == TEST_SKIPPED) {
    4566         [ #  # ]:          0 :                         printf("  %u) TestCase %s: %s\n", i, mlkem_decap_test_vectors[i].name,
    4567                 :            :                                 (ret == TEST_SKIPPED) ? "skipped" : "passed");
    4568                 :          0 :                                 continue;
    4569                 :            :                 }
    4570                 :            : 
    4571                 :          0 :                 printf("  %u) TestCase %s: failed\n", i, mlkem_decap_test_vectors[i].name);
    4572                 :            :                 overall_status = TEST_FAILED;
    4573                 :            :         }
    4574                 :            : 
    4575                 :            :         return overall_status;
    4576                 :            : }
    4577                 :            : 
    4578                 :            : static int
    4579                 :          0 : test_mldsa_keygen(void)
    4580                 :            : {
    4581                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    4582                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    4583                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    4584                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
    4585                 :            :         int overall_status = TEST_SUCCESS;
    4586                 :            :         int ret;
    4587                 :            : 
    4588                 :            :         /* Check if ML-DSA is supported */
    4589                 :          0 :         idx.type = RTE_CRYPTO_ASYM_XFORM_ML_DSA;
    4590                 :          0 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    4591         [ #  # ]:          0 :         if (capa == NULL) {
    4592                 :          0 :                 RTE_LOG(DEBUG, USER1,
    4593                 :            :                         "Device doesn't support ML-DSA. Test skipped\n");
    4594                 :          0 :                 return TEST_SKIPPED;
    4595                 :            :         }
    4596                 :            : 
    4597         [ #  # ]:          0 :         if (!(capa->op_types & (1 <<  RTE_CRYPTO_ML_DSA_OP_KEYGEN))) {
    4598                 :          0 :                 RTE_LOG(DEBUG, USER1,
    4599                 :            :                         "Device doesn't support ML-DSA keygen operation. Test skipped\n");
    4600                 :          0 :                 return TEST_SKIPPED;
    4601                 :            :         }
    4602                 :            : 
    4603         [ #  # ]:          0 :         for (uint8_t i = 0; i < RTE_DIM(mldsa_keygen_test_vectors); i++) {
    4604                 :          0 :                 if (!(capa->mldsa_capa[RTE_CRYPTO_ML_DSA_OP_KEYGEN] &
    4605         [ #  # ]:          0 :                         (1 << mldsa_keygen_test_vectors[i].type))) {
    4606                 :          0 :                         RTE_LOG(DEBUG, USER1,
    4607                 :            :                                 "Device doesn't support ML-DSA param %u. TestCase %s skipped\n",
    4608                 :            :                                 mldsa_keygen_test_vectors[i].type,
    4609                 :            :                                 mldsa_keygen_test_vectors[i].name);
    4610                 :          0 :                         printf("  %u) TestCase %s: skipped\n", i,
    4611                 :            :                                 mldsa_keygen_test_vectors[i].name);
    4612                 :          0 :                         continue;
    4613                 :            :                 }
    4614                 :          0 :                 ret = mldsa_keygen(&mldsa_keygen_test_vectors[i]);
    4615         [ #  # ]:          0 :                 if (ret == TEST_SUCCESS || ret == TEST_SKIPPED) {
    4616         [ #  # ]:          0 :                         printf("  %u) TestCase %s: %s\n", i, mldsa_keygen_test_vectors[i].name,
    4617                 :            :                                 (ret == TEST_SKIPPED) ? "skipped" : "passed");
    4618                 :          0 :                                 continue;
    4619                 :            :                 }
    4620                 :            : 
    4621                 :          0 :                 printf("  %u) TestCase %s: failed\n", i, mldsa_keygen_test_vectors[i].name);
    4622                 :            :                 overall_status = TEST_FAILED;
    4623                 :            :         }
    4624                 :            : 
    4625                 :            :         return overall_status;
    4626                 :            : }
    4627                 :            : 
    4628                 :            : static int
    4629                 :          0 : test_mldsa_sign(void)
    4630                 :            : {
    4631                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    4632                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    4633                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    4634                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
    4635                 :            :         int overall_status = TEST_SUCCESS;
    4636                 :            :         int ret;
    4637                 :            : 
    4638                 :            :         /* Check if ML-DSA is supported */
    4639                 :          0 :         idx.type = RTE_CRYPTO_ASYM_XFORM_ML_DSA;
    4640                 :          0 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    4641         [ #  # ]:          0 :         if (capa == NULL) {
    4642                 :          0 :                 RTE_LOG(DEBUG, USER1,
    4643                 :            :                         "Device doesn't support ML-DSA. Test skipped\n");
    4644                 :          0 :                 return TEST_SKIPPED;
    4645                 :            :         }
    4646                 :            : 
    4647         [ #  # ]:          0 :         if (!(capa->op_types & (1 <<  RTE_CRYPTO_ML_DSA_OP_SIGN))) {
    4648                 :          0 :                 RTE_LOG(DEBUG, USER1,
    4649                 :            :                         "Device doesn't support ML-DSA sign operation. Test skipped\n");
    4650                 :          0 :                 return TEST_SKIPPED;
    4651                 :            :         }
    4652                 :            : 
    4653         [ #  # ]:          0 :         for (uint8_t i = 0; i < RTE_DIM(mldsa_sign_test_vectors); i++) {
    4654                 :          0 :                 if (!(capa->mldsa_capa[RTE_CRYPTO_ML_DSA_OP_SIGN] &
    4655         [ #  # ]:          0 :                         (1 << mldsa_sign_test_vectors[i].type))) {
    4656                 :          0 :                         RTE_LOG(DEBUG, USER1,
    4657                 :            :                                 "Device doesn't support ML-DSA param %u. TestCase %s skipped\n",
    4658                 :            :                                 mldsa_sign_test_vectors[i].type,
    4659                 :            :                                 mldsa_sign_test_vectors[i].name);
    4660                 :          0 :                         printf("  %u) TestCase %s: skipped\n", i,
    4661                 :            :                                 mldsa_sign_test_vectors[i].name);
    4662                 :          0 :                         continue;
    4663                 :            :                 }
    4664                 :          0 :                 ret = mldsa_sign(&mldsa_sign_test_vectors[i]);
    4665         [ #  # ]:          0 :                 if (ret == TEST_SUCCESS || ret == TEST_SKIPPED) {
    4666         [ #  # ]:          0 :                         printf("  %u) TestCase %s: %s\n", i, mldsa_sign_test_vectors[i].name,
    4667                 :            :                                 (ret == TEST_SKIPPED) ? "skipped" : "passed");
    4668                 :          0 :                                 continue;
    4669                 :            :                 }
    4670                 :            : 
    4671                 :          0 :                 printf("  %u) TestCase %s: failed\n", i, mldsa_sign_test_vectors[i].name);
    4672                 :            :                 overall_status = TEST_FAILED;
    4673                 :            :         }
    4674                 :            : 
    4675                 :            :         return overall_status;
    4676                 :            : }
    4677                 :            : 
    4678                 :            : static int
    4679                 :          0 : test_mldsa_verify(void)
    4680                 :            : {
    4681                 :            :         struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
    4682                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    4683                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    4684                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
    4685                 :            :         int overall_status = TEST_SUCCESS;
    4686                 :            :         int ret;
    4687                 :            : 
    4688                 :            :         /* Check if ML-DSA is supported */
    4689                 :          0 :         idx.type = RTE_CRYPTO_ASYM_XFORM_ML_DSA;
    4690                 :          0 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    4691         [ #  # ]:          0 :         if (capa == NULL) {
    4692                 :          0 :                 RTE_LOG(DEBUG, USER1,
    4693                 :            :                         "Device doesn't support ML-DSA. Test skipped\n");
    4694                 :          0 :                 return TEST_SKIPPED;
    4695                 :            :         }
    4696                 :            : 
    4697         [ #  # ]:          0 :         if (!(capa->op_types & (1 <<  RTE_CRYPTO_ML_DSA_OP_VERIFY))) {
    4698                 :          0 :                 RTE_LOG(DEBUG, USER1,
    4699                 :            :                         "Device doesn't support ML-DSA verify operation. Test skipped\n");
    4700                 :          0 :                 return TEST_SKIPPED;
    4701                 :            :         }
    4702                 :            : 
    4703         [ #  # ]:          0 :         for (uint8_t i = 0; i < RTE_DIM(mldsa_verify_test_vectors); i++) {
    4704                 :          0 :                 if (!(capa->mldsa_capa[RTE_CRYPTO_ML_DSA_OP_VERIFY] &
    4705         [ #  # ]:          0 :                         (1 << mldsa_verify_test_vectors[i].type))) {
    4706                 :          0 :                         RTE_LOG(DEBUG, USER1,
    4707                 :            :                                 "Device doesn't support ML-DSA param %u. TestCase %s skipped\n",
    4708                 :            :                                 mldsa_verify_test_vectors[i].type,
    4709                 :            :                                 mldsa_verify_test_vectors[i].name);
    4710                 :          0 :                         printf("  %u) TestCase %s: skipped\n", i,
    4711                 :            :                                 mldsa_verify_test_vectors[i].name);
    4712                 :          0 :                         continue;
    4713                 :            :                 }
    4714                 :          0 :                 ret = mldsa_verify(&mldsa_verify_test_vectors[i]);
    4715         [ #  # ]:          0 :                 if (ret == TEST_SUCCESS || ret == TEST_SKIPPED) {
    4716         [ #  # ]:          0 :                         printf("  %u) TestCase %s: %s\n", i, mldsa_verify_test_vectors[i].name,
    4717                 :            :                                 (ret == TEST_SKIPPED) ? "skipped" : "passed");
    4718                 :          0 :                                 continue;
    4719                 :            :                 }
    4720                 :            : 
    4721                 :          0 :                 printf("  %u) TestCase %s: failed\n", i, mldsa_verify_test_vectors[i].name);
    4722                 :            :                 overall_status = TEST_FAILED;
    4723                 :            :         }
    4724                 :            : 
    4725                 :            :         return overall_status;
    4726                 :            : }
    4727                 :            : 
    4728                 :            : #define SET_RSA_PARAM(arg, vector, coef) \
    4729                 :            :         uint8_t coef[TEST_DATA_SIZE] = { }; \
    4730                 :            :         memcpy(coef, vector->coef.data, vector->coef.len); \
    4731                 :            :         arg.coef.data = coef; \
    4732                 :            :         arg.coef.length = vector->coef.len
    4733                 :            : 
    4734                 :            : #define SET_RSA_PARAM_QT(arg, vector, coef) \
    4735                 :            :         uint8_t coef[TEST_DATA_SIZE] = { }; \
    4736                 :            :         memcpy(coef, vector->coef.data, vector->coef.len); \
    4737                 :            :         arg.qt.coef.data = coef; \
    4738                 :            :         arg.qt.coef.length = vector->coef.len
    4739                 :            : 
    4740                 :            : static int
    4741                 :          2 : rsa_encrypt(const struct rsa_test_data_2 *vector, uint8_t *cipher_buf)
    4742                 :            : {
    4743                 :          2 :         self->result_op = NULL;
    4744                 :            :         /* Compute encryption on the test vector */
    4745                 :          2 :         self->op->asym->rsa.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
    4746                 :          2 :         self->op->asym->rsa.cipher.data = cipher_buf;
    4747                 :          2 :         self->op->asym->rsa.cipher.length = 0;
    4748         [ +  - ]:          2 :         SET_RSA_PARAM(self->op->asym->rsa, vector, message);
    4749                 :            : 
    4750         [ +  - ]:          2 :         rte_crypto_op_attach_asym_session(self->op, self->sess);
    4751         [ -  + ]:          2 :         TEST_ASSERT_SUCCESS(send_one(),
    4752                 :            :                 "Failed to process crypto op (Enryption)");
    4753                 :            : 
    4754                 :            :         return 0;
    4755                 :            : }
    4756                 :            : 
    4757                 :            : static int
    4758                 :          2 : rsa_decrypt(const struct rsa_test_data_2 *vector, uint8_t *plaintext,
    4759                 :            :                 const int use_op)
    4760                 :            : {
    4761                 :          2 :         uint8_t cipher[TEST_DATA_SIZE] = { 0 };
    4762                 :            : 
    4763         [ +  - ]:          2 :         if (use_op == 0) {
    4764                 :          2 :                 memcpy(cipher, vector->cipher.data, vector->cipher.len);
    4765                 :          2 :                 self->op->asym->rsa.cipher.data = cipher;
    4766                 :          2 :                 self->op->asym->rsa.cipher.length = vector->cipher.len;
    4767                 :            :         }
    4768                 :          2 :         self->result_op = NULL;
    4769                 :          2 :         self->op->asym->rsa.message.data = plaintext;
    4770                 :          2 :         self->op->asym->rsa.message.length = 0;
    4771                 :          2 :         self->op->asym->rsa.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
    4772         [ +  - ]:          2 :         rte_crypto_op_attach_asym_session(self->op, self->sess);
    4773         [ -  + ]:          2 :         TEST_ASSERT_SUCCESS(send_one(),
    4774                 :            :                 "Failed to process crypto op (Decryption)");
    4775                 :            :         return 0;
    4776                 :            : }
    4777                 :            : 
    4778                 :            : static int
    4779                 :          4 : rsa_init_session(struct rte_crypto_asym_xform *xform)
    4780                 :            : {
    4781                 :          4 :         const uint8_t dev_id = params->valid_devs[0];
    4782                 :            :         struct rte_cryptodev_info dev_info;
    4783                 :            :         int ret = 0;
    4784                 :            : 
    4785                 :          4 :         xform->xform_type = RTE_CRYPTO_ASYM_XFORM_RSA;
    4786                 :            : 
    4787                 :          4 :         rte_cryptodev_info_get(dev_id, &dev_info);
    4788         [ -  + ]:          4 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
    4789                 :          0 :                 RTE_LOG(INFO, USER1,
    4790                 :            :                         "Device doesn't support decrypt op with quintuple key type. Test skipped\n");
    4791                 :          0 :                 return TEST_SKIPPED;
    4792                 :            :         }
    4793                 :          4 :         ret = rte_cryptodev_asym_session_create(dev_id, xform,
    4794                 :          4 :                 params->session_mpool, &self->sess);
    4795         [ -  + ]:          4 :         if (ret < 0) {
    4796                 :          0 :                 RTE_LOG(ERR, USER1,
    4797                 :            :                         "Session creation failed for enc_dec_crt\n");
    4798         [ #  # ]:          0 :                 return (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
    4799                 :            :         }
    4800                 :            :         return 0;
    4801                 :            : }
    4802                 :            : 
    4803                 :            : static int
    4804                 :          1 : kat_rsa_encrypt(const void *data)
    4805                 :            : {
    4806                 :          1 :         uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
    4807                 :            :         const struct rsa_test_data_2 *vector = data;
    4808                 :          1 :         struct rte_crypto_asym_xform xform = { };
    4809                 :            : 
    4810                 :          1 :         SET_RSA_PARAM(xform.rsa, vector, n);
    4811                 :          1 :         SET_RSA_PARAM(xform.rsa, vector, e);
    4812                 :          1 :         SET_RSA_PARAM(xform.rsa, vector, d);
    4813                 :          1 :         xform.rsa.padding.type = vector->padding;
    4814                 :            :         xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
    4815                 :          1 :         int ret = rsa_init_session(&xform);
    4816                 :            : 
    4817         [ -  + ]:          1 :         if (ret) {
    4818                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
    4819                 :          0 :                 return ret;
    4820                 :            :         }
    4821         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rsa_encrypt(vector, cipher_buf),
    4822                 :            :                 "RSA: Failed to encrypt");
    4823         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->cipher.data,
    4824                 :            :                 self->result_op->asym->rsa.cipher.data,
    4825                 :            :                 self->result_op->asym->rsa.cipher.length,
    4826                 :            :                 "operation verification failed\n");
    4827                 :            :         return 0;
    4828                 :            : }
    4829                 :            : 
    4830                 :            : static int
    4831                 :          1 : kat_rsa_encrypt_crt(const void *data)
    4832                 :            : {
    4833                 :          1 :         uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
    4834                 :            :         const struct rsa_test_data_2 *vector = data;
    4835                 :          1 :         struct rte_crypto_asym_xform xform = { };
    4836                 :            : 
    4837                 :          1 :         SET_RSA_PARAM(xform.rsa, vector, n);
    4838                 :          1 :         SET_RSA_PARAM(xform.rsa, vector, e);
    4839                 :          1 :         SET_RSA_PARAM_QT(xform.rsa, vector, p);
    4840                 :          1 :         SET_RSA_PARAM_QT(xform.rsa, vector, q);
    4841                 :          1 :         SET_RSA_PARAM_QT(xform.rsa, vector, dP);
    4842                 :          1 :         SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
    4843                 :          1 :         SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
    4844                 :          1 :         xform.rsa.padding.type = vector->padding;
    4845                 :          1 :         xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
    4846                 :          1 :         int ret = rsa_init_session(&xform);
    4847         [ -  + ]:          1 :         if (ret) {
    4848                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
    4849                 :          0 :                 return ret;
    4850                 :            :         }
    4851         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rsa_encrypt(vector, cipher_buf),
    4852                 :            :                 "RSA: Failed to encrypt");
    4853         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->cipher.data,
    4854                 :            :                 self->result_op->asym->rsa.cipher.data,
    4855                 :            :                 self->result_op->asym->rsa.cipher.length,
    4856                 :            :                 "operation verification failed\n");
    4857                 :            :         return 0;
    4858                 :            : }
    4859                 :            : 
    4860                 :            : static int
    4861                 :          1 : kat_rsa_decrypt(const void *data)
    4862                 :            : {
    4863                 :          1 :         uint8_t message[TEST_DATA_SIZE] = {0};
    4864                 :            :         const struct rsa_test_data_2 *vector = data;
    4865                 :          1 :         struct rte_crypto_asym_xform xform = { };
    4866                 :            : 
    4867                 :          1 :         SET_RSA_PARAM(xform.rsa, vector, n);
    4868                 :          1 :         SET_RSA_PARAM(xform.rsa, vector, e);
    4869                 :          1 :         SET_RSA_PARAM(xform.rsa, vector, d);
    4870                 :          1 :         xform.rsa.padding.type = vector->padding;
    4871                 :            :         xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
    4872                 :          1 :         int ret = rsa_init_session(&xform);
    4873                 :            : 
    4874         [ -  + ]:          1 :         if (ret) {
    4875                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
    4876                 :          0 :                 return ret;
    4877                 :            :         }
    4878         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rsa_decrypt(vector, message, 0),
    4879                 :            :                 "RSA: Failed to encrypt");
    4880         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->message.data,
    4881                 :            :                 self->result_op->asym->rsa.message.data,
    4882                 :            :                 self->result_op->asym->rsa.message.length,
    4883                 :            :                 "operation verification failed\n");
    4884                 :            :         return 0;
    4885                 :            : }
    4886                 :            : 
    4887                 :            : static int
    4888                 :          1 : kat_rsa_decrypt_crt(const void *data)
    4889                 :            : {
    4890                 :          1 :         uint8_t message[TEST_DATA_SIZE] = {0};
    4891                 :            :         const struct rsa_test_data_2 *vector = data;
    4892                 :          1 :         struct rte_crypto_asym_xform xform = { };
    4893                 :            : 
    4894                 :          1 :         SET_RSA_PARAM(xform.rsa, vector, n);
    4895                 :          1 :         SET_RSA_PARAM(xform.rsa, vector, e);
    4896                 :          1 :         SET_RSA_PARAM_QT(xform.rsa, vector, p);
    4897                 :          1 :         SET_RSA_PARAM_QT(xform.rsa, vector, q);
    4898                 :          1 :         SET_RSA_PARAM_QT(xform.rsa, vector, dP);
    4899                 :          1 :         SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
    4900                 :          1 :         SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
    4901                 :          1 :         xform.rsa.padding.type = vector->padding;
    4902                 :          1 :         xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
    4903                 :          1 :         int ret = rsa_init_session(&xform);
    4904         [ -  + ]:          1 :         if (ret) {
    4905                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
    4906                 :          0 :                 return ret;
    4907                 :            :         }
    4908         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rsa_decrypt(vector, message, 0),
    4909                 :            :                 "RSA: Failed to encrypt");
    4910         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->message.data,
    4911                 :            :                 self->result_op->asym->rsa.message.data,
    4912                 :            :                 self->result_op->asym->rsa.message.length,
    4913                 :            :                 "operation verification failed\n");
    4914                 :            :         return 0;
    4915                 :            : }
    4916                 :            : 
    4917                 :            : static int
    4918                 :          1 : test_sm2_partial_encryption(const void *data)
    4919                 :            : {
    4920                 :          1 :         struct rte_crypto_asym_xform xform = { 0 };
    4921                 :          1 :         const uint8_t dev_id = params->valid_devs[0];
    4922                 :            :         const struct crypto_testsuite_sm2_params *test_vector = data;
    4923                 :          1 :         uint8_t result_C1_x1[TEST_DATA_SIZE] = { 0 };
    4924                 :          1 :         uint8_t result_C1_y1[TEST_DATA_SIZE] = { 0 };
    4925                 :          1 :         uint8_t result_kP_x1[TEST_DATA_SIZE] = { 0 };
    4926                 :          1 :         uint8_t result_kP_y1[TEST_DATA_SIZE] = { 0 };
    4927                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    4928                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    4929                 :            : 
    4930                 :          1 :         idx.type = RTE_CRYPTO_ASYM_XFORM_SM2;
    4931                 :          1 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    4932         [ +  - ]:          1 :         if (capa == NULL)
    4933                 :            :                 return TEST_SKIPPED;
    4934         [ -  + ]:          1 :         if (!rte_cryptodev_asym_xform_capability_check_opcap(capa,
    4935                 :            :                         RTE_CRYPTO_ASYM_OP_ENCRYPT, RTE_CRYPTO_SM2_PARTIAL)) {
    4936                 :            :                 return TEST_SKIPPED;
    4937                 :            :         }
    4938                 :            : 
    4939                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
    4940                 :          0 :         xform.ec.curve_id = RTE_CRYPTO_EC_GROUP_SM2;
    4941                 :          0 :         xform.ec.q = test_vector->pubkey;
    4942                 :          0 :         self->op->asym->sm2.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
    4943                 :          0 :         self->op->asym->sm2.k = test_vector->k;
    4944         [ #  # ]:          0 :         if (rte_cryptodev_asym_session_create(dev_id, &xform,
    4945                 :          0 :                         params->session_mpool, &self->sess) < 0) {
    4946                 :          0 :                 RTE_LOG(ERR, USER1, "line %u FAILED: Session creation failed",
    4947                 :            :                         __LINE__);
    4948                 :          0 :                 return TEST_FAILED;
    4949                 :            :         }
    4950         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(self->op, self->sess);
    4951                 :            : 
    4952                 :          0 :         self->op->asym->sm2.c1.x.data = result_C1_x1;
    4953                 :          0 :         self->op->asym->sm2.c1.y.data = result_C1_y1;
    4954                 :          0 :         self->op->asym->sm2.kp.x.data = result_kP_x1;
    4955                 :          0 :         self->op->asym->sm2.kp.y.data = result_kP_y1;
    4956         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one(),
    4957                 :            :                 "Failed to process crypto op");
    4958                 :            : 
    4959                 :          0 :         debug_hexdump(stdout, "C1[x]", self->op->asym->sm2.c1.x.data,
    4960                 :          0 :                 self->op->asym->sm2.c1.x.length);
    4961                 :          0 :         debug_hexdump(stdout, "C1[y]", self->op->asym->sm2.c1.y.data,
    4962                 :          0 :                 self->op->asym->sm2.c1.y.length);
    4963                 :          0 :         debug_hexdump(stdout, "kP[x]", self->op->asym->sm2.kp.x.data,
    4964                 :          0 :                 self->op->asym->sm2.kp.x.length);
    4965                 :          0 :         debug_hexdump(stdout, "kP[y]", self->op->asym->sm2.kp.y.data,
    4966                 :          0 :                 self->op->asym->sm2.kp.y.length);
    4967                 :            : 
    4968         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(test_vector->C1.x.data,
    4969                 :            :                 self->op->asym->sm2.c1.x.data,
    4970                 :            :                 test_vector->C1.x.length,
    4971                 :            :                 "Incorrect value of C1[x]\n");
    4972         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(test_vector->C1.y.data,
    4973                 :            :                 self->op->asym->sm2.c1.y.data,
    4974                 :            :                 test_vector->C1.y.length,
    4975                 :            :                 "Incorrect value of C1[y]\n");
    4976         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(test_vector->kP.x.data,
    4977                 :            :                 self->op->asym->sm2.kp.x.data,
    4978                 :            :                 test_vector->kP.x.length,
    4979                 :            :                 "Incorrect value of kP[x]\n");
    4980         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(test_vector->kP.y.data,
    4981                 :            :                 self->op->asym->sm2.kp.y.data,
    4982                 :            :                 test_vector->kP.y.length,
    4983                 :            :                 "Incorrect value of kP[y]\n");
    4984                 :            : 
    4985                 :            :         return TEST_SUCCESS;
    4986                 :            : }
    4987                 :            : 
    4988                 :            : static int
    4989                 :          1 : test_sm2_partial_decryption(const void *data)
    4990                 :            : {
    4991                 :          1 :         struct rte_crypto_asym_xform xform = {};
    4992                 :          1 :         const uint8_t dev_id = params->valid_devs[0];
    4993                 :            :         const struct crypto_testsuite_sm2_params *test_vector = data;
    4994                 :          1 :         uint8_t result_kP_x1[TEST_DATA_SIZE] = { 0 };
    4995                 :          1 :         uint8_t result_kP_y1[TEST_DATA_SIZE] = { 0 };
    4996                 :            :         struct rte_cryptodev_asym_capability_idx idx;
    4997                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capa;
    4998                 :            : 
    4999                 :          1 :         idx.type = RTE_CRYPTO_ASYM_XFORM_SM2;
    5000                 :          1 :         capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
    5001         [ +  - ]:          1 :         if (capa == NULL)
    5002                 :            :                 return TEST_SKIPPED;
    5003         [ -  + ]:          1 :         if (!rte_cryptodev_asym_xform_capability_check_opcap(capa,
    5004                 :            :                         RTE_CRYPTO_ASYM_OP_DECRYPT, RTE_CRYPTO_SM2_PARTIAL)) {
    5005                 :            :                 return TEST_SKIPPED;
    5006                 :            :         }
    5007                 :            : 
    5008                 :          0 :         xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
    5009                 :          0 :         xform.ec.pkey = test_vector->pkey;
    5010                 :          0 :         self->op->asym->sm2.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
    5011                 :          0 :         self->op->asym->sm2.c1 = test_vector->C1;
    5012                 :            : 
    5013         [ #  # ]:          0 :         if (rte_cryptodev_asym_session_create(dev_id, &xform,
    5014                 :          0 :                         params->session_mpool, &self->sess) < 0) {
    5015                 :          0 :                 RTE_LOG(ERR, USER1, "line %u FAILED: Session creation failed",
    5016                 :            :                         __LINE__);
    5017                 :          0 :                 return TEST_FAILED;
    5018                 :            :         }
    5019         [ #  # ]:          0 :         rte_crypto_op_attach_asym_session(self->op, self->sess);
    5020                 :            : 
    5021                 :          0 :         self->op->asym->sm2.kp.x.data = result_kP_x1;
    5022                 :          0 :         self->op->asym->sm2.kp.y.data = result_kP_y1;
    5023         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(send_one(),
    5024                 :            :                 "Failed to process crypto op");
    5025                 :            : 
    5026                 :          0 :         debug_hexdump(stdout, "kP[x]", self->op->asym->sm2.kp.x.data,
    5027                 :          0 :                 self->op->asym->sm2.c1.x.length);
    5028                 :          0 :         debug_hexdump(stdout, "kP[y]", self->op->asym->sm2.kp.y.data,
    5029                 :          0 :                 self->op->asym->sm2.c1.y.length);
    5030                 :            : 
    5031         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(test_vector->kP.x.data,
    5032                 :            :                 self->op->asym->sm2.kp.x.data,
    5033                 :            :                 test_vector->kP.x.length,
    5034                 :            :                 "Incorrect value of kP[x]\n");
    5035         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(test_vector->kP.y.data,
    5036                 :            :                 self->op->asym->sm2.kp.y.data,
    5037                 :            :                 test_vector->kP.y.length,
    5038                 :            :                 "Incorrect value of kP[y]\n");
    5039                 :            : 
    5040                 :            :         return 0;
    5041                 :            : }
    5042                 :            : 
    5043                 :            : static int
    5044                 :            : check_asym_capabilities_supported(const enum rte_crypto_asym_xform_type xform_type)
    5045                 :            : {
    5046                 :         12 :         uint8_t dev_id = testsuite_params.valid_devs[0];
    5047                 :         12 :         struct rte_cryptodev_asym_capability_idx idx = {xform_type};
    5048                 :            : 
    5049   [ -  +  -  +  :         12 :         if (rte_cryptodev_asym_capability_get(dev_id, &idx) == NULL)
          +  -  +  -  +  
          -  +  -  +  -  
          -  +  -  +  -  
             +  +  -  +  
                      - ]
    5050                 :            :                 return TEST_SKIPPED;
    5051                 :            :         return 0;
    5052                 :            : }
    5053                 :            : 
    5054                 :            : static int
    5055                 :          1 : crypto_asym_dh_testsuite_setup(void)
    5056                 :            : {
    5057                 :            :         if (check_asym_capabilities_supported(RTE_CRYPTO_ASYM_XFORM_DH) != 0) {
    5058                 :          0 :                 RTE_LOG(INFO, USER1,
    5059                 :            :                         "Device doesn't support required ASYM capabilities. Test skipped\n");
    5060                 :          0 :                 return TEST_SKIPPED;
    5061                 :            :         }
    5062                 :            :         return 0;
    5063                 :            : }
    5064                 :            : 
    5065                 :            : static int
    5066                 :          1 : crypto_asym_dsa_testsuite_setup(void)
    5067                 :            : {
    5068                 :            :         if (check_asym_capabilities_supported(RTE_CRYPTO_ASYM_XFORM_DSA) != 0) {
    5069                 :          0 :                 RTE_LOG(INFO, USER1,
    5070                 :            :                         "Device doesn't support required ASYM capabilities. Test skipped\n");
    5071                 :          0 :                 return TEST_SKIPPED;
    5072                 :            :         }
    5073                 :            :         return 0;
    5074                 :            : }
    5075                 :            : 
    5076                 :            : static int
    5077                 :          1 : crypto_asym_ecdh_testsuite_setup(void)
    5078                 :            : {
    5079                 :            :         if (check_asym_capabilities_supported(RTE_CRYPTO_ASYM_XFORM_ECDH) != 0) {
    5080                 :          1 :                 RTE_LOG(INFO, USER1,
    5081                 :            :                         "Device doesn't support required ASYM capabilities. Test skipped\n");
    5082                 :          1 :                 return TEST_SKIPPED;
    5083                 :            :         }
    5084                 :            :         return 0;
    5085                 :            : }
    5086                 :            : 
    5087                 :            : static int
    5088                 :          1 : crypto_asym_ecdsa_testsuite_setup(void)
    5089                 :            : {
    5090                 :            :         if (check_asym_capabilities_supported(RTE_CRYPTO_ASYM_XFORM_ECDSA) != 0) {
    5091                 :          1 :                 RTE_LOG(INFO, USER1,
    5092                 :            :                         "Device doesn't support required ASYM capabilities. Test skipped\n");
    5093                 :          1 :                 return TEST_SKIPPED;
    5094                 :            :         }
    5095                 :            :         return 0;
    5096                 :            : }
    5097                 :            : 
    5098                 :            : static int
    5099                 :          1 : crypto_asym_ecpm_testsuite_setup(void)
    5100                 :            : {
    5101                 :            :         if (check_asym_capabilities_supported(RTE_CRYPTO_ASYM_XFORM_ECPM) != 0) {
    5102                 :          1 :                 RTE_LOG(INFO, USER1,
    5103                 :            :                         "Device doesn't support required ASYM capabilities. Test skipped\n");
    5104                 :          1 :                 return TEST_SKIPPED;
    5105                 :            :         }
    5106                 :            :         return 0;
    5107                 :            : }
    5108                 :            : 
    5109                 :            : static int
    5110                 :          1 : crypto_asym_eddsa_testsuite_setup(void)
    5111                 :            : {
    5112                 :            :         if (check_asym_capabilities_supported(RTE_CRYPTO_ASYM_XFORM_EDDSA) != 0) {
    5113                 :          0 :                 RTE_LOG(INFO, USER1,
    5114                 :            :                         "Device doesn't support required ASYM capabilities. Test skipped\n");
    5115                 :          0 :                 return TEST_SKIPPED;
    5116                 :            :         }
    5117                 :            :         return 0;
    5118                 :            : }
    5119                 :            : 
    5120                 :            : static int
    5121                 :          1 : crypto_asym_mod_ex_testsuite_setup(void)
    5122                 :            : {
    5123                 :            :         if (check_asym_capabilities_supported(RTE_CRYPTO_ASYM_XFORM_MODEX) != 0) {
    5124                 :          0 :                 RTE_LOG(INFO, USER1,
    5125                 :            :                         "Device doesn't support required ASYM capabilities. Test skipped\n");
    5126                 :          0 :                 return TEST_SKIPPED;
    5127                 :            :         }
    5128                 :            :         return 0;
    5129                 :            : }
    5130                 :            : 
    5131                 :            : static int
    5132                 :          1 : crypto_asym_mod_inv_testsuite_setup(void)
    5133                 :            : {
    5134                 :            :         if (check_asym_capabilities_supported(RTE_CRYPTO_ASYM_XFORM_MODINV) != 0) {
    5135                 :          0 :                 RTE_LOG(INFO, USER1,
    5136                 :            :                         "Device doesn't support required ASYM capabilities. Test skipped\n");
    5137                 :          0 :                 return TEST_SKIPPED;
    5138                 :            :         }
    5139                 :            :         return 0;
    5140                 :            : }
    5141                 :            : 
    5142                 :            : static int
    5143                 :          1 : crypto_asym_rsa_testsuite_setup(void)
    5144                 :            : {
    5145                 :            :         if (check_asym_capabilities_supported(RTE_CRYPTO_ASYM_XFORM_RSA) != 0) {
    5146                 :          0 :                 RTE_LOG(INFO, USER1,
    5147                 :            :                         "Device doesn't support required ASYM capabilities. Test skipped\n");
    5148                 :          0 :                 return TEST_SKIPPED;
    5149                 :            :         }
    5150                 :            :         return 0;
    5151                 :            : }
    5152                 :            : 
    5153                 :            : static int
    5154                 :          1 : crypto_asym_sm2_testsuite_setup(void)
    5155                 :            : {
    5156                 :            :         if (check_asym_capabilities_supported(RTE_CRYPTO_ASYM_XFORM_SM2) != 0) {
    5157                 :          0 :                 RTE_LOG(INFO, USER1,
    5158                 :            :                         "Device doesn't support required ASYM capabilities. Test skipped\n");
    5159                 :          0 :                 return TEST_SKIPPED;
    5160                 :            :         }
    5161                 :            :         return 0;
    5162                 :            : }
    5163                 :            : 
    5164                 :            : static int
    5165                 :          1 : crypto_asym_ml_kem_testsuite_setup(void)
    5166                 :            : {
    5167                 :            :         if (check_asym_capabilities_supported(RTE_CRYPTO_ASYM_XFORM_ML_KEM) != 0) {
    5168                 :          1 :                 RTE_LOG(INFO, USER1,
    5169                 :            :                         "Device doesn't support required ASYM capabilities. Test skipped\n");
    5170                 :          1 :                 return TEST_SKIPPED;
    5171                 :            :         }
    5172                 :            :         return 0;
    5173                 :            : }
    5174                 :            : 
    5175                 :            : static int
    5176                 :          1 : crypto_asym_ml_dsa_testsuite_setup(void)
    5177                 :            : {
    5178                 :            :         if (check_asym_capabilities_supported(RTE_CRYPTO_ASYM_XFORM_ML_DSA) != 0) {
    5179                 :          1 :                 RTE_LOG(INFO, USER1,
    5180                 :            :                         "Device doesn't support required ASYM capabilities. Test skipped\n");
    5181                 :          1 :                 return TEST_SKIPPED;
    5182                 :            :         }
    5183                 :            :         return 0;
    5184                 :            : }
    5185                 :            : 
    5186                 :            : static struct unit_test_suite cryptodev_asym_gen_testsuite = {
    5187                 :            :         .suite_name = "Cryptodev ASYM General Unit Test Suite",
    5188                 :            :         .unit_test_cases = {
    5189                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_capability),
    5190                 :            :                 TEST_CASES_END()
    5191                 :            :         }
    5192                 :            : };
    5193                 :            : 
    5194                 :            : static struct unit_test_suite cryptodev_asym_dh_testsuite = {
    5195                 :            :         .suite_name = "Cryptodev ASYM DH Unit Test Suite",
    5196                 :            :         .setup = crypto_asym_dh_testsuite_setup,
    5197                 :            :         .unit_test_cases = {
    5198                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_dh_key_generation),
    5199                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
    5200                 :            :         }
    5201                 :            : };
    5202                 :            : 
    5203                 :            : static struct unit_test_suite cryptodev_asym_dsa_testsuite = {
    5204                 :            :         .suite_name = "Cryptodev ASYM DSA Unit Test Suite",
    5205                 :            :         .setup = crypto_asym_dsa_testsuite_setup,
    5206                 :            :         .unit_test_cases = {
    5207                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_dsa),
    5208                 :            :                 TEST_CASES_END()
    5209                 :            :         }
    5210                 :            : };
    5211                 :            : 
    5212                 :            : static struct unit_test_suite cryptodev_asym_ecdh_testsuite = {
    5213                 :            :         .suite_name = "Cryptodev ASYM ECDH Unit Test Suite",
    5214                 :            :         .setup = crypto_asym_ecdh_testsuite_setup,
    5215                 :            :         .unit_test_cases = {
    5216                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym,
    5217                 :            :                                 test_ecdh_all_curve),
    5218                 :            :                 TEST_CASE_NAMED_ST(
    5219                 :            :                         "ECDH Elliptic Curve tests",
    5220                 :            :                         ut_setup_asym, ut_teardown_asym,
    5221                 :            :                         test_ecdh_qat_curves),
    5222                 :            :                 TEST_CASES_END()
    5223                 :            :         }
    5224                 :            : };
    5225                 :            : 
    5226                 :            : static struct unit_test_suite cryptodev_asym_ecdsa_testsuite = {
    5227                 :            :         .suite_name = "Cryptodev ASYM ECDSA Unit Test Suite",
    5228                 :            :         .setup = crypto_asym_ecdsa_testsuite_setup,
    5229                 :            :         .unit_test_cases = {
    5230                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym,
    5231                 :            :                              test_ecdsa_sign_verify_all_curve),
    5232                 :            :                 TEST_CASE_NAMED_ST(
    5233                 :            :                         "ECDSA Elliptic Curve tests",
    5234                 :            :                         ut_setup_asym, ut_teardown_asym,
    5235                 :            :                         test_ecdsa_sign_verify_qat_curves),
    5236                 :            :                 TEST_CASES_END()
    5237                 :            :         }
    5238                 :            : };
    5239                 :            : 
    5240                 :            : static struct unit_test_suite cryptodev_asym_ecpm_testsuite = {
    5241                 :            :         .suite_name = "Cryptodev ASYM ECPM Unit Test Suite",
    5242                 :            :         .setup = crypto_asym_ecpm_testsuite_setup,
    5243                 :            :         .unit_test_cases = {
    5244                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym,
    5245                 :            :                                 test_ecpm_all_curve),
    5246                 :            :                 TEST_CASE_NAMED_ST(
    5247                 :            :                         "ECPM Elliptic Curve tests",
    5248                 :            :                         ut_setup_asym, ut_teardown_asym,
    5249                 :            :                         test_ecpm_qat_curves),
    5250                 :            :                 TEST_CASES_END()
    5251                 :            :         }
    5252                 :            : };
    5253                 :            : 
    5254                 :            : static struct unit_test_suite cryptodev_asym_eddsa_testsuite = {
    5255                 :            :         .suite_name = "Cryptodev ASYM EdDSA Unit Test Suite",
    5256                 :            :         .setup = crypto_asym_eddsa_testsuite_setup,
    5257                 :            :         .unit_test_cases = {
    5258                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_eddsa_sign_verify_all_curve),
    5259                 :            :                 TEST_CASES_END()
    5260                 :            :         }
    5261                 :            : };
    5262                 :            : 
    5263                 :            : static struct unit_test_suite cryptodev_asym_mod_ex_testsuite = {
    5264                 :            :         .suite_name = "Cryptodev ASYM MOD Ex Unit Test Suite",
    5265                 :            :         .setup = crypto_asym_mod_ex_testsuite_setup,
    5266                 :            :         .unit_test_cases = {
    5267                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mod_exp),
    5268                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5269                 :            :                         "Modex test for zero padding",
    5270                 :            :                         ut_setup_asym, ut_teardown_asym,
    5271                 :            :                         modular_exponentiation, &modex_test_cases[0]),
    5272                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5273                 :            :                         "Modex test for zero padding (2)",
    5274                 :            :                         ut_setup_asym, ut_teardown_asym,
    5275                 :            :                         modular_exponentiation, &modex_test_cases[1]),
    5276                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5277                 :            :                         "Modex Group 5 test",
    5278                 :            :                         ut_setup_asym, ut_teardown_asym,
    5279                 :            :                         modular_exponentiation, &modex_group_test_cases[0]),
    5280                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5281                 :            :                         "Modex Group 14 test",
    5282                 :            :                         ut_setup_asym, ut_teardown_asym,
    5283                 :            :                         modular_exponentiation, &modex_group_test_cases[1]),
    5284                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5285                 :            :                         "Modex Group 15 test",
    5286                 :            :                         ut_setup_asym, ut_teardown_asym,
    5287                 :            :                         modular_exponentiation, &modex_group_test_cases[2]),
    5288                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5289                 :            :                         "Modex Group 16 test",
    5290                 :            :                         ut_setup_asym, ut_teardown_asym,
    5291                 :            :                         modular_exponentiation, &modex_group_test_cases[3]),
    5292                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5293                 :            :                         "Modex Group 17 test",
    5294                 :            :                         ut_setup_asym, ut_teardown_asym,
    5295                 :            :                         modular_exponentiation, &modex_group_test_cases[4]),
    5296                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5297                 :            :                         "Modex Group 18 test",
    5298                 :            :                         ut_setup_asym, ut_teardown_asym,
    5299                 :            :                         modular_exponentiation, &modex_group_test_cases[5]),
    5300                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5301                 :            :                         "Modex Group 24 test",
    5302                 :            :                         ut_setup_asym, ut_teardown_asym,
    5303                 :            :                         modular_exponentiation, &modex_group_test_cases[6]),
    5304                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5305                 :            :                         "Modex Group 24 subgroup test",
    5306                 :            :                         ut_setup_asym, ut_teardown_asym,
    5307                 :            :                         modular_exponentiation, &modex_group_test_cases[7]),
    5308                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5309                 :            :                         "Modular Exponentiation (mod=128, base=20, exp=3, res=128)",
    5310                 :            :                         ut_setup_asym, ut_teardown_asym,
    5311                 :            :                         modular_exponentiation, &modex_test_case_m128_b20_e3),
    5312                 :            :                 TEST_CASES_END()
    5313                 :            :         }
    5314                 :            : };
    5315                 :            : 
    5316                 :            : static struct unit_test_suite cryptodev_asym_mod_inv_testsuite = {
    5317                 :            :         .suite_name = "Cryptodev ASYM MOD Inv Unit Test Suite",
    5318                 :            :         .setup = crypto_asym_mod_inv_testsuite_setup,
    5319                 :            :         .unit_test_cases = {
    5320                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mod_inv),
    5321                 :            :                 /* Modular Multiplicative Inverse */
    5322                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5323                 :            :                         "Modular Inverse (mod=128, base=20, exp=3, inv=128)",
    5324                 :            :                         ut_setup_asym, ut_teardown_asym,
    5325                 :            :                         modular_multiplicative_inverse, &modinv_test_case),
    5326                 :            :                 TEST_CASES_END()
    5327                 :            :         }
    5328                 :            : };
    5329                 :            : 
    5330                 :            : static struct unit_test_suite cryptodev_asym_rsa_testsuite = {
    5331                 :            :         .suite_name = "Cryptodev ASYM RSA Unit Test Suite",
    5332                 :            :         .setup = crypto_asym_rsa_testsuite_setup,
    5333                 :            :         .unit_test_cases = {
    5334                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_rsa_enc_dec),
    5335                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym,
    5336                 :            :                                 test_rsa_sign_verify),
    5337                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym,
    5338                 :            :                                 test_rsa_enc_dec_crt),
    5339                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym,
    5340                 :            :                                 test_rsa_sign_verify_crt),
    5341                 :            :                 /* RSA EXP */
    5342                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5343                 :            :                         "RSA Encryption (n=128, pt=20, e=3) EXP, Padding: NONE",
    5344                 :            :                         ut_setup_asym, ut_teardown_asym,
    5345                 :            :                         kat_rsa_encrypt, &rsa_vector_128_20_3_none),
    5346                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5347                 :            :                         "RSA Decryption (n=128, pt=20, e=3) EXP, Padding: NONE",
    5348                 :            :                         ut_setup_asym, ut_teardown_asym,
    5349                 :            :                         kat_rsa_decrypt, &rsa_vector_128_20_3_none),
    5350                 :            :                 /* RSA CRT */
    5351                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5352                 :            :                         "RSA Encryption (n=128, pt=20, e=3) CRT, Padding: NONE",
    5353                 :            :                         ut_setup_asym, ut_teardown_asym,
    5354                 :            :                         kat_rsa_encrypt_crt, &rsa_vector_128_20_3_none),
    5355                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5356                 :            :                         "RSA Decryption (n=128, pt=20, e=3) CRT, Padding: NONE",
    5357                 :            :                         ut_setup_asym, ut_teardown_asym,
    5358                 :            :                         kat_rsa_decrypt_crt, &rsa_vector_128_20_3_none),
    5359                 :            :                 TEST_CASES_END()
    5360                 :            :         }
    5361                 :            : };
    5362                 :            : 
    5363                 :            : static struct unit_test_suite cryptodev_asym_sm2_testsuite = {
    5364                 :            :         .suite_name = "Cryptodev ASYM SM2 Unit Test Suite",
    5365                 :            :         .setup = crypto_asym_sm2_testsuite_setup,
    5366                 :            :         .unit_test_cases = {
    5367                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_sm2_sign),
    5368                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_sm2_verify),
    5369                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_sm2_enc),
    5370                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_sm2_dec),
    5371                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5372                 :            :                         "SM2 encryption - test case 1",
    5373                 :            :                         ut_setup_asym, ut_teardown_asym,
    5374                 :            :                         test_sm2_partial_encryption, &sm2_enc_hw_t1),
    5375                 :            :                 TEST_CASE_NAMED_WITH_DATA(
    5376                 :            :                         "SM2 decryption - test case 1",
    5377                 :            :                         ut_setup_asym, ut_teardown_asym,
    5378                 :            :                         test_sm2_partial_decryption, &sm2_enc_hw_t1),
    5379                 :            :                 TEST_CASES_END()
    5380                 :            :         }
    5381                 :            : };
    5382                 :            : 
    5383                 :            : static struct unit_test_suite cryptodev_asym_ml_kem_testsuite = {
    5384                 :            :         .suite_name = "Cryptodev ASYM ML KEM Unit Test Suite",
    5385                 :            :         .setup = crypto_asym_ml_kem_testsuite_setup,
    5386                 :            :         .unit_test_cases = {
    5387                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mlkem_keygen),
    5388                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mlkem_encap),
    5389                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mlkem_decap),
    5390                 :            :                 TEST_CASES_END()
    5391                 :            :         }
    5392                 :            : };
    5393                 :            : 
    5394                 :            : static struct unit_test_suite cryptodev_asym_ml_dsa_testsuite = {
    5395                 :            :         .suite_name = "Cryptodev ASYM ML DSA Unit Test Suite",
    5396                 :            :         .setup = crypto_asym_ml_dsa_testsuite_setup,
    5397                 :            :         .unit_test_cases = {
    5398                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mldsa_keygen),
    5399                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mldsa_sign),
    5400                 :            :                 TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mldsa_verify),
    5401                 :            :                 TEST_CASES_END()
    5402                 :            :         }
    5403                 :            : };
    5404                 :            : 
    5405                 :            : static struct unit_test_suite end_testsuite = {
    5406                 :            :         .suite_name = NULL,
    5407                 :            :         .setup = NULL,
    5408                 :            :         .teardown = NULL,
    5409                 :            :         .unit_test_suites = NULL
    5410                 :            : };
    5411                 :            : 
    5412                 :            : static int
    5413                 :          1 : run_cryptodev_asym_testsuite(const char *pmd_name)
    5414                 :            : {
    5415                 :            :         uint8_t ret, j, i = 0;
    5416                 :            : 
    5417                 :          1 :         struct unit_test_suite *asym_suites[] = {
    5418                 :            :                 &cryptodev_asym_gen_testsuite,
    5419                 :            :                 &cryptodev_asym_dh_testsuite,
    5420                 :            :                 &cryptodev_asym_dsa_testsuite,
    5421                 :            :                 &cryptodev_asym_ecdh_testsuite,
    5422                 :            :                 &cryptodev_asym_ecdsa_testsuite,
    5423                 :            :                 &cryptodev_asym_ecpm_testsuite,
    5424                 :            :                 &cryptodev_asym_eddsa_testsuite,
    5425                 :            :                 &cryptodev_asym_mod_ex_testsuite,
    5426                 :            :                 &cryptodev_asym_mod_inv_testsuite,
    5427                 :            :                 &cryptodev_asym_rsa_testsuite,
    5428                 :            :                 &cryptodev_asym_sm2_testsuite,
    5429                 :            :                 &cryptodev_asym_ml_kem_testsuite,
    5430                 :            :                 &cryptodev_asym_ml_dsa_testsuite,
    5431                 :            :                 &end_testsuite
    5432                 :            :         };
    5433                 :            : 
    5434                 :            :         static struct unit_test_suite asym_ts = {
    5435                 :            :                 .suite_name = "Cryptodev ASYM Unit Test Suite",
    5436                 :            :                 .setup = testsuite_setup,
    5437                 :            :                 .teardown = testsuite_teardown,
    5438                 :            :                 .unit_test_cases = {TEST_CASES_END()}
    5439                 :            :         };
    5440                 :            : 
    5441                 :          1 :         gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
    5442         [ -  + ]:          1 :         if (gbl_driver_id == -1) {
    5443                 :          0 :                 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
    5444                 :          0 :                 return TEST_SKIPPED;
    5445                 :            :         }
    5446                 :            : 
    5447                 :          1 :         asym_ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * RTE_DIM(asym_suites));
    5448         [ -  + ]:          1 :         if (asym_ts.unit_test_suites == NULL) {
    5449                 :          0 :                 RTE_LOG(ERR, USER1,
    5450                 :            :                         "Failed to allocate memory for unit test suites\n");
    5451                 :          0 :                 return TEST_FAILED;
    5452                 :            :         }
    5453                 :            : 
    5454         [ +  + ]:         15 :         ADD_ASYM_TESTSUITE(i, asym_ts, asym_suites, RTE_DIM(asym_suites));
    5455                 :          1 :         ret = unit_test_suite_runner(&asym_ts);
    5456                 :            : 
    5457                 :          1 :         free(asym_ts.unit_test_suites);
    5458                 :            : 
    5459                 :          1 :         return ret;
    5460                 :            : }
    5461                 :            : 
    5462                 :            : static int
    5463                 :          1 : test_cryptodev_openssl_asym(void)
    5464                 :            : {
    5465                 :          1 :         return run_cryptodev_asym_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
    5466                 :            : }
    5467                 :            : 
    5468                 :            : static int
    5469                 :          0 : test_cryptodev_qat_asym(void)
    5470                 :            : {
    5471                 :          0 :         return run_cryptodev_asym_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_ASYM_PMD));
    5472                 :            : }
    5473                 :            : 
    5474                 :            : static int
    5475                 :          0 : test_cryptodev_octeontx_asym(void)
    5476                 :            : {
    5477                 :          0 :         return run_cryptodev_asym_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
    5478                 :            : }
    5479                 :            : 
    5480                 :            : static int
    5481                 :          0 : test_cryptodev_cn9k_asym(void)
    5482                 :            : {
    5483                 :          0 :         return run_cryptodev_asym_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
    5484                 :            : }
    5485                 :            : 
    5486                 :            : static int
    5487                 :          0 : test_cryptodev_cn10k_asym(void)
    5488                 :            : {
    5489                 :          0 :         return run_cryptodev_asym_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
    5490                 :            : }
    5491                 :            : 
    5492                 :            : static int
    5493                 :          0 : test_cryptodev_virtio_asym(void)
    5494                 :            : {
    5495                 :          0 :         return run_cryptodev_asym_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
    5496                 :            : }
    5497                 :            : 
    5498                 :            : static int
    5499                 :          0 : test_cryptodev_virtio_user_asym(void)
    5500                 :            : {
    5501                 :          0 :         return run_cryptodev_asym_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_USER_PMD));
    5502                 :            : }
    5503                 :            : 
    5504                 :        276 : REGISTER_DRIVER_TEST(cryptodev_openssl_asym_autotest, test_cryptodev_openssl_asym);
    5505                 :        276 : REGISTER_DRIVER_TEST(cryptodev_qat_asym_autotest, test_cryptodev_qat_asym);
    5506                 :        276 : REGISTER_DRIVER_TEST(cryptodev_octeontx_asym_autotest, test_cryptodev_octeontx_asym);
    5507                 :        276 : REGISTER_DRIVER_TEST(cryptodev_cn9k_asym_autotest, test_cryptodev_cn9k_asym);
    5508                 :        276 : REGISTER_DRIVER_TEST(cryptodev_cn10k_asym_autotest, test_cryptodev_cn10k_asym);
    5509                 :        276 : REGISTER_DRIVER_TEST(cryptodev_virtio_asym_autotest, test_cryptodev_virtio_asym);
    5510                 :        276 : REGISTER_DRIVER_TEST(cryptodev_virtio_user_asym_autotest, test_cryptodev_virtio_user_asym);

Generated by: LCOV version 1.14