LCOV - code coverage report
Current view: top level - app/test - test_cryptodev_asym.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 1183 2715 43.6 %
Date: 2026-11-01 19:11:22 Functions: 76 108 70.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 362 1291 28.0 %

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

Generated by: LCOV version 1.14