LCOV - code coverage report
Current view: top level - app/test - test_cryptodev.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 2129 6747 31.6 %
Date: 2026-04-01 20:02:27 Functions: 290 717 40.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 715 4073 17.6 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2015-2020 Intel Corporation
       3                 :            :  * Copyright 2020 NXP
       4                 :            :  */
       5                 :            : 
       6                 :            : #include <stdbool.h>
       7                 :            : #include <time.h>
       8                 :            : 
       9                 :            : #include <rte_common.h>
      10                 :            : #include <rte_hexdump.h>
      11                 :            : #include <rte_mbuf.h>
      12                 :            : #include <rte_malloc.h>
      13                 :            : #include <rte_memcpy.h>
      14                 :            : #include <rte_pause.h>
      15                 :            : #include <rte_bus_vdev.h>
      16                 :            : #include <rte_ether.h>
      17                 :            : #include <rte_errno.h>
      18                 :            : 
      19                 :            : #include <rte_crypto.h>
      20                 :            : #include <rte_cryptodev.h>
      21                 :            : #include <rte_ethdev.h>
      22                 :            : #include <rte_ip.h>
      23                 :            : #include <rte_string_fns.h>
      24                 :            : #include <rte_tcp.h>
      25                 :            : #include <rte_tls.h>
      26                 :            : #include <rte_udp.h>
      27                 :            : 
      28                 :            : #ifdef RTE_CRYPTO_SCHEDULER
      29                 :            : #include <rte_cryptodev_scheduler.h>
      30                 :            : #include <rte_cryptodev_scheduler_operations.h>
      31                 :            : #endif
      32                 :            : 
      33                 :            : #include <rte_lcore.h>
      34                 :            : 
      35                 :            : #include "test.h"
      36                 :            : #include "test_cryptodev.h"
      37                 :            : 
      38                 :            : #include "test_cryptodev_blockcipher.h"
      39                 :            : #include "test_cryptodev_aes_test_vectors.h"
      40                 :            : #include "test_cryptodev_des_test_vectors.h"
      41                 :            : #include "test_cryptodev_hash_test_vectors.h"
      42                 :            : #include "test_cryptodev_kasumi_test_vectors.h"
      43                 :            : #include "test_cryptodev_kasumi_hash_test_vectors.h"
      44                 :            : #include "test_cryptodev_snow3g_test_vectors.h"
      45                 :            : #include "test_cryptodev_snow3g_hash_test_vectors.h"
      46                 :            : #include "test_cryptodev_zuc_test_vectors.h"
      47                 :            : #include "test_cryptodev_aead_test_vectors.h"
      48                 :            : #include "test_cryptodev_hmac_test_vectors.h"
      49                 :            : #include "test_cryptodev_mixed_test_vectors.h"
      50                 :            : #include "test_cryptodev_sm4_test_vectors.h"
      51                 :            : #include "test_cryptodev_nxan_test_vectors.h"
      52                 :            : #ifdef RTE_LIB_SECURITY
      53                 :            : #include "test_cryptodev_security_ipsec.h"
      54                 :            : #include "test_cryptodev_security_ipsec_test_vectors.h"
      55                 :            : #include "test_cryptodev_security_pdcp_test_vectors.h"
      56                 :            : #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
      57                 :            : #include "test_cryptodev_security_pdcp_test_func.h"
      58                 :            : #include "test_cryptodev_security_docsis_test_vectors.h"
      59                 :            : #include "test_cryptodev_security_tls_record.h"
      60                 :            : #include "test_security_proto.h"
      61                 :            : 
      62                 :            : #define SDAP_DISABLED   0
      63                 :            : #define SDAP_ENABLED    1
      64                 :            : #endif
      65                 :            : 
      66                 :            : #define VDEV_ARGS_SIZE 100
      67                 :            : #define MAX_NB_SESSIONS 4
      68                 :            : 
      69                 :            : #define MAX_RAW_DEQUEUE_COUNT   65535
      70                 :            : 
      71                 :            : #define IN_PLACE 0
      72                 :            : #define OUT_OF_PLACE 1
      73                 :            : 
      74                 :            : #define QP_DRAIN_TIMEOUT 100
      75                 :            : #define HW_ERR_RECOVER_TIMEOUT 500
      76                 :            : 
      77                 :            : static int gbl_driver_id;
      78                 :            : 
      79                 :            : enum rte_security_session_action_type gbl_action_type =
      80                 :            :         RTE_SECURITY_ACTION_TYPE_NONE;
      81                 :            : 
      82                 :            : enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
      83                 :            : 
      84                 :            : struct crypto_unittest_params {
      85                 :            :         struct rte_crypto_sym_xform cipher_xform;
      86                 :            :         struct rte_crypto_sym_xform auth_xform;
      87                 :            :         struct rte_crypto_sym_xform aead_xform;
      88                 :            : #ifdef RTE_LIB_SECURITY
      89                 :            :         struct rte_security_docsis_xform docsis_xform;
      90                 :            : #endif
      91                 :            : 
      92                 :            :         union {
      93                 :            :                 void *sess;
      94                 :            : #ifdef RTE_LIB_SECURITY
      95                 :            :                 void *sec_session;
      96                 :            : #endif
      97                 :            :         };
      98                 :            : #ifdef RTE_LIB_SECURITY
      99                 :            :         enum rte_security_session_action_type type;
     100                 :            : #endif
     101                 :            :         struct rte_crypto_op *op;
     102                 :            : 
     103                 :            :         struct rte_mbuf *obuf, *ibuf;
     104                 :            : 
     105                 :            :         uint8_t *digest;
     106                 :            : };
     107                 :            : 
     108                 :            : #define ALIGN_POW2_ROUNDUP(num, align) \
     109                 :            :         (((num) + (align) - 1) & ~((align) - 1))
     110                 :            : 
     111                 :            : #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts)  \
     112                 :            :         for (j = 0; j < num_child_ts; index++, j++)                  \
     113                 :            :                 parent_ts.unit_test_suites[index] = child_ts[j]
     114                 :            : 
     115                 :            : #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types)   \
     116                 :            :         for (j = 0; j < num_blk_types; index++, j++)                         \
     117                 :            :                 parent_ts.unit_test_suites[index] =                             \
     118                 :            :                                 build_blockcipher_test_suite(blk_types[j])
     119                 :            : 
     120                 :            : #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types)             \
     121                 :            :         for (j = index; j < index + num_blk_types; j++)                              \
     122                 :            :                 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
     123                 :            : 
     124                 :            : /*
     125                 :            :  * Forward declarations.
     126                 :            :  */
     127                 :            : static int
     128                 :            : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
     129                 :            :                 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
     130                 :            :                 uint8_t *hmac_key);
     131                 :            : 
     132                 :            : static int
     133                 :            : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
     134                 :            :                 struct crypto_unittest_params *ut_params,
     135                 :            :                 struct crypto_testsuite_params *ts_param,
     136                 :            :                 const uint8_t *cipher,
     137                 :            :                 const uint8_t *digest,
     138                 :            :                 const uint8_t *iv);
     139                 :            : 
     140                 :            : static int
     141                 :            : security_proto_supported(enum rte_security_session_action_type action,
     142                 :            :         enum rte_security_session_protocol proto);
     143                 :            : 
     144                 :            : static int
     145                 :            : dev_configure_and_start(uint64_t ff_disable);
     146                 :            : 
     147                 :            : static int
     148                 :            : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
     149                 :            :                         const enum rte_crypto_cipher_algorithm cipher_algo,
     150                 :            :                         const uint16_t key_size, const uint16_t iv_size);
     151                 :            : 
     152                 :            : static int
     153                 :            : check_auth_capability(const struct crypto_testsuite_params *ts_params,
     154                 :            :                         const enum rte_crypto_auth_algorithm auth_algo,
     155                 :            :                         const uint16_t key_size, const uint16_t iv_size,
     156                 :            :                         const uint16_t tag_size);
     157                 :            : 
     158                 :            : static struct rte_mbuf *
     159                 :          7 : setup_test_string(struct rte_mempool *mpool,
     160                 :            :                 const char *string, size_t len, uint8_t blocksize)
     161                 :            : {
     162                 :          7 :         struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
     163         [ -  + ]:          7 :         size_t t_len = len - (blocksize ? (len % blocksize) : 0);
     164                 :            : 
     165         [ +  - ]:          7 :         if (m) {
     166                 :            :                 char *dst;
     167                 :            : 
     168                 :          7 :                 memset(m->buf_addr, 0, m->buf_len);
     169                 :          7 :                 dst = rte_pktmbuf_append(m, t_len);
     170         [ -  + ]:          7 :                 if (!dst) {
     171                 :          0 :                         rte_pktmbuf_free(m);
     172                 :          0 :                         return NULL;
     173                 :            :                 }
     174         [ +  - ]:          7 :                 if (string != NULL)
     175                 :            :                         rte_memcpy(dst, string, t_len);
     176                 :            :                 else
     177                 :            :                         memset(dst, 0, t_len);
     178                 :            :         }
     179                 :            : 
     180                 :            :         return m;
     181                 :            : }
     182                 :            : 
     183                 :            : /* Get number of bytes in X bits (rounding up) */
     184                 :            : static uint32_t
     185                 :            : ceil_byte_length(uint32_t num_bits)
     186                 :            : {
     187                 :          4 :         if (num_bits % 8)
     188                 :          0 :                 return ((num_bits >> 3) + 1);
     189                 :            :         else
     190                 :          4 :                 return (num_bits >> 3);
     191                 :            : }
     192                 :            : 
     193                 :            : static void
     194                 :          0 : post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
     195                 :            :                 uint8_t is_op_success)
     196                 :            : {
     197                 :            :         struct rte_crypto_op *op = user_data;
     198         [ #  # ]:          0 :         op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
     199                 :            :                         RTE_CRYPTO_OP_STATUS_ERROR;
     200                 :          0 : }
     201                 :            : 
     202                 :            : static struct crypto_testsuite_params testsuite_params = { NULL };
     203                 :            : struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
     204                 :            : static struct crypto_unittest_params unittest_params;
     205                 :            : static bool enq_cb_called;
     206                 :            : static bool deq_cb_called;
     207                 :            : 
     208                 :            : enum cryptodev_err_state {
     209                 :            :         CRYPTODEV_ERR_CLEARED,
     210                 :            :         CRYPTODEV_ERR_TRIGGERED,
     211                 :            :         CRYPTODEV_ERR_UNRECOVERABLE,
     212                 :            : };
     213                 :            : 
     214                 :            : static enum cryptodev_err_state crypto_err = CRYPTODEV_ERR_CLEARED;
     215                 :            : 
     216                 :            : static void
     217                 :          0 : test_cryptodev_error_cb(uint8_t dev_id, enum rte_cryptodev_event_type event, void *cb_arg)
     218                 :            : {
     219                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     220                 :            :         uint16_t qp_id;
     221                 :            :         int ticks = 0;
     222                 :            :         int ret = 0;
     223                 :            : 
     224                 :            :         RTE_SET_USED(event);
     225                 :            :         RTE_SET_USED(cb_arg);
     226                 :            : 
     227         [ #  # ]:          0 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
     228                 :          0 :                 ret = rte_cryptodev_queue_pair_event_error_query(dev_id, qp_id);
     229         [ #  # ]:          0 :                 if (ret)
     230                 :            :                         break;
     231                 :            :         }
     232         [ #  # ]:          0 :         if (ret == 1) {
     233                 :            :                 /* Wait for the queue to be completely drained */
     234   [ #  #  #  # ]:          0 :                 while (rte_cryptodev_qp_depth_used(dev_id, qp_id) != 0) {
     235                 :            :                         rte_delay_ms(10);
     236                 :          0 :                         ticks++;
     237         [ #  # ]:          0 :                         if (ticks > QP_DRAIN_TIMEOUT) {
     238                 :          0 :                                 crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
     239                 :          0 :                                 return;
     240                 :            :                         }
     241                 :            :                 }
     242         [ #  # ]:          0 :                 if (rte_cryptodev_queue_pair_reset(dev_id, qp_id, NULL, 0)) {
     243                 :          0 :                         crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
     244                 :          0 :                         return;
     245                 :            :                 }
     246                 :            :         }
     247                 :            : 
     248                 :          0 :         crypto_err = CRYPTODEV_ERR_CLEARED;
     249                 :            : }
     250                 :            : 
     251                 :            : static struct rte_mbuf *
     252                 :          0 : create_mbuf_from_heap(int pkt_len, uint8_t pattern)
     253                 :            : {
     254                 :            :         struct rte_mbuf *m = NULL;
     255                 :            :         uint8_t *dst;
     256                 :            : 
     257                 :          0 :         m = calloc(1, MBUF_SIZE);
     258         [ #  # ]:          0 :         if (m == NULL) {
     259                 :            :                 printf("Cannot create mbuf from heap");
     260                 :          0 :                 return NULL;
     261                 :            :         }
     262                 :            : 
     263                 :            :         /* Set the default values to the mbuf */
     264                 :          0 :         m->nb_segs = 1;
     265                 :          0 :         m->port = RTE_MBUF_PORT_INVALID;
     266                 :          0 :         m->buf_len = MBUF_SIZE - sizeof(struct rte_mbuf) - RTE_PKTMBUF_HEADROOM;
     267                 :            :         rte_pktmbuf_reset_headroom(m);
     268                 :            :         __rte_mbuf_sanity_check(m, 1);
     269                 :            : 
     270                 :          0 :         m->buf_addr = (char *)m + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM;
     271                 :            : 
     272                 :          0 :         memset(m->buf_addr, pattern, m->buf_len);
     273                 :          0 :         dst = (uint8_t *)rte_pktmbuf_append(m, pkt_len);
     274         [ #  # ]:          0 :         if (dst == NULL) {
     275                 :            :                 printf("Cannot append %d bytes to the mbuf\n", pkt_len);
     276                 :          0 :                 free(m);
     277                 :          0 :                 return NULL;
     278                 :            :         }
     279                 :            : 
     280                 :            :         return m;
     281                 :            : }
     282                 :            : 
     283                 :            : int
     284                 :          0 : process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
     285                 :            :                 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
     286                 :            :                 uint8_t len_in_bits, uint8_t cipher_iv_len)
     287                 :            : {
     288                 :          0 :         struct rte_crypto_sym_op *sop = op->sym;
     289                 :          0 :         struct rte_crypto_op *ret_op = NULL;
     290                 :            :         struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
     291                 :            :         struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
     292                 :            :         union rte_crypto_sym_ofs ofs;
     293                 :          0 :         struct rte_crypto_sym_vec vec = {0};
     294                 :            :         struct rte_crypto_sgl sgl, dest_sgl;
     295                 :            :         uint32_t max_len;
     296                 :            :         union rte_cryptodev_session_ctx sess;
     297                 :            :         uint64_t auth_end_iova;
     298                 :            :         uint32_t count = 0;
     299                 :            :         struct rte_crypto_raw_dp_ctx *ctx;
     300                 :            :         uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
     301                 :            :                         auth_len = 0;
     302                 :            :         int32_t n;
     303                 :            :         uint32_t n_success;
     304                 :            :         int ctx_service_size;
     305                 :          0 :         int32_t status = 0;
     306                 :            :         int enqueue_status, dequeue_status;
     307                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
     308                 :          0 :         int is_sgl = sop->m_src->nb_segs > 1;
     309                 :            :         int ret = TEST_SUCCESS, is_oop = 0;
     310                 :            : 
     311                 :          0 :         ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
     312         [ #  # ]:          0 :         if (ctx_service_size < 0)
     313                 :            :                 return TEST_SKIPPED;
     314                 :            : 
     315                 :          0 :         ctx = malloc(ctx_service_size);
     316         [ #  # ]:          0 :         if (ctx == NULL)
     317                 :            :                 return TEST_FAILED;
     318                 :            : 
     319                 :            :         /* Both are enums, setting crypto_sess will suit any session type */
     320                 :          0 :         sess.crypto_sess = op->sym->session;
     321                 :            : 
     322                 :          0 :         ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
     323         [ #  # ]:          0 :         if (ret == -ENOTSUP) {
     324                 :            :                 ret = TEST_SKIPPED;
     325                 :          0 :                 goto exit;
     326         [ #  # ]:          0 :         } else if (ret) {
     327                 :            :                 ret = TEST_FAILED;
     328                 :          0 :                 goto exit;
     329                 :            :         }
     330                 :            : 
     331                 :          0 :         cipher_iv.iova = 0;
     332                 :          0 :         cipher_iv.va = NULL;
     333                 :          0 :         aad_auth_iv.iova = 0;
     334                 :          0 :         aad_auth_iv.va = NULL;
     335                 :          0 :         digest.iova = 0;
     336                 :          0 :         digest.va = NULL;
     337                 :          0 :         sgl.vec = data_vec;
     338                 :          0 :         vec.num = 1;
     339                 :          0 :         vec.src_sgl = &sgl;
     340                 :          0 :         vec.iv = &cipher_iv;
     341                 :          0 :         vec.digest = &digest;
     342                 :          0 :         vec.aad = &aad_auth_iv;
     343                 :          0 :         vec.status = &status;
     344                 :            : 
     345                 :          0 :         ofs.raw = 0;
     346                 :            : 
     347   [ #  #  #  # ]:          0 :         if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
     348                 :            :                 is_oop = 1;
     349                 :            : 
     350         [ #  # ]:          0 :         if (is_cipher && is_auth) {
     351                 :          0 :                 cipher_offset = sop->cipher.data.offset;
     352                 :          0 :                 cipher_len = sop->cipher.data.length;
     353                 :          0 :                 auth_offset = sop->auth.data.offset;
     354                 :          0 :                 auth_len = sop->auth.data.length;
     355                 :          0 :                 max_len = RTE_MAX(cipher_offset + cipher_len,
     356                 :            :                                 auth_offset + auth_len);
     357         [ #  # ]:          0 :                 if (len_in_bits) {
     358                 :          0 :                         max_len = max_len >> 3;
     359                 :          0 :                         cipher_offset = cipher_offset >> 3;
     360                 :          0 :                         auth_offset = auth_offset >> 3;
     361                 :          0 :                         cipher_len = cipher_len >> 3;
     362                 :          0 :                         auth_len = auth_len >> 3;
     363                 :            :                 }
     364                 :          0 :                 ofs.ofs.cipher.head = cipher_offset;
     365                 :          0 :                 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
     366                 :          0 :                 ofs.ofs.auth.head = auth_offset;
     367                 :          0 :                 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
     368                 :          0 :                 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
     369                 :          0 :                 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
     370                 :          0 :                 aad_auth_iv.va = rte_crypto_op_ctod_offset(
     371                 :            :                                 op, void *, IV_OFFSET + cipher_iv_len);
     372                 :          0 :                 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
     373                 :            :                                 cipher_iv_len);
     374                 :          0 :                 digest.va = (void *)sop->auth.digest.data;
     375                 :          0 :                 digest.iova = sop->auth.digest.phys_addr;
     376                 :            : 
     377         [ #  # ]:          0 :                 if (is_sgl) {
     378                 :          0 :                         uint32_t remaining_off = auth_offset + auth_len;
     379                 :          0 :                         struct rte_mbuf *sgl_buf = sop->m_src;
     380         [ #  # ]:          0 :                         if (is_oop)
     381                 :            :                                 sgl_buf = sop->m_dst;
     382                 :            : 
     383                 :          0 :                         while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
     384   [ #  #  #  # ]:          0 :                                         && sgl_buf->next != NULL) {
     385                 :          0 :                                 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
     386                 :            :                                 sgl_buf = sgl_buf->next;
     387                 :            :                         }
     388                 :            : 
     389                 :          0 :                         auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
     390                 :            :                                 sgl_buf, remaining_off);
     391                 :            :                 } else {
     392                 :          0 :                         auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
     393                 :          0 :                                                          auth_offset + auth_len;
     394                 :            :                 }
     395                 :            :                 /* Then check if digest-encrypted conditions are met */
     396   [ #  #  #  # ]:          0 :                 if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
     397         [ #  # ]:          0 :                                 (digest.iova == auth_end_iova) && is_sgl)
     398                 :          0 :                         max_len = RTE_MAX(max_len,
     399                 :            :                                 auth_offset + auth_len +
     400                 :            :                                 ut_params->auth_xform.auth.digest_length);
     401                 :            : 
     402         [ #  # ]:          0 :         } else if (is_cipher) {
     403                 :          0 :                 cipher_offset = sop->cipher.data.offset;
     404                 :          0 :                 cipher_len = sop->cipher.data.length;
     405                 :          0 :                 max_len = cipher_len + cipher_offset;
     406         [ #  # ]:          0 :                 if (len_in_bits) {
     407                 :          0 :                         max_len = max_len >> 3;
     408                 :          0 :                         cipher_offset = cipher_offset >> 3;
     409                 :          0 :                         cipher_len = cipher_len >> 3;
     410                 :            :                 }
     411                 :          0 :                 ofs.ofs.cipher.head = cipher_offset;
     412                 :          0 :                 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
     413                 :          0 :                 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
     414                 :          0 :                 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
     415                 :            : 
     416         [ #  # ]:          0 :         } else if (is_auth) {
     417                 :          0 :                 auth_offset = sop->auth.data.offset;
     418                 :          0 :                 auth_len = sop->auth.data.length;
     419                 :          0 :                 max_len = auth_len + auth_offset;
     420         [ #  # ]:          0 :                 if (len_in_bits) {
     421                 :          0 :                         max_len = max_len >> 3;
     422                 :          0 :                         auth_offset = auth_offset >> 3;
     423                 :          0 :                         auth_len = auth_len >> 3;
     424                 :            :                 }
     425                 :          0 :                 ofs.ofs.auth.head = auth_offset;
     426                 :          0 :                 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
     427                 :          0 :                 aad_auth_iv.va = rte_crypto_op_ctod_offset(
     428                 :            :                                 op, void *, IV_OFFSET + cipher_iv_len);
     429                 :          0 :                 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
     430                 :            :                                 cipher_iv_len);
     431                 :          0 :                 digest.va = (void *)sop->auth.digest.data;
     432                 :          0 :                 digest.iova = sop->auth.digest.phys_addr;
     433                 :            : 
     434                 :            :         } else { /* aead */
     435                 :          0 :                 cipher_offset = sop->aead.data.offset;
     436                 :          0 :                 cipher_len = sop->aead.data.length;
     437                 :          0 :                 max_len = cipher_len + cipher_offset;
     438         [ #  # ]:          0 :                 if (len_in_bits) {
     439                 :          0 :                         max_len = max_len >> 3;
     440                 :          0 :                         cipher_offset = cipher_offset >> 3;
     441                 :          0 :                         cipher_len = cipher_len >> 3;
     442                 :            :                 }
     443                 :          0 :                 ofs.ofs.cipher.head = cipher_offset;
     444                 :          0 :                 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
     445                 :          0 :                 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
     446                 :          0 :                 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
     447                 :          0 :                 aad_auth_iv.va = (void *)sop->aead.aad.data;
     448                 :          0 :                 aad_auth_iv.iova = sop->aead.aad.phys_addr;
     449                 :          0 :                 digest.va = (void *)sop->aead.digest.data;
     450                 :          0 :                 digest.iova = sop->aead.digest.phys_addr;
     451                 :            :         }
     452                 :            : 
     453                 :          0 :         n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
     454                 :            :                         data_vec, RTE_DIM(data_vec));
     455   [ #  #  #  # ]:          0 :         if (n < 0 || n > sop->m_src->nb_segs) {
     456                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     457                 :          0 :                 goto exit;
     458                 :            :         }
     459                 :            : 
     460                 :          0 :         sgl.num = n;
     461                 :            :         /* Out of place */
     462         [ #  # ]:          0 :         if (is_oop) {
     463                 :          0 :                 dest_sgl.vec = dest_data_vec;
     464                 :          0 :                 vec.dest_sgl = &dest_sgl;
     465                 :          0 :                 n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
     466                 :            :                                 dest_data_vec, RTE_DIM(dest_data_vec));
     467   [ #  #  #  # ]:          0 :                 if (n < 0 || n > sop->m_dst->nb_segs) {
     468                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     469                 :          0 :                         goto exit;
     470                 :            :                 }
     471                 :          0 :                 dest_sgl.num = n;
     472                 :            :         } else
     473                 :          0 :                 vec.dest_sgl = NULL;
     474                 :            : 
     475         [ #  # ]:          0 :         if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
     476                 :            :                         &enqueue_status) < 1) {
     477                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     478                 :          0 :                 goto exit;
     479                 :            :         }
     480                 :            : 
     481         [ #  # ]:          0 :         if (enqueue_status == 0) {
     482                 :          0 :                 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
     483         [ #  # ]:          0 :                 if (status < 0) {
     484                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     485                 :          0 :                         goto exit;
     486                 :            :                 }
     487         [ #  # ]:          0 :         } else if (enqueue_status < 0) {
     488                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     489                 :          0 :                 goto exit;
     490                 :            :         }
     491                 :            : 
     492                 :          0 :         n = n_success = 0;
     493   [ #  #  #  # ]:          0 :         while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
     494                 :          0 :                 n = rte_cryptodev_raw_dequeue_burst(ctx,
     495                 :            :                         NULL, 1, post_process_raw_dp_op,
     496                 :            :                                 (void **)&ret_op, 0, &n_success,
     497                 :            :                                 &dequeue_status);
     498         [ #  # ]:          0 :                 if (dequeue_status < 0) {
     499                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     500                 :          0 :                         goto exit;
     501                 :            :                 }
     502         [ #  # ]:          0 :                 if (n == 0)
     503                 :            :                         rte_pause();
     504                 :            :         }
     505                 :            : 
     506   [ #  #  #  # ]:          0 :         if (n == 1 && dequeue_status == 0) {
     507         [ #  # ]:          0 :                 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
     508                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     509                 :          0 :                         goto exit;
     510                 :            :                 }
     511                 :            :         }
     512                 :            : 
     513   [ #  #  #  # ]:          0 :         op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
     514         [ #  # ]:          0 :                         ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
     515         [ #  # ]:          0 :                         n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
     516                 :            :                                         RTE_CRYPTO_OP_STATUS_SUCCESS;
     517                 :            : 
     518                 :          0 : exit:
     519                 :          0 :         free(ctx);
     520                 :          0 :         return ret;
     521                 :            : }
     522                 :            : 
     523                 :            : static void
     524                 :          0 : process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
     525                 :            : {
     526                 :            :         int32_t n, st;
     527                 :            :         struct rte_crypto_sym_op *sop;
     528                 :            :         union rte_crypto_sym_ofs ofs;
     529                 :            :         struct rte_crypto_sgl sgl;
     530                 :          0 :         struct rte_crypto_sym_vec symvec = {0};
     531                 :            :         struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
     532                 :            :         struct rte_crypto_vec vec[UINT8_MAX];
     533                 :            : 
     534                 :            :         sop = op->sym;
     535                 :            : 
     536                 :          0 :         n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
     537                 :            :                 sop->aead.data.length, vec, RTE_DIM(vec));
     538                 :            : 
     539   [ #  #  #  # ]:          0 :         if (n < 0 || n != sop->m_src->nb_segs) {
     540                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     541                 :          0 :                 return;
     542                 :            :         }
     543                 :            : 
     544                 :          0 :         sgl.vec = vec;
     545                 :          0 :         sgl.num = n;
     546                 :          0 :         symvec.src_sgl = &sgl;
     547                 :          0 :         symvec.iv = &iv_ptr;
     548                 :          0 :         symvec.digest = &digest_ptr;
     549                 :          0 :         symvec.aad = &aad_ptr;
     550                 :          0 :         symvec.status = &st;
     551                 :          0 :         symvec.num = 1;
     552                 :            : 
     553                 :            :         /* for CPU crypto the IOVA address is not required */
     554                 :          0 :         iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
     555                 :          0 :         digest_ptr.va = (void *)sop->aead.digest.data;
     556                 :          0 :         aad_ptr.va = (void *)sop->aead.aad.data;
     557                 :            : 
     558                 :          0 :         ofs.raw = 0;
     559                 :            : 
     560                 :          0 :         n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
     561                 :            :                 &symvec);
     562                 :            : 
     563         [ #  # ]:          0 :         if (n != 1)
     564                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
     565                 :            :         else
     566                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
     567                 :            : }
     568                 :            : 
     569                 :            : static void
     570                 :          0 : process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
     571                 :            : {
     572                 :            :         int32_t n, st;
     573                 :            :         struct rte_crypto_sym_op *sop;
     574                 :            :         union rte_crypto_sym_ofs ofs;
     575                 :            :         struct rte_crypto_sgl sgl;
     576                 :          0 :         struct rte_crypto_sym_vec symvec = {0};
     577                 :            :         struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
     578                 :            :         struct rte_crypto_vec vec[UINT8_MAX];
     579                 :            : 
     580                 :            :         sop = op->sym;
     581                 :            : 
     582                 :          0 :         n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
     583                 :            :                 sop->auth.data.length, vec, RTE_DIM(vec));
     584                 :            : 
     585   [ #  #  #  # ]:          0 :         if (n < 0 || n != sop->m_src->nb_segs) {
     586                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     587                 :          0 :                 return;
     588                 :            :         }
     589                 :            : 
     590                 :          0 :         sgl.vec = vec;
     591                 :          0 :         sgl.num = n;
     592                 :          0 :         symvec.src_sgl = &sgl;
     593                 :          0 :         symvec.iv = &iv_ptr;
     594                 :          0 :         symvec.digest = &digest_ptr;
     595                 :          0 :         symvec.status = &st;
     596                 :          0 :         symvec.num = 1;
     597                 :            : 
     598                 :          0 :         iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
     599                 :          0 :         digest_ptr.va = (void *)sop->auth.digest.data;
     600                 :            : 
     601                 :          0 :         ofs.raw = 0;
     602                 :          0 :         ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
     603                 :          0 :         ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
     604                 :          0 :                 (sop->cipher.data.offset + sop->cipher.data.length);
     605                 :            : 
     606                 :          0 :         n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
     607                 :            :                 &symvec);
     608                 :            : 
     609         [ #  # ]:          0 :         if (n != 1)
     610                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
     611                 :            :         else
     612                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
     613                 :            : }
     614                 :            : 
     615                 :            : static struct rte_crypto_op *
     616                 :        118 : process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
     617                 :            : {
     618                 :            : 
     619         [ -  + ]:        118 :         RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
     620                 :            : 
     621         [ -  + ]:        118 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
     622                 :          0 :                 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
     623                 :          0 :                 return NULL;
     624                 :            :         }
     625                 :            : 
     626                 :        118 :         op = NULL;
     627                 :            : 
     628         [ -  + ]:        118 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
     629                 :            :                 rte_pause();
     630                 :            : 
     631         [ +  + ]:        118 :         if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
     632                 :         11 :                 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
     633                 :         11 :                 return NULL;
     634                 :            :         }
     635                 :            : 
     636                 :            :         return op;
     637                 :            : }
     638                 :            : 
     639                 :            : static int
     640                 :          1 : testsuite_setup(void)
     641                 :            : {
     642                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     643                 :            :         struct rte_cryptodev_info info;
     644                 :            :         uint32_t i = 0, nb_devs, dev_id;
     645                 :            :         uint16_t qp_id;
     646                 :            : 
     647                 :            :         memset(ts_params, 0, sizeof(*ts_params));
     648                 :            : 
     649                 :          1 :         ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
     650         [ +  - ]:          1 :         if (ts_params->mbuf_pool == NULL) {
     651                 :            :                 /* Not already created so create */
     652                 :          1 :                 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
     653                 :            :                                 "CRYPTO_MBUFPOOL",
     654                 :            :                                 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
     655                 :          1 :                                 rte_socket_id());
     656         [ -  + ]:          1 :                 if (ts_params->mbuf_pool == NULL) {
     657                 :          0 :                         RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
     658                 :          0 :                         return TEST_FAILED;
     659                 :            :                 }
     660                 :            :         }
     661                 :            : 
     662                 :          1 :         ts_params->large_mbuf_pool = rte_mempool_lookup(
     663                 :            :                         "CRYPTO_LARGE_MBUFPOOL");
     664         [ +  - ]:          1 :         if (ts_params->large_mbuf_pool == NULL) {
     665                 :            :                 /* Not already created so create */
     666                 :          1 :                 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
     667                 :            :                                 "CRYPTO_LARGE_MBUFPOOL",
     668                 :            :                                 1, 0, 0, LARGE_MBUF_SIZE,
     669                 :          1 :                                 rte_socket_id());
     670         [ -  + ]:          1 :                 if (ts_params->large_mbuf_pool == NULL) {
     671                 :          0 :                         RTE_LOG(ERR, USER1,
     672                 :            :                                 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
     673                 :          0 :                         return TEST_FAILED;
     674                 :            :                 }
     675                 :            :         }
     676                 :            : 
     677                 :          1 :         ts_params->op_mpool = rte_crypto_op_pool_create(
     678                 :            :                         "MBUF_CRYPTO_SYM_OP_POOL",
     679                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC,
     680                 :            :                         NUM_MBUFS, MBUF_CACHE_SIZE,
     681                 :            :                         DEFAULT_NUM_XFORMS *
     682                 :            :                         sizeof(struct rte_crypto_sym_xform) +
     683                 :            :                         MAXIMUM_IV_LENGTH,
     684                 :          1 :                         rte_socket_id());
     685         [ -  + ]:          1 :         if (ts_params->op_mpool == NULL) {
     686                 :          0 :                 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
     687                 :          0 :                 return TEST_FAILED;
     688                 :            :         }
     689                 :            : 
     690                 :          1 :         nb_devs = rte_cryptodev_count();
     691         [ -  + ]:          1 :         if (nb_devs < 1) {
     692                 :          0 :                 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
     693                 :          0 :                 return TEST_SKIPPED;
     694                 :            :         }
     695                 :            : 
     696         [ -  + ]:          1 :         if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
     697                 :          0 :                 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
     698                 :            :                                 rte_cryptodev_driver_name_get(gbl_driver_id));
     699                 :          0 :                 return TEST_SKIPPED;
     700                 :            :         }
     701                 :            : 
     702                 :            :         /* Create list of valid crypto devs */
     703         [ +  + ]:          2 :         for (i = 0; i < nb_devs; i++) {
     704                 :          1 :                 rte_cryptodev_info_get(i, &info);
     705         [ +  - ]:          1 :                 if (info.driver_id == gbl_driver_id)
     706                 :          1 :                         ts_params->valid_devs[ts_params->valid_dev_count++] = i;
     707                 :            :         }
     708                 :            : 
     709         [ +  - ]:          1 :         if (ts_params->valid_dev_count < 1)
     710                 :            :                 return TEST_FAILED;
     711                 :            : 
     712                 :            :         /* Set up all the qps on the first of the valid devices found */
     713                 :            : 
     714                 :          1 :         dev_id = ts_params->valid_devs[0];
     715                 :            : 
     716                 :          1 :         rte_cryptodev_info_get(dev_id, &info);
     717                 :            : 
     718                 :          1 :         ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
     719                 :          1 :         ts_params->conf.socket_id = SOCKET_ID_ANY;
     720                 :          1 :         ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
     721                 :            : 
     722                 :            :         unsigned int session_size =
     723                 :          1 :                 rte_cryptodev_sym_get_private_session_size(dev_id);
     724                 :            : 
     725                 :            : #ifdef RTE_LIB_SECURITY
     726                 :          1 :         unsigned int security_session_size = rte_security_session_get_size(
     727                 :            :                         rte_cryptodev_get_sec_ctx(dev_id));
     728                 :            : 
     729                 :            :         if (session_size < security_session_size)
     730                 :            :                 session_size = security_session_size;
     731                 :            : #endif
     732                 :            :         /*
     733                 :            :          * Create mempool with maximum number of sessions.
     734                 :            :          */
     735         [ -  + ]:          1 :         if (info.sym.max_nb_sessions != 0 &&
     736                 :            :                         info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
     737                 :          0 :                 RTE_LOG(ERR, USER1, "Device does not support "
     738                 :            :                                 "at least %u sessions\n",
     739                 :            :                                 MAX_NB_SESSIONS);
     740                 :          0 :                 return TEST_FAILED;
     741                 :            :         }
     742                 :            : 
     743                 :          1 :         ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
     744                 :            :                         "test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
     745                 :            :                         SOCKET_ID_ANY);
     746         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
     747                 :            :                         "session mempool allocation failed");
     748                 :            : 
     749         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
     750                 :            :                         &ts_params->conf),
     751                 :            :                         "Failed to configure cryptodev %u with %u qps",
     752                 :            :                         dev_id, ts_params->conf.nb_queue_pairs);
     753                 :            : 
     754                 :          1 :         ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
     755                 :          1 :         ts_params->qp_conf.mp_session = ts_params->session_mpool;
     756                 :            : 
     757         [ +  + ]:          9 :         for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
     758         [ -  + ]:          8 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
     759                 :            :                         dev_id, qp_id, &ts_params->qp_conf,
     760                 :            :                         rte_cryptodev_socket_id(dev_id)),
     761                 :            :                         "Failed to setup queue pair %u on cryptodev %u",
     762                 :            :                         qp_id, dev_id);
     763                 :            :         }
     764                 :            : 
     765                 :            :         return TEST_SUCCESS;
     766                 :            : }
     767                 :            : 
     768                 :            : static void
     769                 :          1 : testsuite_teardown(void)
     770                 :            : {
     771                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     772                 :            :         int res;
     773                 :            : 
     774         [ +  - ]:          1 :         if (ts_params->large_mbuf_pool != NULL) {
     775                 :          1 :                 rte_mempool_free(ts_params->large_mbuf_pool);
     776                 :          1 :                 ts_params->large_mbuf_pool = NULL;
     777                 :            :         }
     778                 :            : 
     779         [ +  - ]:          1 :         if (ts_params->mbuf_pool != NULL) {
     780                 :          1 :                 rte_mempool_free(ts_params->mbuf_pool);
     781                 :          1 :                 ts_params->mbuf_pool = NULL;
     782                 :            :         }
     783                 :            : 
     784         [ +  - ]:          1 :         if (ts_params->op_mpool != NULL) {
     785                 :          1 :                 rte_mempool_free(ts_params->op_mpool);
     786                 :          1 :                 ts_params->op_mpool = NULL;
     787                 :            :         }
     788                 :            : 
     789         [ +  - ]:          1 :         if (ts_params->session_mpool != NULL) {
     790                 :          1 :                 rte_mempool_free(ts_params->session_mpool);
     791                 :          1 :                 ts_params->session_mpool = NULL;
     792                 :            :         }
     793                 :            : 
     794                 :          1 :         res = rte_cryptodev_close(ts_params->valid_devs[0]);
     795         [ -  + ]:          1 :         if (res)
     796                 :          0 :                 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
     797                 :          1 : }
     798                 :            : 
     799                 :            : static int
     800                 :         40 : check_capabilities_supported(enum rte_crypto_sym_xform_type type,
     801                 :            :                 const int *algs, uint16_t num_algs)
     802                 :            : {
     803                 :         40 :         uint8_t dev_id = testsuite_params.valid_devs[0];
     804                 :            :         bool some_alg_supported = false;
     805                 :            :         uint16_t i;
     806                 :            : 
     807         [ +  + ]:        110 :         for (i = 0; i < num_algs && !some_alg_supported; i++) {
     808                 :         70 :                 struct rte_cryptodev_sym_capability_idx alg = {
     809                 :         70 :                         type, {algs[i]}
     810                 :            :                 };
     811         [ +  + ]:         70 :                 if (rte_cryptodev_sym_capability_get(dev_id,
     812                 :            :                                 &alg) != NULL)
     813                 :            :                         some_alg_supported = true;
     814                 :            :         }
     815         [ +  + ]:         40 :         if (!some_alg_supported)
     816                 :         23 :                 return TEST_SKIPPED;
     817                 :            : 
     818                 :            :         return 0;
     819                 :            : }
     820                 :            : 
     821                 :            : int
     822                 :          9 : check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
     823                 :            :                 uint16_t num_ciphers)
     824                 :            : {
     825                 :         20 :         return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
     826                 :            :                         (const int *) ciphers, num_ciphers);
     827                 :            : }
     828                 :            : 
     829                 :            : int
     830                 :          2 : check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
     831                 :            :                 uint16_t num_auths)
     832                 :            : {
     833                 :         12 :         return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
     834                 :            :                         (const int *) auths, num_auths);
     835                 :            : }
     836                 :            : 
     837                 :            : int
     838                 :          0 : check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
     839                 :            :                 uint16_t num_aeads)
     840                 :            : {
     841                 :          8 :         return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
     842                 :            :                         (const int *) aeads, num_aeads);
     843                 :            : }
     844                 :            : 
     845                 :            : static int
     846                 :          1 : null_testsuite_setup(void)
     847                 :            : {
     848                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     849                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     850                 :            :         struct rte_cryptodev_info dev_info;
     851                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
     852                 :            :                 RTE_CRYPTO_CIPHER_NULL
     853                 :            :         };
     854                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
     855                 :            :                 RTE_CRYPTO_AUTH_NULL
     856                 :            :         };
     857                 :            : 
     858                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
     859                 :            : 
     860         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
     861                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
     862                 :            :                                 "testsuite not met\n");
     863                 :          0 :                 return TEST_SKIPPED;
     864                 :            :         }
     865                 :            : 
     866         [ +  - ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
     867         [ +  - ]:          1 :                         && check_auth_capabilities_supported(auths,
     868                 :            :                         RTE_DIM(auths)) != 0) {
     869                 :          1 :                 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
     870                 :            :                                 "testsuite not met\n");
     871                 :          1 :                 return TEST_SKIPPED;
     872                 :            :         }
     873                 :            : 
     874                 :            :         return 0;
     875                 :            : }
     876                 :            : 
     877                 :            : static int
     878                 :          1 : crypto_gen_testsuite_setup(void)
     879                 :            : {
     880                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     881                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     882                 :            :         struct rte_cryptodev_info dev_info;
     883                 :            : 
     884                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
     885                 :            : 
     886         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
     887                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
     888                 :            :                                 "testsuite not met\n");
     889                 :          0 :                 return TEST_SKIPPED;
     890                 :            :         }
     891                 :            : 
     892                 :            :         return 0;
     893                 :            : }
     894                 :            : 
     895                 :            : #ifdef RTE_LIB_SECURITY
     896                 :            : static int
     897                 :          4 : sec_proto_testsuite_setup(enum rte_security_session_protocol protocol)
     898                 :            : {
     899                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     900                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
     901                 :            :         struct rte_cryptodev_info dev_info;
     902                 :            :         int ret = 0;
     903                 :            : 
     904                 :          4 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
     905                 :            : 
     906         [ +  - ]:          4 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
     907                 :          4 :                 RTE_LOG(INFO, USER1,
     908                 :            :                         "Feature flag requirements for security protocol testsuite not met\n");
     909                 :          4 :                 return TEST_SKIPPED;
     910                 :            :         }
     911                 :            : 
     912                 :            :         /* Reconfigure to enable security */
     913                 :          0 :         ret = dev_configure_and_start(0);
     914         [ #  # ]:          0 :         if (ret != TEST_SUCCESS)
     915                 :            :                 return ret;
     916                 :            : 
     917                 :            :         /* Set action type */
     918                 :          0 :         ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
     919                 :            : 
     920         [ #  # ]:          0 :         if (security_proto_supported(RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, protocol) < 0) {
     921                 :          0 :                 RTE_LOG(INFO, USER1,
     922                 :            :                         "Capability requirements for security protocol test not met\n");
     923                 :            :                 ret = TEST_SKIPPED;
     924                 :            :         }
     925                 :            : 
     926                 :          0 :         test_sec_alg_list_populate();
     927                 :          0 :         test_sec_auth_only_alg_list_populate();
     928                 :            : 
     929                 :            :         /*
     930                 :            :          * Stop the device. Device would be started again by individual test
     931                 :            :          * case setup routine.
     932                 :            :          */
     933                 :          0 :         rte_cryptodev_stop(ts_params->valid_devs[0]);
     934                 :            : 
     935                 :          0 :         return ret;
     936                 :            : }
     937                 :            : 
     938                 :            : static int
     939                 :          1 : ipsec_proto_testsuite_setup(void)
     940                 :            : {
     941                 :          1 :         return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_IPSEC);
     942                 :            : }
     943                 :            : 
     944                 :            : static int
     945                 :          3 : tls_record_proto_testsuite_setup(void)
     946                 :            : {
     947                 :          3 :         test_sec_proto_pattern_generate();
     948                 :            : 
     949                 :          3 :         return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_TLS_RECORD);
     950                 :            : }
     951                 :            : 
     952                 :            : static int
     953                 :          1 : pdcp_proto_testsuite_setup(void)
     954                 :            : {
     955                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     956                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     957                 :            :         struct rte_cryptodev_info dev_info;
     958                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
     959                 :            :                 RTE_CRYPTO_CIPHER_NULL,
     960                 :            :                 RTE_CRYPTO_CIPHER_AES_CTR,
     961                 :            :                 RTE_CRYPTO_CIPHER_ZUC_EEA3,
     962                 :            :                 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
     963                 :            :         };
     964                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
     965                 :            :                 RTE_CRYPTO_AUTH_NULL,
     966                 :            :                 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
     967                 :            :                 RTE_CRYPTO_AUTH_AES_CMAC,
     968                 :            :                 RTE_CRYPTO_AUTH_ZUC_EIA3
     969                 :            :         };
     970                 :            : 
     971                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
     972                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
     973                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
     974                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
     975                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
     976                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
     977                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
     978                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
     979                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
     980                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
     981                 :            : 
     982                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
     983                 :            : 
     984         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
     985                 :            :                         !(dev_info.feature_flags &
     986                 :            :                         RTE_CRYPTODEV_FF_SECURITY)) {
     987                 :          1 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
     988                 :            :                                 "testsuite not met\n");
     989                 :          1 :                 return TEST_SKIPPED;
     990                 :            :         }
     991                 :            : 
     992         [ #  # ]:          0 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
     993         [ #  # ]:          0 :                         && check_auth_capabilities_supported(auths,
     994                 :            :                         RTE_DIM(auths)) != 0) {
     995                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
     996                 :            :                                 "testsuite not met\n");
     997                 :          0 :                 return TEST_SKIPPED;
     998                 :            :         }
     999                 :            : 
    1000                 :            :         return 0;
    1001                 :            : }
    1002                 :            : 
    1003                 :            : static int
    1004                 :          1 : docsis_proto_testsuite_setup(void)
    1005                 :            : {
    1006                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1007                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1008                 :            :         struct rte_cryptodev_info dev_info;
    1009                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1010                 :            :                 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
    1011                 :            :         };
    1012                 :            : 
    1013                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1014                 :            : 
    1015         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1016                 :            :                         !(dev_info.feature_flags &
    1017                 :            :                         RTE_CRYPTODEV_FF_SECURITY)) {
    1018                 :          1 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
    1019                 :            :                                 "Proto testsuite not met\n");
    1020                 :          1 :                 return TEST_SKIPPED;
    1021                 :            :         }
    1022                 :            : 
    1023         [ #  # ]:          0 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
    1024                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
    1025                 :            :                                 "testsuite not met\n");
    1026                 :          0 :                 return TEST_SKIPPED;
    1027                 :            :         }
    1028                 :            : 
    1029                 :            :         return 0;
    1030                 :            : }
    1031                 :            : #endif
    1032                 :            : 
    1033                 :            : static int
    1034                 :          1 : aes_ccm_auth_testsuite_setup(void)
    1035                 :            : {
    1036                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1037                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1038                 :            :         struct rte_cryptodev_info dev_info;
    1039                 :          1 :         const enum rte_crypto_aead_algorithm aeads[] = {
    1040                 :            :                 RTE_CRYPTO_AEAD_AES_CCM
    1041                 :            :         };
    1042                 :            : 
    1043                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1044                 :            : 
    1045         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1046         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1047         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1048                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
    1049                 :            :                                 "testsuite not met\n");
    1050                 :          0 :                 return TEST_SKIPPED;
    1051                 :            :         }
    1052                 :            : 
    1053         [ -  + ]:          1 :         if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
    1054                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
    1055                 :            :                                 "testsuite not met\n");
    1056                 :          0 :                 return TEST_SKIPPED;
    1057                 :            :         }
    1058                 :            : 
    1059                 :            :         return 0;
    1060                 :            : }
    1061                 :            : 
    1062                 :            : static int
    1063                 :          1 : aes_gcm_auth_testsuite_setup(void)
    1064                 :            : {
    1065                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1066                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1067                 :            :         struct rte_cryptodev_info dev_info;
    1068                 :          1 :         const enum rte_crypto_aead_algorithm aeads[] = {
    1069                 :            :                 RTE_CRYPTO_AEAD_AES_GCM
    1070                 :            :         };
    1071                 :            : 
    1072                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1073                 :            : 
    1074         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
    1075                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
    1076                 :            :                                 "testsuite not met\n");
    1077                 :          0 :                 return TEST_SKIPPED;
    1078                 :            :         }
    1079                 :            : 
    1080         [ -  + ]:          1 :         if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
    1081                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
    1082                 :            :                                 "testsuite not met\n");
    1083                 :          0 :                 return TEST_SKIPPED;
    1084                 :            :         }
    1085                 :            : 
    1086                 :            :         return 0;
    1087                 :            : }
    1088                 :            : 
    1089                 :            : static int
    1090                 :          1 : aes_gmac_auth_testsuite_setup(void)
    1091                 :            : {
    1092                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1093                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1094                 :            :         struct rte_cryptodev_info dev_info;
    1095                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1096                 :            :                 RTE_CRYPTO_AUTH_AES_GMAC
    1097                 :            :         };
    1098                 :            : 
    1099                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1100                 :            : 
    1101         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1102         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1103         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1104                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
    1105                 :            :                                 "testsuite not met\n");
    1106                 :          0 :                 return TEST_SKIPPED;
    1107                 :            :         }
    1108                 :            : 
    1109         [ -  + ]:          1 :         if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
    1110                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
    1111                 :            :                                 "testsuite not met\n");
    1112                 :          0 :                 return TEST_SKIPPED;
    1113                 :            :         }
    1114                 :            : 
    1115                 :            :         return 0;
    1116                 :            : }
    1117                 :            : 
    1118                 :            : static int
    1119                 :          1 : chacha20_poly1305_testsuite_setup(void)
    1120                 :            : {
    1121                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1122                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1123                 :            :         struct rte_cryptodev_info dev_info;
    1124                 :          1 :         const enum rte_crypto_aead_algorithm aeads[] = {
    1125                 :            :                 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
    1126                 :            :         };
    1127                 :            : 
    1128                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1129                 :            : 
    1130         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1131         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1132         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1133                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for "
    1134                 :            :                                 "Chacha20-Poly1305 testsuite not met\n");
    1135                 :          0 :                 return TEST_SKIPPED;
    1136                 :            :         }
    1137                 :            : 
    1138         [ +  - ]:          1 :         if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
    1139                 :          1 :                 RTE_LOG(INFO, USER1, "Capability requirements for "
    1140                 :            :                                 "Chacha20-Poly1305 testsuite not met\n");
    1141                 :          1 :                 return TEST_SKIPPED;
    1142                 :            :         }
    1143                 :            : 
    1144                 :            :         return 0;
    1145                 :            : }
    1146                 :            : 
    1147                 :            : static int
    1148                 :          1 : sm4_gcm_testsuite_setup(void)
    1149                 :            : {
    1150                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1151                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1152                 :            :         struct rte_cryptodev_info dev_info;
    1153                 :          1 :         const enum rte_crypto_aead_algorithm aeads[] = {
    1154                 :            :                 RTE_CRYPTO_AEAD_SM4_GCM
    1155                 :            :         };
    1156                 :            : 
    1157                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1158                 :            : 
    1159         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1160         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1161         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1162                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for "
    1163                 :            :                                 "SM4 GCM testsuite not met\n");
    1164                 :          0 :                 return TEST_SKIPPED;
    1165                 :            :         }
    1166                 :            : 
    1167         [ +  - ]:          1 :         if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
    1168                 :          1 :                 RTE_LOG(INFO, USER1, "Capability requirements for "
    1169                 :            :                                 "SM4 GCM testsuite not met\n");
    1170                 :          1 :                 return TEST_SKIPPED;
    1171                 :            :         }
    1172                 :            : 
    1173                 :            :         return 0;
    1174                 :            : }
    1175                 :            : 
    1176                 :            : static int
    1177                 :          1 : snow3g_testsuite_setup(void)
    1178                 :            : {
    1179                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1180                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1181                 :            :         struct rte_cryptodev_info dev_info;
    1182                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1183                 :            :                 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
    1184                 :            : 
    1185                 :            :         };
    1186                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1187                 :            :                 RTE_CRYPTO_AUTH_SNOW3G_UIA2
    1188                 :            :         };
    1189                 :            : 
    1190                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1191                 :            : 
    1192         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
    1193                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
    1194                 :            :                                 "testsuite not met\n");
    1195                 :          0 :                 return TEST_SKIPPED;
    1196                 :            :         }
    1197                 :            : 
    1198         [ +  - ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1199         [ +  - ]:          1 :                         && check_auth_capabilities_supported(auths,
    1200                 :            :                         RTE_DIM(auths)) != 0) {
    1201                 :          1 :                 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
    1202                 :            :                                 "testsuite not met\n");
    1203                 :          1 :                 return TEST_SKIPPED;
    1204                 :            :         }
    1205                 :            : 
    1206                 :            :         return 0;
    1207                 :            : }
    1208                 :            : 
    1209                 :            : static int
    1210                 :          1 : zuc_testsuite_setup(void)
    1211                 :            : {
    1212                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1213                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1214                 :            :         struct rte_cryptodev_info dev_info;
    1215                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1216                 :            :                 RTE_CRYPTO_CIPHER_ZUC_EEA3
    1217                 :            :         };
    1218                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1219                 :            :                 RTE_CRYPTO_AUTH_ZUC_EIA3
    1220                 :            :         };
    1221                 :            : 
    1222                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1223                 :            : 
    1224         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
    1225                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
    1226                 :            :                                 "testsuite not met\n");
    1227                 :          0 :                 return TEST_SKIPPED;
    1228                 :            :         }
    1229                 :            : 
    1230         [ +  - ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1231         [ +  - ]:          1 :                         && check_auth_capabilities_supported(auths,
    1232                 :            :                         RTE_DIM(auths)) != 0) {
    1233                 :          1 :                 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
    1234                 :            :                                 "testsuite not met\n");
    1235                 :          1 :                 return TEST_SKIPPED;
    1236                 :            :         }
    1237                 :            : 
    1238                 :            :         return 0;
    1239                 :            : }
    1240                 :            : 
    1241                 :            : static int
    1242                 :          1 : hmac_md5_auth_testsuite_setup(void)
    1243                 :            : {
    1244                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1245                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1246                 :            :         struct rte_cryptodev_info dev_info;
    1247                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1248                 :            :                 RTE_CRYPTO_AUTH_MD5_HMAC
    1249                 :            :         };
    1250                 :            : 
    1251                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1252                 :            : 
    1253         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1254         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1255         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1256                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
    1257                 :            :                                 "Auth testsuite not met\n");
    1258                 :          0 :                 return TEST_SKIPPED;
    1259                 :            :         }
    1260                 :            : 
    1261         [ -  + ]:          1 :         if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
    1262                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
    1263                 :            :                                 "testsuite not met\n");
    1264                 :          0 :                 return TEST_SKIPPED;
    1265                 :            :         }
    1266                 :            : 
    1267                 :            :         return 0;
    1268                 :            : }
    1269                 :            : 
    1270                 :            : static int
    1271                 :          1 : kasumi_testsuite_setup(void)
    1272                 :            : {
    1273                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1274                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1275                 :            :         struct rte_cryptodev_info dev_info;
    1276                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1277                 :            :                 RTE_CRYPTO_CIPHER_KASUMI_F8
    1278                 :            :         };
    1279                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1280                 :            :                 RTE_CRYPTO_AUTH_KASUMI_F9
    1281                 :            :         };
    1282                 :            : 
    1283                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1284                 :            : 
    1285         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1286         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1287         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1288                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
    1289                 :            :                                 "testsuite not met\n");
    1290                 :          0 :                 return TEST_SKIPPED;
    1291                 :            :         }
    1292                 :            : 
    1293         [ +  - ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1294         [ +  - ]:          1 :                         && check_auth_capabilities_supported(auths,
    1295                 :            :                         RTE_DIM(auths)) != 0) {
    1296                 :          1 :                 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
    1297                 :            :                                 "testsuite not met\n");
    1298                 :          1 :                 return TEST_SKIPPED;
    1299                 :            :         }
    1300                 :            : 
    1301                 :            :         return 0;
    1302                 :            : }
    1303                 :            : 
    1304                 :            : static int
    1305                 :          1 : negative_aes_gcm_testsuite_setup(void)
    1306                 :            : {
    1307                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1308                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1309                 :            :         struct rte_cryptodev_info dev_info;
    1310                 :          1 :         const enum rte_crypto_aead_algorithm aeads[] = {
    1311                 :            :                 RTE_CRYPTO_AEAD_AES_GCM
    1312                 :            :         };
    1313                 :            : 
    1314                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1315                 :            : 
    1316         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1317         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1318         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1319                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
    1320                 :            :                                 "AES GCM testsuite not met\n");
    1321                 :          0 :                 return TEST_SKIPPED;
    1322                 :            :         }
    1323                 :            : 
    1324         [ -  + ]:          1 :         if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
    1325                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
    1326                 :            :                                 "AES GCM testsuite not met\n");
    1327                 :          0 :                 return TEST_SKIPPED;
    1328                 :            :         }
    1329                 :            : 
    1330                 :            :         return 0;
    1331                 :            : }
    1332                 :            : 
    1333                 :            : static int
    1334                 :          1 : negative_aes_gmac_testsuite_setup(void)
    1335                 :            : {
    1336                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1337                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1338                 :            :         struct rte_cryptodev_info dev_info;
    1339                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1340                 :            :                 RTE_CRYPTO_AUTH_AES_GMAC
    1341                 :            :         };
    1342                 :            : 
    1343                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1344                 :            : 
    1345         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1346         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1347         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1348                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
    1349                 :            :                                 "AES GMAC testsuite not met\n");
    1350                 :          0 :                 return TEST_SKIPPED;
    1351                 :            :         }
    1352                 :            : 
    1353         [ -  + ]:          1 :         if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
    1354                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
    1355                 :            :                                 "AES GMAC testsuite not met\n");
    1356                 :          0 :                 return TEST_SKIPPED;
    1357                 :            :         }
    1358                 :            : 
    1359                 :            :         return 0;
    1360                 :            : }
    1361                 :            : 
    1362                 :            : static int
    1363                 :          1 : mixed_cipher_hash_testsuite_setup(void)
    1364                 :            : {
    1365                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1366                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1367                 :            :         struct rte_cryptodev_info dev_info;
    1368                 :            :         uint64_t feat_flags;
    1369                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1370                 :            :                 RTE_CRYPTO_CIPHER_NULL,
    1371                 :            :                 RTE_CRYPTO_CIPHER_AES_CTR,
    1372                 :            :                 RTE_CRYPTO_CIPHER_ZUC_EEA3,
    1373                 :            :                 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
    1374                 :            :         };
    1375                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1376                 :            :                 RTE_CRYPTO_AUTH_NULL,
    1377                 :            :                 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
    1378                 :            :                 RTE_CRYPTO_AUTH_AES_CMAC,
    1379                 :            :                 RTE_CRYPTO_AUTH_ZUC_EIA3
    1380                 :            :         };
    1381                 :            : 
    1382                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1383                 :          1 :         feat_flags = dev_info.feature_flags;
    1384                 :            : 
    1385         [ +  - ]:          1 :         if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1386         [ -  + ]:          1 :                         (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
    1387                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
    1388                 :            :                                 "Cipher Hash testsuite not met\n");
    1389                 :          0 :                 return TEST_SKIPPED;
    1390                 :            :         }
    1391                 :            : 
    1392         [ -  + ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1393         [ #  # ]:          0 :                         && check_auth_capabilities_supported(auths,
    1394                 :            :                         RTE_DIM(auths)) != 0) {
    1395                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
    1396                 :            :                                 "Cipher Hash testsuite not met\n");
    1397                 :          0 :                 return TEST_SKIPPED;
    1398                 :            :         }
    1399                 :            : 
    1400                 :            :         return 0;
    1401                 :            : }
    1402                 :            : 
    1403                 :            : static int
    1404                 :          1 : esn_testsuite_setup(void)
    1405                 :            : {
    1406                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1407                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1408                 :            :         struct rte_cryptodev_info dev_info;
    1409                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1410                 :            :                 RTE_CRYPTO_CIPHER_AES_CBC
    1411                 :            :         };
    1412                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1413                 :            :                 RTE_CRYPTO_AUTH_SHA1_HMAC
    1414                 :            :         };
    1415                 :            : 
    1416                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1417                 :            : 
    1418         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1419         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1420         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1421                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
    1422                 :            :                                 "testsuite not met\n");
    1423                 :          0 :                 return TEST_SKIPPED;
    1424                 :            :         }
    1425                 :            : 
    1426         [ -  + ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1427         [ #  # ]:          0 :                         && check_auth_capabilities_supported(auths,
    1428                 :            :                         RTE_DIM(auths)) != 0) {
    1429                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
    1430                 :            :                                 "testsuite not met\n");
    1431                 :          0 :                 return TEST_SKIPPED;
    1432                 :            :         }
    1433                 :            : 
    1434                 :            :         return 0;
    1435                 :            : }
    1436                 :            : 
    1437                 :            : static int
    1438                 :          1 : multi_session_testsuite_setup(void)
    1439                 :            : {
    1440                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1441                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1442                 :            :         struct rte_cryptodev_info dev_info;
    1443                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1444                 :            :                 RTE_CRYPTO_CIPHER_AES_CBC
    1445                 :            :         };
    1446                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1447                 :            :                 RTE_CRYPTO_AUTH_SHA512_HMAC
    1448                 :            :         };
    1449                 :            : 
    1450                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1451                 :            : 
    1452         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
    1453                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
    1454                 :            :                                 "Session testsuite not met\n");
    1455                 :          0 :                 return TEST_SKIPPED;
    1456                 :            :         }
    1457                 :            : 
    1458         [ -  + ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1459         [ #  # ]:          0 :                         && check_auth_capabilities_supported(auths,
    1460                 :            :                         RTE_DIM(auths)) != 0) {
    1461                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
    1462                 :            :                                 "Session testsuite not met\n");
    1463                 :          0 :                 return TEST_SKIPPED;
    1464                 :            :         }
    1465                 :            : 
    1466                 :            :         return 0;
    1467                 :            : }
    1468                 :            : 
    1469                 :            : static int
    1470                 :          1 : negative_hmac_sha1_testsuite_setup(void)
    1471                 :            : {
    1472                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1473                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1474                 :            :         struct rte_cryptodev_info dev_info;
    1475                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1476                 :            :                 RTE_CRYPTO_CIPHER_AES_CBC
    1477                 :            :         };
    1478                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1479                 :            :                 RTE_CRYPTO_AUTH_SHA1_HMAC
    1480                 :            :         };
    1481                 :            : 
    1482                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1483                 :            : 
    1484         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1485         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1486         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1487                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
    1488                 :            :                                 "HMAC SHA1 testsuite not met\n");
    1489                 :          0 :                 return TEST_SKIPPED;
    1490                 :            :         }
    1491                 :            : 
    1492         [ -  + ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1493         [ #  # ]:          0 :                         && check_auth_capabilities_supported(auths,
    1494                 :            :                         RTE_DIM(auths)) != 0) {
    1495                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
    1496                 :            :                                 "HMAC SHA1 testsuite not met\n");
    1497                 :          0 :                 return TEST_SKIPPED;
    1498                 :            :         }
    1499                 :            : 
    1500                 :            :         return 0;
    1501                 :            : }
    1502                 :            : 
    1503                 :            : static int
    1504                 :        434 : dev_configure_and_start(uint64_t ff_disable)
    1505                 :            : {
    1506                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1507                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    1508                 :            : 
    1509                 :            :         uint16_t qp_id;
    1510                 :            : 
    1511                 :            :         /* Clear unit test parameters before running test */
    1512                 :            :         memset(ut_params, 0, sizeof(*ut_params));
    1513                 :            : 
    1514                 :            :         /* Reconfigure device to default parameters */
    1515                 :        434 :         ts_params->conf.socket_id = SOCKET_ID_ANY;
    1516                 :        434 :         ts_params->conf.ff_disable = ff_disable;
    1517                 :        434 :         ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
    1518                 :        434 :         ts_params->qp_conf.mp_session = ts_params->session_mpool;
    1519                 :            : 
    1520         [ -  + ]:        434 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
    1521                 :            :                         &ts_params->conf),
    1522                 :            :                         "Failed to configure cryptodev %u",
    1523                 :            :                         ts_params->valid_devs[0]);
    1524                 :            : 
    1525         [ +  + ]:       3906 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
    1526         [ -  + ]:       3472 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
    1527                 :            :                         ts_params->valid_devs[0], qp_id,
    1528                 :            :                         &ts_params->qp_conf,
    1529                 :            :                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
    1530                 :            :                         "Failed to setup queue pair %u on cryptodev %u",
    1531                 :            :                         qp_id, ts_params->valid_devs[0]);
    1532                 :            :         }
    1533                 :            : 
    1534                 :            : 
    1535                 :        434 :         rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
    1536                 :            : 
    1537                 :            :         /* Start the device */
    1538         [ -  + ]:        434 :         TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
    1539                 :            :                         "Failed to start cryptodev %u",
    1540                 :            :                         ts_params->valid_devs[0]);
    1541                 :            : 
    1542                 :            :         return TEST_SUCCESS;
    1543                 :            : }
    1544                 :            : 
    1545                 :            : int
    1546                 :        434 : ut_setup(void)
    1547                 :            : {
    1548                 :            :         /* Configure and start the device with security feature disabled */
    1549                 :        434 :         return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
    1550                 :            : }
    1551                 :            : 
    1552                 :            : static int
    1553                 :          0 : ut_setup_security(void)
    1554                 :            : {
    1555                 :            :         /* Configure and start the device with no features disabled */
    1556                 :          0 :         return dev_configure_and_start(0);
    1557                 :            : }
    1558                 :            : 
    1559                 :            : static int
    1560                 :          0 : ut_setup_security_rx_inject(void)
    1561                 :            : {
    1562                 :          0 :         struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
    1563                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1564                 :          0 :         struct rte_eth_conf port_conf = {
    1565                 :            :                 .rxmode = {
    1566                 :            :                         .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
    1567                 :            :                                     RTE_ETH_RX_OFFLOAD_SECURITY,
    1568                 :            :                 },
    1569                 :            :                 .txmode = {
    1570                 :            :                         .offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
    1571                 :            :                 },
    1572                 :            :                 .lpbk_mode = 1,  /* Enable loopback */
    1573                 :            :         };
    1574                 :            :         struct rte_cryptodev_info dev_info;
    1575                 :          0 :         struct rte_eth_rxconf rx_conf = {
    1576                 :            :                 .rx_thresh = {
    1577                 :            :                         .pthresh = 8,
    1578                 :            :                         .hthresh = 8,
    1579                 :            :                         .wthresh = 8,
    1580                 :            :                 },
    1581                 :            :                 .rx_free_thresh = 32,
    1582                 :            :         };
    1583                 :            :         uint16_t nb_ports;
    1584                 :            :         void *sec_ctx;
    1585                 :            :         int ret;
    1586                 :            : 
    1587                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    1588         [ #  # ]:          0 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
    1589                 :            :             !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
    1590                 :          0 :                 RTE_LOG(INFO, USER1,
    1591                 :            :                         "Feature requirements for IPsec Rx inject test case not met\n");
    1592                 :          0 :                 return TEST_SKIPPED;
    1593                 :            :         }
    1594                 :            : 
    1595                 :          0 :         sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
    1596         [ #  # ]:          0 :         if (sec_ctx == NULL)
    1597                 :            :                 return TEST_SKIPPED;
    1598                 :            : 
    1599                 :          0 :         nb_ports = rte_eth_dev_count_avail();
    1600         [ #  # ]:          0 :         if (nb_ports == 0)
    1601                 :            :                 return TEST_SKIPPED;
    1602                 :            : 
    1603                 :          0 :         ret = rte_eth_dev_configure(0 /* port_id */,
    1604                 :            :                                     1 /* nb_rx_queue */,
    1605                 :            :                                     0 /* nb_tx_queue */,
    1606                 :            :                                     &port_conf);
    1607         [ #  # ]:          0 :         if (ret) {
    1608                 :            :                 printf("Could not configure ethdev port 0 [err=%d]\n", ret);
    1609                 :          0 :                 return TEST_SKIPPED;
    1610                 :            :         }
    1611                 :            : 
    1612                 :            :         /* Rx queue setup */
    1613                 :          0 :         ret = rte_eth_rx_queue_setup(0 /* port_id */,
    1614                 :            :                                      0 /* rx_queue_id */,
    1615                 :            :                                      1024 /* nb_rx_desc */,
    1616                 :            :                                      SOCKET_ID_ANY,
    1617                 :            :                                      &rx_conf,
    1618                 :            :                                      mbuf_pool);
    1619         [ #  # ]:          0 :         if (ret) {
    1620                 :            :                 printf("Could not setup eth port 0 queue 0\n");
    1621                 :          0 :                 return TEST_SKIPPED;
    1622                 :            :         }
    1623                 :            : 
    1624                 :          0 :         ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
    1625         [ #  # ]:          0 :         if (ret) {
    1626                 :            :                 printf("Could not enable Rx inject offload");
    1627                 :          0 :                 return TEST_SKIPPED;
    1628                 :            :         }
    1629                 :            : 
    1630                 :          0 :         ret = rte_eth_dev_start(0);
    1631         [ #  # ]:          0 :         if (ret) {
    1632                 :            :                 printf("Could not start ethdev");
    1633                 :          0 :                 return TEST_SKIPPED;
    1634                 :            :         }
    1635                 :            : 
    1636                 :          0 :         ret = rte_eth_promiscuous_enable(0);
    1637         [ #  # ]:          0 :         if (ret) {
    1638                 :            :                 printf("Could not enable promiscuous mode");
    1639                 :          0 :                 return TEST_SKIPPED;
    1640                 :            :         }
    1641                 :            : 
    1642                 :            :         /* Configure and start cryptodev with no features disabled */
    1643                 :          0 :         return dev_configure_and_start(0);
    1644                 :            : }
    1645                 :            : 
    1646                 :            : static inline void
    1647                 :          0 : ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
    1648                 :            : {
    1649                 :          0 : }
    1650                 :            : 
    1651                 :            : static inline void
    1652                 :        110 : ext_mbuf_memzone_free(int nb_segs)
    1653                 :            : {
    1654                 :            :         int i;
    1655                 :            : 
    1656         [ +  + ]:        330 :         for (i = 0; i <= nb_segs; i++) {
    1657                 :            :                 char mz_name[RTE_MEMZONE_NAMESIZE];
    1658                 :            :                 const struct rte_memzone *memzone;
    1659                 :            :                 snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
    1660                 :        220 :                 memzone = rte_memzone_lookup(mz_name);
    1661         [ +  + ]:        220 :                 if (memzone != NULL) {
    1662                 :          2 :                         rte_memzone_free(memzone);
    1663                 :            :                         memzone = NULL;
    1664                 :            :                 }
    1665                 :            :         }
    1666                 :        110 : }
    1667                 :            : 
    1668                 :            : static inline struct rte_mbuf *
    1669                 :          2 : ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
    1670                 :            :                 int nb_segs, const void *input_text)
    1671                 :            : {
    1672                 :            :         struct rte_mbuf *m = NULL, *mbuf = NULL;
    1673                 :            :         size_t data_off = 0;
    1674                 :            :         uint8_t *dst;
    1675                 :            :         int i, size;
    1676                 :            :         int t_len;
    1677                 :            : 
    1678         [ -  + ]:          2 :         if (pkt_len < 1) {
    1679                 :            :                 printf("Packet size must be 1 or more (is %d)\n", pkt_len);
    1680                 :          0 :                 return NULL;
    1681                 :            :         }
    1682                 :            : 
    1683         [ -  + ]:          2 :         if (nb_segs < 1) {
    1684                 :            :                 printf("Number of segments must be 1 or more (is %d)\n",
    1685                 :            :                                 nb_segs);
    1686                 :          0 :                 return NULL;
    1687                 :            :         }
    1688                 :            : 
    1689         [ +  - ]:          2 :         t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
    1690                 :            :         size = pkt_len;
    1691                 :            : 
    1692                 :            :         /* Create chained mbuf_src with external buffer */
    1693         [ +  + ]:          4 :         for (i = 0; size > 0; i++) {
    1694                 :            :                 struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
    1695                 :          2 :                 uint16_t data_len = RTE_MIN(size, t_len);
    1696                 :            :                 char mz_name[RTE_MEMZONE_NAMESIZE];
    1697                 :            :                 const struct rte_memzone *memzone;
    1698                 :            :                 void *ext_buf_addr = NULL;
    1699                 :            :                 rte_iova_t buf_iova;
    1700                 :          2 :                 bool freed = false;
    1701                 :            :                 uint16_t buf_len;
    1702                 :            : 
    1703                 :          2 :                 buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
    1704                 :            :                         sizeof(struct rte_mbuf_ext_shared_info), 8);
    1705                 :            : 
    1706                 :            :                 snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
    1707                 :          2 :                 memzone = rte_memzone_lookup(mz_name);
    1708   [ -  +  -  - ]:          2 :                 if (memzone != NULL && memzone->len != buf_len) {
    1709                 :          0 :                         rte_memzone_free(memzone);
    1710                 :            :                         memzone = NULL;
    1711                 :            :                 }
    1712         [ +  - ]:          2 :                 if (memzone == NULL) {
    1713                 :          2 :                         memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
    1714                 :            :                                 RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
    1715         [ -  + ]:          2 :                         if (memzone == NULL) {
    1716                 :            :                                 printf("Can't allocate memory zone %s\n", mz_name);
    1717                 :          0 :                                 return NULL;
    1718                 :            :                         }
    1719                 :            :                 }
    1720                 :            : 
    1721                 :          2 :                 ext_buf_addr = memzone->addr;
    1722         [ -  + ]:          2 :                 if (input_text)
    1723                 :          0 :                         memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
    1724                 :            : 
    1725                 :            :                 /* Create buffer to hold rte_mbuf header */
    1726                 :          2 :                 m = rte_pktmbuf_alloc(mbuf_pool);
    1727         [ +  - ]:          2 :                 if (i == 0)
    1728                 :            :                         mbuf = m;
    1729                 :            : 
    1730         [ -  + ]:          2 :                 if (m == NULL) {
    1731                 :            :                         printf("Cannot create segment for source mbuf");
    1732                 :          0 :                         goto fail;
    1733                 :            :                 }
    1734                 :            : 
    1735                 :            :                 /* Save shared data (like callback function) in external buffer's end */
    1736                 :            :                 ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
    1737                 :            :                         ext_mbuf_callback_fn_free, &freed);
    1738                 :            :                 if (ret_shinfo == NULL) {
    1739                 :            :                         printf("Shared mem initialization failed!\n");
    1740                 :          0 :                         goto fail;
    1741                 :            :                 }
    1742                 :            : 
    1743                 :          2 :                 buf_iova = rte_mem_virt2iova(ext_buf_addr);
    1744                 :            : 
    1745                 :            :                 /* Attach external buffer to mbuf */
    1746                 :            :                 rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
    1747                 :            :                         ret_shinfo);
    1748         [ -  + ]:          2 :                 if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
    1749                 :            :                         printf("External buffer is not attached to mbuf\n");
    1750                 :          0 :                         goto fail;
    1751                 :            :                 }
    1752                 :            : 
    1753         [ -  + ]:          2 :                 if (input_text) {
    1754                 :            :                         dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
    1755         [ #  # ]:          0 :                         if (dst == NULL) {
    1756                 :            :                                 printf("Cannot append %d bytes to the mbuf\n", data_len);
    1757                 :          0 :                                 goto fail;
    1758                 :            :                         }
    1759                 :            :                 }
    1760                 :            : 
    1761         [ -  + ]:          2 :                 if (mbuf != m)
    1762                 :            :                         rte_pktmbuf_chain(mbuf, m);
    1763                 :            : 
    1764                 :          2 :                 size -= data_len;
    1765                 :          2 :                 data_off += data_len;
    1766                 :            :         }
    1767                 :            : 
    1768                 :            :         return mbuf;
    1769                 :            : 
    1770                 :            : fail:
    1771                 :          0 :         rte_pktmbuf_free(mbuf);
    1772                 :          0 :         ext_mbuf_memzone_free(nb_segs);
    1773                 :          0 :         return NULL;
    1774                 :            : }
    1775                 :            : 
    1776                 :            : void
    1777                 :        434 : ut_teardown(void)
    1778                 :            : {
    1779                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1780                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    1781                 :            : 
    1782                 :            :         /* free crypto session structure */
    1783                 :            : #ifdef RTE_LIB_SECURITY
    1784         [ -  + ]:        434 :         if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
    1785         [ #  # ]:          0 :                 if (ut_params->sec_session) {
    1786                 :          0 :                         rte_security_session_destroy(rte_cryptodev_get_sec_ctx
    1787                 :          0 :                                                 (ts_params->valid_devs[0]),
    1788                 :            :                                                 ut_params->sec_session);
    1789                 :          0 :                         ut_params->sec_session = NULL;
    1790                 :            :                 }
    1791                 :            :         } else
    1792                 :            : #endif
    1793                 :            :         {
    1794         [ +  + ]:        434 :                 if (ut_params->sess) {
    1795                 :        111 :                         rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
    1796                 :            :                                         ut_params->sess);
    1797                 :        111 :                         ut_params->sess = NULL;
    1798                 :            :                 }
    1799                 :            :         }
    1800                 :            : 
    1801                 :            :         /* free crypto operation structure */
    1802                 :        434 :         rte_crypto_op_free(ut_params->op);
    1803                 :            : 
    1804                 :            :         /*
    1805                 :            :          * free mbuf - both obuf and ibuf are usually the same,
    1806                 :            :          * so check if they point at the same address is necessary,
    1807                 :            :          * to avoid freeing the mbuf twice.
    1808                 :            :          */
    1809         [ +  + ]:        434 :         if (ut_params->obuf) {
    1810                 :          6 :                 rte_pktmbuf_free(ut_params->obuf);
    1811         [ +  + ]:          6 :                 if (ut_params->ibuf == ut_params->obuf)
    1812                 :          3 :                         ut_params->ibuf = 0;
    1813                 :          6 :                 ut_params->obuf = 0;
    1814                 :            :         }
    1815         [ +  + ]:        434 :         if (ut_params->ibuf) {
    1816                 :        110 :                 ext_mbuf_memzone_free(1);
    1817                 :        110 :                 rte_pktmbuf_free(ut_params->ibuf);
    1818                 :        110 :                 ut_params->ibuf = 0;
    1819                 :            :         }
    1820                 :            : 
    1821         [ +  - ]:        434 :         if (ts_params->mbuf_pool != NULL)
    1822                 :        434 :                 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
    1823                 :            :                         rte_mempool_avail_count(ts_params->mbuf_pool));
    1824                 :            : 
    1825                 :            :         /* Stop the device */
    1826                 :        434 :         rte_cryptodev_stop(ts_params->valid_devs[0]);
    1827                 :        434 : }
    1828                 :            : 
    1829                 :            : static void
    1830                 :          0 : ut_teardown_rx_inject(void)
    1831                 :            : {
    1832                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1833                 :            :         void *sec_ctx;
    1834                 :            :         int ret;
    1835                 :            : 
    1836         [ #  # ]:          0 :         if  (rte_eth_dev_count_avail() != 0) {
    1837                 :          0 :                 ret = rte_eth_dev_reset(0);
    1838         [ #  # ]:          0 :                 if (ret)
    1839                 :            :                         printf("Could not reset eth port 0");
    1840                 :            : 
    1841                 :            :         }
    1842                 :            : 
    1843                 :          0 :         ut_teardown();
    1844                 :            : 
    1845                 :          0 :         sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
    1846         [ #  # ]:          0 :         if (sec_ctx == NULL)
    1847                 :            :                 return;
    1848                 :            : 
    1849                 :          0 :         ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
    1850         [ #  # ]:          0 :         if (ret) {
    1851                 :            :                 printf("Could not disable Rx inject offload");
    1852                 :          0 :                 return;
    1853                 :            :         }
    1854                 :            : }
    1855                 :            : 
    1856                 :            : static int
    1857                 :          1 : test_device_configure_invalid_dev_id(void)
    1858                 :            : {
    1859                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1860                 :            :         uint16_t dev_id, num_devs = 0;
    1861                 :            : 
    1862         [ -  + ]:          1 :         TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
    1863                 :            :                         "Need at least %d devices for test", 1);
    1864                 :            : 
    1865                 :            :         /* valid dev_id values */
    1866                 :          1 :         dev_id = ts_params->valid_devs[0];
    1867                 :            : 
    1868                 :            :         /* Stop the device in case it's started so it can be configured */
    1869                 :          1 :         rte_cryptodev_stop(dev_id);
    1870                 :            : 
    1871         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
    1872                 :            :                         "Failed test for rte_cryptodev_configure: "
    1873                 :            :                         "invalid dev_num %u", dev_id);
    1874                 :            : 
    1875                 :            :         /* invalid dev_id values */
    1876                 :            :         dev_id = num_devs;
    1877                 :            : 
    1878         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
    1879                 :            :                         "Failed test for rte_cryptodev_configure: "
    1880                 :            :                         "invalid dev_num %u", dev_id);
    1881                 :            : 
    1882                 :            :         dev_id = 0xff;
    1883                 :            : 
    1884         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
    1885                 :            :                         "Failed test for rte_cryptodev_configure:"
    1886                 :            :                         "invalid dev_num %u", dev_id);
    1887                 :            : 
    1888                 :            :         return TEST_SUCCESS;
    1889                 :            : }
    1890                 :            : 
    1891                 :            : static int
    1892                 :          1 : test_device_configure_invalid_queue_pair_ids(void)
    1893                 :            : {
    1894                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1895                 :          1 :         uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
    1896                 :            : 
    1897                 :            :         /* Stop the device in case it's started so it can be configured */
    1898                 :          1 :         rte_cryptodev_stop(ts_params->valid_devs[0]);
    1899                 :            : 
    1900                 :            :         /* valid - max value queue pairs */
    1901                 :          1 :         ts_params->conf.nb_queue_pairs = orig_nb_qps;
    1902                 :            : 
    1903         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
    1904                 :            :                         &ts_params->conf),
    1905                 :            :                         "Failed to configure cryptodev: dev_id %u, qp_id %u",
    1906                 :            :                         ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
    1907                 :            : 
    1908                 :            :         /* valid - one queue pairs */
    1909                 :          1 :         ts_params->conf.nb_queue_pairs = 1;
    1910                 :            : 
    1911         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
    1912                 :            :                         &ts_params->conf),
    1913                 :            :                         "Failed to configure cryptodev: dev_id %u, qp_id %u",
    1914                 :            :                         ts_params->valid_devs[0],
    1915                 :            :                         ts_params->conf.nb_queue_pairs);
    1916                 :            : 
    1917                 :            : 
    1918                 :            :         /* invalid - zero queue pairs */
    1919                 :          1 :         ts_params->conf.nb_queue_pairs = 0;
    1920                 :            : 
    1921         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
    1922                 :            :                         &ts_params->conf),
    1923                 :            :                         "Failed test for rte_cryptodev_configure, dev_id %u,"
    1924                 :            :                         " invalid qps: %u",
    1925                 :            :                         ts_params->valid_devs[0],
    1926                 :            :                         ts_params->conf.nb_queue_pairs);
    1927                 :            : 
    1928                 :            : 
    1929                 :            :         /* invalid - max value supported by field queue pairs */
    1930                 :          1 :         ts_params->conf.nb_queue_pairs = UINT16_MAX;
    1931                 :            : 
    1932         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
    1933                 :            :                         &ts_params->conf),
    1934                 :            :                         "Failed test for rte_cryptodev_configure, dev_id %u,"
    1935                 :            :                         " invalid qps: %u",
    1936                 :            :                         ts_params->valid_devs[0],
    1937                 :            :                         ts_params->conf.nb_queue_pairs);
    1938                 :            : 
    1939                 :            : 
    1940                 :            :         /* invalid - max value + 1 queue pairs */
    1941                 :          1 :         ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
    1942                 :            : 
    1943         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
    1944                 :            :                         &ts_params->conf),
    1945                 :            :                         "Failed test for rte_cryptodev_configure, dev_id %u,"
    1946                 :            :                         " invalid qps: %u",
    1947                 :            :                         ts_params->valid_devs[0],
    1948                 :            :                         ts_params->conf.nb_queue_pairs);
    1949                 :            : 
    1950                 :            :         /* revert to original testsuite value */
    1951                 :          1 :         ts_params->conf.nb_queue_pairs = orig_nb_qps;
    1952                 :            : 
    1953                 :          1 :         return TEST_SUCCESS;
    1954                 :            : }
    1955                 :            : 
    1956                 :            : static int
    1957                 :          1 : test_queue_pair_descriptor_setup(void)
    1958                 :            : {
    1959                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1960                 :          1 :         struct rte_cryptodev_qp_conf qp_conf = {
    1961                 :            :                 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
    1962                 :            :         };
    1963                 :            :         uint16_t qp_id;
    1964                 :            : 
    1965                 :            :         /* Stop the device in case it's started so it can be configured */
    1966                 :          1 :         rte_cryptodev_stop(ts_params->valid_devs[0]);
    1967                 :            : 
    1968         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
    1969                 :            :                         &ts_params->conf),
    1970                 :            :                         "Failed to configure cryptodev %u",
    1971                 :            :                         ts_params->valid_devs[0]);
    1972                 :            : 
    1973                 :            :         /*
    1974                 :            :          * Test various ring sizes on this device. memzones can't be
    1975                 :            :          * freed so are re-used if ring is released and re-created.
    1976                 :            :          */
    1977                 :          1 :         qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
    1978                 :          1 :         qp_conf.mp_session = ts_params->session_mpool;
    1979                 :            : 
    1980         [ +  + ]:          9 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
    1981         [ -  + ]:          8 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
    1982                 :            :                                 ts_params->valid_devs[0], qp_id, &qp_conf,
    1983                 :            :                                 rte_cryptodev_socket_id(
    1984                 :            :                                                 ts_params->valid_devs[0])),
    1985                 :            :                                 "Failed test for "
    1986                 :            :                                 "rte_cryptodev_queue_pair_setup: num_inflights "
    1987                 :            :                                 "%u on qp %u on cryptodev %u",
    1988                 :            :                                 qp_conf.nb_descriptors, qp_id,
    1989                 :            :                                 ts_params->valid_devs[0]);
    1990                 :            :         }
    1991                 :            : 
    1992                 :          1 :         qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
    1993                 :            : 
    1994         [ +  + ]:          9 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
    1995         [ -  + ]:          8 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
    1996                 :            :                                 ts_params->valid_devs[0], qp_id, &qp_conf,
    1997                 :            :                                 rte_cryptodev_socket_id(
    1998                 :            :                                                 ts_params->valid_devs[0])),
    1999                 :            :                                 "Failed test for"
    2000                 :            :                                 " rte_cryptodev_queue_pair_setup: num_inflights"
    2001                 :            :                                 " %u on qp %u on cryptodev %u",
    2002                 :            :                                 qp_conf.nb_descriptors, qp_id,
    2003                 :            :                                 ts_params->valid_devs[0]);
    2004                 :            :         }
    2005                 :            : 
    2006                 :          1 :         qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
    2007                 :            : 
    2008         [ +  + ]:          9 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
    2009         [ -  + ]:          8 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
    2010                 :            :                                 ts_params->valid_devs[0], qp_id, &qp_conf,
    2011                 :            :                                 rte_cryptodev_socket_id(
    2012                 :            :                                                 ts_params->valid_devs[0])),
    2013                 :            :                                 "Failed test for "
    2014                 :            :                                 "rte_cryptodev_queue_pair_setup: num_inflights"
    2015                 :            :                                 " %u on qp %u on cryptodev %u",
    2016                 :            :                                 qp_conf.nb_descriptors, qp_id,
    2017                 :            :                                 ts_params->valid_devs[0]);
    2018                 :            :         }
    2019                 :            : 
    2020                 :          1 :         qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
    2021                 :            : 
    2022         [ +  + ]:          9 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
    2023         [ -  + ]:          8 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
    2024                 :            :                                 ts_params->valid_devs[0], qp_id, &qp_conf,
    2025                 :            :                                 rte_cryptodev_socket_id(
    2026                 :            :                                                 ts_params->valid_devs[0])),
    2027                 :            :                                 "Failed test for"
    2028                 :            :                                 " rte_cryptodev_queue_pair_setup:"
    2029                 :            :                                 "num_inflights %u on qp %u on cryptodev %u",
    2030                 :            :                                 qp_conf.nb_descriptors, qp_id,
    2031                 :            :                                 ts_params->valid_devs[0]);
    2032                 :            :         }
    2033                 :            : 
    2034                 :            :         /* test invalid queue pair id */
    2035                 :          1 :         qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;      /*valid */
    2036                 :            : 
    2037                 :            :         qp_id = ts_params->conf.nb_queue_pairs;              /*invalid */
    2038                 :            : 
    2039         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
    2040                 :            :                         ts_params->valid_devs[0],
    2041                 :            :                         qp_id, &qp_conf,
    2042                 :            :                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
    2043                 :            :                         "Failed test for rte_cryptodev_queue_pair_setup:"
    2044                 :            :                         "invalid qp %u on cryptodev %u",
    2045                 :            :                         qp_id, ts_params->valid_devs[0]);
    2046                 :            : 
    2047                 :            :         qp_id = 0xffff; /*invalid*/
    2048                 :            : 
    2049         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
    2050                 :            :                         ts_params->valid_devs[0],
    2051                 :            :                         qp_id, &qp_conf,
    2052                 :            :                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
    2053                 :            :                         "Failed test for rte_cryptodev_queue_pair_setup:"
    2054                 :            :                         "invalid qp %u on cryptodev %u",
    2055                 :            :                         qp_id, ts_params->valid_devs[0]);
    2056                 :            : 
    2057                 :            :         return TEST_SUCCESS;
    2058                 :            : }
    2059                 :            : 
    2060                 :            : /* ***** Plaintext data for tests ***** */
    2061                 :            : 
    2062                 :            : const char catch_22_quote_1[] =
    2063                 :            :                 "There was only one catch and that was Catch-22, which "
    2064                 :            :                 "specified that a concern for one's safety in the face of "
    2065                 :            :                 "dangers that were real and immediate was the process of a "
    2066                 :            :                 "rational mind. Orr was crazy and could be grounded. All he "
    2067                 :            :                 "had to do was ask; and as soon as he did, he would no longer "
    2068                 :            :                 "be crazy and would have to fly more missions. Orr would be "
    2069                 :            :                 "crazy to fly more missions and sane if he didn't, but if he "
    2070                 :            :                 "was sane he had to fly them. If he flew them he was crazy "
    2071                 :            :                 "and didn't have to; but if he didn't want to he was sane and "
    2072                 :            :                 "had to. Yossarian was moved very deeply by the absolute "
    2073                 :            :                 "simplicity of this clause of Catch-22 and let out a "
    2074                 :            :                 "respectful whistle. \"That's some catch, that Catch-22\", he "
    2075                 :            :                 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
    2076                 :            : 
    2077                 :            : const char catch_22_quote[] =
    2078                 :            :                 "What a lousy earth! He wondered how many people were "
    2079                 :            :                 "destitute that same night even in his own prosperous country, "
    2080                 :            :                 "how many homes were shanties, how many husbands were drunk "
    2081                 :            :                 "and wives socked, and how many children were bullied, abused, "
    2082                 :            :                 "or abandoned. How many families hungered for food they could "
    2083                 :            :                 "not afford to buy? How many hearts were broken? How many "
    2084                 :            :                 "suicides would take place that same night, how many people "
    2085                 :            :                 "would go insane? How many cockroaches and landlords would "
    2086                 :            :                 "triumph? How many winners were losers, successes failures, "
    2087                 :            :                 "and rich men poor men? How many wise guys were stupid? How "
    2088                 :            :                 "many happy endings were unhappy endings? How many honest men "
    2089                 :            :                 "were liars, brave men cowards, loyal men traitors, how many "
    2090                 :            :                 "sainted men were corrupt, how many people in positions of "
    2091                 :            :                 "trust had sold their souls to bodyguards, how many had never "
    2092                 :            :                 "had souls? How many straight-and-narrow paths were crooked "
    2093                 :            :                 "paths? How many best families were worst families and how "
    2094                 :            :                 "many good people were bad people? When you added them all up "
    2095                 :            :                 "and then subtracted, you might be left with only the children, "
    2096                 :            :                 "and perhaps with Albert Einstein and an old violinist or "
    2097                 :            :                 "sculptor somewhere.";
    2098                 :            : 
    2099                 :            : #define QUOTE_480_BYTES         (480)
    2100                 :            : #define QUOTE_512_BYTES         (512)
    2101                 :            : #define QUOTE_768_BYTES         (768)
    2102                 :            : #define QUOTE_1024_BYTES        (1024)
    2103                 :            : 
    2104                 :            : 
    2105                 :            : 
    2106                 :            : /* ***** SHA1 Hash Tests ***** */
    2107                 :            : 
    2108                 :            : #define HMAC_KEY_LENGTH_SHA1    (DIGEST_BYTE_LENGTH_SHA1)
    2109                 :            : 
    2110                 :            : static uint8_t hmac_sha1_key[] = {
    2111                 :            :         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
    2112                 :            :         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
    2113                 :            :         0xDE, 0xF4, 0xDE, 0xAD };
    2114                 :            : 
    2115                 :            : /* ***** SHA224 Hash Tests ***** */
    2116                 :            : 
    2117                 :            : #define HMAC_KEY_LENGTH_SHA224  (DIGEST_BYTE_LENGTH_SHA224)
    2118                 :            : 
    2119                 :            : 
    2120                 :            : /* ***** AES-CBC Cipher Tests ***** */
    2121                 :            : 
    2122                 :            : #define CIPHER_KEY_LENGTH_AES_CBC       (16)
    2123                 :            : #define CIPHER_IV_LENGTH_AES_CBC        (CIPHER_KEY_LENGTH_AES_CBC)
    2124                 :            : 
    2125                 :            : static uint8_t aes_cbc_key[] = {
    2126                 :            :         0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
    2127                 :            :         0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
    2128                 :            : 
    2129                 :            : static uint8_t aes_cbc_iv[] = {
    2130                 :            :         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    2131                 :            :         0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
    2132                 :            : 
    2133                 :            : 
    2134                 :            : /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
    2135                 :            : 
    2136                 :            : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
    2137                 :            :         0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
    2138                 :            :         0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
    2139                 :            :         0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
    2140                 :            :         0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
    2141                 :            :         0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
    2142                 :            :         0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
    2143                 :            :         0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
    2144                 :            :         0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
    2145                 :            :         0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
    2146                 :            :         0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
    2147                 :            :         0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
    2148                 :            :         0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
    2149                 :            :         0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
    2150                 :            :         0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
    2151                 :            :         0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
    2152                 :            :         0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
    2153                 :            :         0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
    2154                 :            :         0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
    2155                 :            :         0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
    2156                 :            :         0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
    2157                 :            :         0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
    2158                 :            :         0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
    2159                 :            :         0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
    2160                 :            :         0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
    2161                 :            :         0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
    2162                 :            :         0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
    2163                 :            :         0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
    2164                 :            :         0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
    2165                 :            :         0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
    2166                 :            :         0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
    2167                 :            :         0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
    2168                 :            :         0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
    2169                 :            :         0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
    2170                 :            :         0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
    2171                 :            :         0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
    2172                 :            :         0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
    2173                 :            :         0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
    2174                 :            :         0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
    2175                 :            :         0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
    2176                 :            :         0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
    2177                 :            :         0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
    2178                 :            :         0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
    2179                 :            :         0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
    2180                 :            :         0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
    2181                 :            :         0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
    2182                 :            :         0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
    2183                 :            :         0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
    2184                 :            :         0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
    2185                 :            :         0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
    2186                 :            :         0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
    2187                 :            :         0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
    2188                 :            :         0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
    2189                 :            :         0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
    2190                 :            :         0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
    2191                 :            :         0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
    2192                 :            :         0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
    2193                 :            :         0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
    2194                 :            :         0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
    2195                 :            :         0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
    2196                 :            :         0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
    2197                 :            :         0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
    2198                 :            :         0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
    2199                 :            :         0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
    2200                 :            :         0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
    2201                 :            : };
    2202                 :            : 
    2203                 :            : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
    2204                 :            :         0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
    2205                 :            :         0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
    2206                 :            :         0x18, 0x8c, 0x1d, 0x32
    2207                 :            : };
    2208                 :            : 
    2209                 :            : 
    2210                 :            : /* Multisession Vector context Test */
    2211                 :            : /*Begin Session 0 */
    2212                 :            : static uint8_t ms_aes_cbc_key0[] = {
    2213                 :            :         0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    2214                 :            :         0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
    2215                 :            : };
    2216                 :            : 
    2217                 :            : static uint8_t ms_aes_cbc_iv0[] = {
    2218                 :            :         0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    2219                 :            :         0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
    2220                 :            : };
    2221                 :            : 
    2222                 :            : static const uint8_t ms_aes_cbc_cipher0[] = {
    2223                 :            :                 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
    2224                 :            :                 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
    2225                 :            :                 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
    2226                 :            :                 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
    2227                 :            :                 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
    2228                 :            :                 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
    2229                 :            :                 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
    2230                 :            :                 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
    2231                 :            :                 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
    2232                 :            :                 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
    2233                 :            :                 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
    2234                 :            :                 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
    2235                 :            :                 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
    2236                 :            :                 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
    2237                 :            :                 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
    2238                 :            :                 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
    2239                 :            :                 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
    2240                 :            :                 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
    2241                 :            :                 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
    2242                 :            :                 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
    2243                 :            :                 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
    2244                 :            :                 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
    2245                 :            :                 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
    2246                 :            :                 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
    2247                 :            :                 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
    2248                 :            :                 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
    2249                 :            :                 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
    2250                 :            :                 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
    2251                 :            :                 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
    2252                 :            :                 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
    2253                 :            :                 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
    2254                 :            :                 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
    2255                 :            :                 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
    2256                 :            :                 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
    2257                 :            :                 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
    2258                 :            :                 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
    2259                 :            :                 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
    2260                 :            :                 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
    2261                 :            :                 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
    2262                 :            :                 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
    2263                 :            :                 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
    2264                 :            :                 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
    2265                 :            :                 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
    2266                 :            :                 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
    2267                 :            :                 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
    2268                 :            :                 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
    2269                 :            :                 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
    2270                 :            :                 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
    2271                 :            :                 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
    2272                 :            :                 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
    2273                 :            :                 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
    2274                 :            :                 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
    2275                 :            :                 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
    2276                 :            :                 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
    2277                 :            :                 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
    2278                 :            :                 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
    2279                 :            :                 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
    2280                 :            :                 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
    2281                 :            :                 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
    2282                 :            :                 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
    2283                 :            :                 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
    2284                 :            :                 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
    2285                 :            :                 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
    2286                 :            :                 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
    2287                 :            : };
    2288                 :            : 
    2289                 :            : 
    2290                 :            : static  uint8_t ms_hmac_key0[] = {
    2291                 :            :                 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
    2292                 :            :                 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
    2293                 :            :                 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
    2294                 :            :                 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
    2295                 :            :                 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
    2296                 :            :                 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
    2297                 :            :                 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
    2298                 :            :                 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
    2299                 :            : };
    2300                 :            : 
    2301                 :            : static const uint8_t ms_hmac_digest0[] = {
    2302                 :            :                 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
    2303                 :            :                 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
    2304                 :            :                 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
    2305                 :            :                 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
    2306                 :            :                 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
    2307                 :            :                 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
    2308                 :            :                 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
    2309                 :            :                 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
    2310                 :            :                 };
    2311                 :            : 
    2312                 :            : /* End Session 0 */
    2313                 :            : /* Begin session 1 */
    2314                 :            : 
    2315                 :            : static  uint8_t ms_aes_cbc_key1[] = {
    2316                 :            :                 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    2317                 :            :                 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
    2318                 :            : };
    2319                 :            : 
    2320                 :            : static  uint8_t ms_aes_cbc_iv1[] = {
    2321                 :            :         0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    2322                 :            :         0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
    2323                 :            : };
    2324                 :            : 
    2325                 :            : static const uint8_t ms_aes_cbc_cipher1[] = {
    2326                 :            :                 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
    2327                 :            :                 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
    2328                 :            :                 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
    2329                 :            :                 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
    2330                 :            :                 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
    2331                 :            :                 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
    2332                 :            :                 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
    2333                 :            :                 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
    2334                 :            :                 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
    2335                 :            :                 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
    2336                 :            :                 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
    2337                 :            :                 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
    2338                 :            :                 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
    2339                 :            :                 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
    2340                 :            :                 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
    2341                 :            :                 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
    2342                 :            :                 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
    2343                 :            :                 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
    2344                 :            :                 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
    2345                 :            :                 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
    2346                 :            :                 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
    2347                 :            :                 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
    2348                 :            :                 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
    2349                 :            :                 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
    2350                 :            :                 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
    2351                 :            :                 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
    2352                 :            :                 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
    2353                 :            :                 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
    2354                 :            :                 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
    2355                 :            :                 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
    2356                 :            :                 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
    2357                 :            :                 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
    2358                 :            :                 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
    2359                 :            :                 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
    2360                 :            :                 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
    2361                 :            :                 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
    2362                 :            :                 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
    2363                 :            :                 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
    2364                 :            :                 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
    2365                 :            :                 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
    2366                 :            :                 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
    2367                 :            :                 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
    2368                 :            :                 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
    2369                 :            :                 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
    2370                 :            :                 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
    2371                 :            :                 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
    2372                 :            :                 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
    2373                 :            :                 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
    2374                 :            :                 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
    2375                 :            :                 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
    2376                 :            :                 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
    2377                 :            :                 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
    2378                 :            :                 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
    2379                 :            :                 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
    2380                 :            :                 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
    2381                 :            :                 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
    2382                 :            :                 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
    2383                 :            :                 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
    2384                 :            :                 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
    2385                 :            :                 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
    2386                 :            :                 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
    2387                 :            :                 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
    2388                 :            :                 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
    2389                 :            :                 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
    2390                 :            : 
    2391                 :            : };
    2392                 :            : 
    2393                 :            : static uint8_t ms_hmac_key1[] = {
    2394                 :            :                 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
    2395                 :            :                 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
    2396                 :            :                 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
    2397                 :            :                 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
    2398                 :            :                 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
    2399                 :            :                 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
    2400                 :            :                 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
    2401                 :            :                 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
    2402                 :            : };
    2403                 :            : 
    2404                 :            : static const uint8_t ms_hmac_digest1[] = {
    2405                 :            :                 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
    2406                 :            :                 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
    2407                 :            :                 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
    2408                 :            :                 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
    2409                 :            :                 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
    2410                 :            :                 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
    2411                 :            :                 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
    2412                 :            :                 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
    2413                 :            : };
    2414                 :            : /* End Session 1  */
    2415                 :            : /* Begin Session 2 */
    2416                 :            : static  uint8_t ms_aes_cbc_key2[] = {
    2417                 :            :                 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    2418                 :            :                 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
    2419                 :            : };
    2420                 :            : 
    2421                 :            : static  uint8_t ms_aes_cbc_iv2[] = {
    2422                 :            :                 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    2423                 :            :                 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
    2424                 :            : };
    2425                 :            : 
    2426                 :            : static const uint8_t ms_aes_cbc_cipher2[] = {
    2427                 :            :                 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
    2428                 :            :                 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
    2429                 :            :                 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
    2430                 :            :                 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
    2431                 :            :                 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
    2432                 :            :                 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
    2433                 :            :                 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
    2434                 :            :                 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
    2435                 :            :                 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
    2436                 :            :                 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
    2437                 :            :                 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
    2438                 :            :                 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
    2439                 :            :                 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
    2440                 :            :                 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
    2441                 :            :                 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
    2442                 :            :                 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
    2443                 :            :                 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
    2444                 :            :                 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
    2445                 :            :                 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
    2446                 :            :                 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
    2447                 :            :                 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
    2448                 :            :                 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
    2449                 :            :                 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
    2450                 :            :                 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
    2451                 :            :                 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
    2452                 :            :                 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
    2453                 :            :                 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
    2454                 :            :                 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
    2455                 :            :                 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
    2456                 :            :                 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
    2457                 :            :                 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
    2458                 :            :                 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
    2459                 :            :                 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
    2460                 :            :                 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
    2461                 :            :                 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
    2462                 :            :                 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
    2463                 :            :                 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
    2464                 :            :                 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
    2465                 :            :                 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
    2466                 :            :                 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
    2467                 :            :                 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
    2468                 :            :                 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
    2469                 :            :                 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
    2470                 :            :                 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
    2471                 :            :                 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
    2472                 :            :                 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
    2473                 :            :                 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
    2474                 :            :                 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
    2475                 :            :                 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
    2476                 :            :                 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
    2477                 :            :                 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
    2478                 :            :                 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
    2479                 :            :                 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
    2480                 :            :                 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
    2481                 :            :                 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
    2482                 :            :                 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
    2483                 :            :                 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
    2484                 :            :                 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
    2485                 :            :                 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
    2486                 :            :                 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
    2487                 :            :                 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
    2488                 :            :                 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
    2489                 :            :                 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
    2490                 :            :                 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
    2491                 :            : };
    2492                 :            : 
    2493                 :            : static  uint8_t ms_hmac_key2[] = {
    2494                 :            :                 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
    2495                 :            :                 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
    2496                 :            :                 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
    2497                 :            :                 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
    2498                 :            :                 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
    2499                 :            :                 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
    2500                 :            :                 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
    2501                 :            :                 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
    2502                 :            : };
    2503                 :            : 
    2504                 :            : static const uint8_t ms_hmac_digest2[] = {
    2505                 :            :                 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
    2506                 :            :                 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
    2507                 :            :                 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
    2508                 :            :                 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
    2509                 :            :                 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
    2510                 :            :                 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
    2511                 :            :                 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
    2512                 :            :                 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
    2513                 :            : };
    2514                 :            : 
    2515                 :            : /* End Session 2 */
    2516                 :            : 
    2517                 :            : #define MAX_OPS_PROCESSED (MAX_NUM_OPS_INFLIGHT - 1)
    2518                 :            : static int
    2519                 :          1 : test_queue_pair_descriptor_count(void)
    2520                 :            : {
    2521                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    2522                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    2523                 :          1 :         struct rte_crypto_op *ops_deq[MAX_OPS_PROCESSED] = { NULL };
    2524                 :          1 :         struct rte_crypto_op *ops[MAX_OPS_PROCESSED] = { NULL };
    2525                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    2526                 :            :         int qp_depth = 0;
    2527                 :            :         int i;
    2528                 :            : 
    2529         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    2530                 :            :                 return TEST_SKIPPED;
    2531                 :            : 
    2532                 :            :         /* Verify if the queue pair depth API is supported by driver */
    2533         [ +  - ]:          1 :         qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
    2534         [ #  # ]:          0 :         if (qp_depth == -ENOTSUP)
    2535                 :          1 :                 return TEST_SKIPPED;
    2536                 :            : 
    2537                 :            :         /* Verify the capabilities */
    2538                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    2539                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
    2540         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
    2541                 :            :                 return TEST_SKIPPED;
    2542                 :            : 
    2543                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    2544                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
    2545         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
    2546                 :            :                 return TEST_SKIPPED;
    2547                 :            : 
    2548                 :            :         /* Setup Cipher Parameters */
    2549                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    2550                 :          0 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
    2551                 :          0 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
    2552                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
    2553                 :          0 :         ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
    2554                 :          0 :         ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
    2555                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    2556                 :          0 :         ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
    2557                 :            : 
    2558                 :            :         /* Setup HMAC Parameters */
    2559                 :          0 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    2560                 :          0 :         ut_params->auth_xform.next = NULL;
    2561                 :          0 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
    2562                 :          0 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
    2563                 :          0 :         ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
    2564                 :          0 :         ut_params->auth_xform.auth.key.data = hmac_sha1_key;
    2565                 :          0 :         ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
    2566                 :            : 
    2567                 :          0 :         rte_errno = 0;
    2568                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
    2569                 :            :                         &ut_params->cipher_xform, ts_params->session_mpool);
    2570         [ #  # ]:          0 :         if (rte_errno == ENOTSUP)
    2571                 :            :                 return TEST_SKIPPED;
    2572                 :            : 
    2573         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    2574                 :            : 
    2575         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
    2576                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops, MAX_OPS_PROCESSED),
    2577                 :            :                         MAX_OPS_PROCESSED, "failed to generate burst of crypto ops");
    2578                 :            : 
    2579                 :            :         /* Generate crypto op data structure */
    2580         [ #  # ]:          0 :         for (i = 0; i < MAX_OPS_PROCESSED; i++) {
    2581                 :            :                 struct rte_mbuf *m;
    2582                 :            :                 uint8_t *digest;
    2583                 :            : 
    2584                 :            :                 /* Generate test mbuf data and space for digest */
    2585                 :          0 :                 m = setup_test_string(ts_params->mbuf_pool, catch_22_quote, QUOTE_512_BYTES, 0);
    2586         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
    2587                 :            : 
    2588                 :            :                 digest = (uint8_t *)rte_pktmbuf_append(m, DIGEST_BYTE_LENGTH_SHA1);
    2589         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(digest, "no room to append digest");
    2590                 :            : 
    2591         [ #  # ]:          0 :                 rte_crypto_op_attach_sym_session(ops[i], ut_params->sess);
    2592                 :            : 
    2593                 :            :                 /* set crypto operation source mbuf */
    2594                 :          0 :                 ops[i]->sym->m_src = m;
    2595                 :            : 
    2596                 :            :                 /* Set crypto operation authentication parameters */
    2597                 :          0 :                 ops[i]->sym->auth.digest.data = digest;
    2598                 :          0 :                 ops[i]->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m, QUOTE_512_BYTES);
    2599                 :            : 
    2600                 :          0 :                 ops[i]->sym->auth.data.offset = 0;
    2601                 :          0 :                 ops[i]->sym->auth.data.length = QUOTE_512_BYTES;
    2602                 :            : 
    2603                 :            :                 /* Copy IV at the end of the crypto operation */
    2604                 :          0 :                 memcpy(rte_crypto_op_ctod_offset(ops[i], uint8_t *, IV_OFFSET), aes_cbc_iv,
    2605                 :            :                                 CIPHER_IV_LENGTH_AES_CBC);
    2606                 :            : 
    2607                 :            :                 /* Set crypto operation cipher parameters */
    2608                 :          0 :                 ops[i]->sym->cipher.data.offset = 0;
    2609                 :          0 :                 ops[i]->sym->cipher.data.length = QUOTE_512_BYTES;
    2610                 :            : 
    2611         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0], 0,
    2612                 :            :                                         &ops[i], 1), 1, "Error enqueuing");
    2613                 :            :         }
    2614                 :            : 
    2615         [ #  # ]:          0 :         for (i = 0; i < MAX_OPS_PROCESSED; i++) {
    2616         [ #  # ]:          0 :                 qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
    2617         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(qp_depth, MAX_OPS_PROCESSED - i,
    2618                 :            :                         "Crypto queue pair depth used does not match with inflight ops");
    2619                 :            : 
    2620                 :          0 :                 while (rte_cryptodev_dequeue_burst(ts_params->valid_devs[0], 0,
    2621         [ #  # ]:          0 :                                         &ops_deq[i], 1) == 0)
    2622                 :            :                         rte_pause();
    2623                 :            : 
    2624         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(ops_deq[i]->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    2625                 :            :                                 "crypto op processing failed");
    2626                 :            : 
    2627                 :          0 :                 rte_pktmbuf_free(ops_deq[i]->sym->m_src);
    2628                 :          0 :                 rte_crypto_op_free(ops_deq[i]);
    2629                 :          0 :                 ops_deq[i] = NULL;
    2630                 :            :         }
    2631                 :            : 
    2632                 :            :         return TEST_SUCCESS;
    2633                 :            : }
    2634                 :            : 
    2635                 :            : static int
    2636                 :          2 : test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
    2637                 :            : {
    2638                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    2639                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    2640                 :            :         /* Verify the capabilities */
    2641                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    2642                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    2643                 :          2 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
    2644         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    2645                 :            :                         &cap_idx) == NULL)
    2646                 :            :                 return TEST_SKIPPED;
    2647                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    2648                 :          2 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
    2649         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    2650                 :            :                         &cap_idx) == NULL)
    2651                 :            :                 return TEST_SKIPPED;
    2652                 :            : 
    2653                 :            :         /* Generate test mbuf data and space for digest */
    2654                 :          2 :         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
    2655                 :            :                         catch_22_quote, QUOTE_512_BYTES, 0);
    2656                 :            : 
    2657                 :          2 :         ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    2658                 :            :                         DIGEST_BYTE_LENGTH_SHA1);
    2659         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
    2660                 :            : 
    2661                 :            :         /* Setup Cipher Parameters */
    2662                 :          2 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    2663                 :          2 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
    2664                 :            : 
    2665                 :          2 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
    2666                 :          2 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
    2667                 :          2 :         ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
    2668                 :          2 :         ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
    2669                 :          2 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    2670                 :          2 :         ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
    2671                 :            : 
    2672                 :            :         /* Setup HMAC Parameters */
    2673                 :          2 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    2674                 :            : 
    2675                 :          2 :         ut_params->auth_xform.next = NULL;
    2676                 :            : 
    2677                 :          2 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
    2678                 :          2 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
    2679                 :          2 :         ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
    2680                 :          2 :         ut_params->auth_xform.auth.key.data = hmac_sha1_key;
    2681                 :          2 :         ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
    2682                 :            : 
    2683                 :          2 :         rte_errno = 0;
    2684                 :          4 :         ut_params->sess = rte_cryptodev_sym_session_create(
    2685                 :          2 :                         ts_params->valid_devs[0], &ut_params->cipher_xform,
    2686                 :            :                         ts_params->session_mpool);
    2687         [ +  - ]:          2 :         if (rte_errno == ENOTSUP)
    2688                 :            :                 return TEST_SKIPPED;
    2689         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    2690                 :            : 
    2691                 :            :         /* Generate crypto op data structure */
    2692                 :          2 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    2693                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    2694         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    2695                 :            :                         "Failed to allocate symmetric crypto operation struct");
    2696                 :            : 
    2697         [ +  - ]:          2 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    2698                 :            : 
    2699                 :          2 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    2700                 :            : 
    2701                 :            :         /* set crypto operation source mbuf */
    2702                 :          2 :         sym_op->m_src = ut_params->ibuf;
    2703                 :            : 
    2704                 :            :         /* Set crypto operation authentication parameters */
    2705                 :          2 :         sym_op->auth.digest.data = ut_params->digest;
    2706         [ -  + ]:          2 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    2707                 :            :                         ut_params->ibuf, QUOTE_512_BYTES);
    2708                 :            : 
    2709                 :          2 :         sym_op->auth.data.offset = 0;
    2710                 :          2 :         sym_op->auth.data.length = QUOTE_512_BYTES;
    2711                 :            : 
    2712                 :            :         /* Copy IV at the end of the crypto operation */
    2713         [ -  + ]:          2 :         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
    2714                 :            :                         aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
    2715                 :            : 
    2716                 :            :         /* Set crypto operation cipher parameters */
    2717                 :          2 :         sym_op->cipher.data.offset = 0;
    2718                 :          2 :         sym_op->cipher.data.length = QUOTE_512_BYTES;
    2719                 :            : 
    2720                 :            :         /* Process crypto operation */
    2721         [ -  + ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    2722                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
    2723                 :            :                         ut_params->op);
    2724                 :            :         else
    2725         [ -  + ]:          2 :                 TEST_ASSERT_NOT_NULL(
    2726                 :            :                         process_crypto_request(ts_params->valid_devs[0],
    2727                 :            :                                 ut_params->op),
    2728                 :            :                                 "failed to process sym crypto op");
    2729                 :            : 
    2730         [ -  + ]:          2 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    2731                 :            :                         "crypto op processing failed");
    2732                 :            : 
    2733                 :            :         /* Validate obuf */
    2734                 :          2 :         uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
    2735                 :            :                         uint8_t *);
    2736                 :            : 
    2737         [ -  + ]:          2 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
    2738                 :            :                         catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
    2739                 :            :                         QUOTE_512_BYTES,
    2740                 :            :                         "ciphertext data not as expected");
    2741                 :            : 
    2742                 :          2 :         uint8_t *digest = ciphertext + QUOTE_512_BYTES;
    2743                 :            : 
    2744   [ +  -  -  + ]:          4 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
    2745                 :            :                         catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
    2746                 :            :                         gbl_driver_id == rte_cryptodev_driver_id_get(
    2747                 :            :                                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
    2748                 :            :                                         TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
    2749                 :            :                                         DIGEST_BYTE_LENGTH_SHA1,
    2750                 :            :                         "Generated digest data not as expected");
    2751                 :            : 
    2752                 :            :         return TEST_SUCCESS;
    2753                 :            : }
    2754                 :            : 
    2755                 :            : /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
    2756                 :            : 
    2757                 :            : #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
    2758                 :            : 
    2759                 :            : static uint8_t hmac_sha512_key[] = {
    2760                 :            :         0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
    2761                 :            :         0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
    2762                 :            :         0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
    2763                 :            :         0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
    2764                 :            :         0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
    2765                 :            :         0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
    2766                 :            :         0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
    2767                 :            :         0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
    2768                 :            : 
    2769                 :            : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
    2770                 :            :         0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
    2771                 :            :         0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
    2772                 :            :         0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
    2773                 :            :         0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
    2774                 :            :         0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
    2775                 :            :         0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
    2776                 :            :         0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
    2777                 :            :         0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
    2778                 :            : 
    2779                 :            : 
    2780                 :            : 
    2781                 :            : static int
    2782                 :            : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
    2783                 :            :                 struct crypto_unittest_params *ut_params,
    2784                 :            :                 uint8_t *cipher_key,
    2785                 :            :                 uint8_t *hmac_key);
    2786                 :            : 
    2787                 :            : static int
    2788                 :            : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
    2789                 :            :                 struct crypto_unittest_params *ut_params,
    2790                 :            :                 struct crypto_testsuite_params *ts_params,
    2791                 :            :                 const uint8_t *cipher,
    2792                 :            :                 const uint8_t *digest,
    2793                 :            :                 const uint8_t *iv);
    2794                 :            : 
    2795                 :            : 
    2796                 :            : static int
    2797                 :            : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
    2798                 :            :                 struct crypto_unittest_params *ut_params,
    2799                 :            :                 uint8_t *cipher_key,
    2800                 :            :                 uint8_t *hmac_key)
    2801                 :            : {
    2802                 :            : 
    2803                 :            :         /* Setup Cipher Parameters */
    2804                 :          4 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    2805                 :          4 :         ut_params->cipher_xform.next = NULL;
    2806                 :            : 
    2807                 :          4 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
    2808                 :          4 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
    2809                 :          4 :         ut_params->cipher_xform.cipher.key.data = cipher_key;
    2810                 :          4 :         ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
    2811                 :          4 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    2812                 :          4 :         ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
    2813                 :            : 
    2814                 :            :         /* Setup HMAC Parameters */
    2815                 :          4 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    2816                 :          4 :         ut_params->auth_xform.next = &ut_params->cipher_xform;
    2817                 :            : 
    2818                 :          4 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
    2819                 :          4 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
    2820                 :          4 :         ut_params->auth_xform.auth.key.data = hmac_key;
    2821                 :          4 :         ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
    2822                 :          4 :         ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
    2823                 :            : 
    2824                 :            :         return TEST_SUCCESS;
    2825                 :            : }
    2826                 :            : 
    2827                 :            : 
    2828                 :            : static int
    2829                 :          5 : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
    2830                 :            :                 struct crypto_unittest_params *ut_params,
    2831                 :            :                 struct crypto_testsuite_params *ts_params,
    2832                 :            :                 const uint8_t *cipher,
    2833                 :            :                 const uint8_t *digest,
    2834                 :            :                 const uint8_t *iv)
    2835                 :            : {
    2836                 :            :         int ret;
    2837                 :            : 
    2838                 :            :         /* Generate test mbuf data and digest */
    2839                 :          5 :         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
    2840                 :            :                         (const char *)
    2841                 :            :                         cipher,
    2842                 :            :                         QUOTE_512_BYTES, 0);
    2843                 :            : 
    2844                 :          5 :         ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    2845                 :            :                         DIGEST_BYTE_LENGTH_SHA512);
    2846         [ -  + ]:          5 :         TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
    2847                 :            : 
    2848                 :            :         rte_memcpy(ut_params->digest,
    2849                 :            :                         digest,
    2850                 :            :                         DIGEST_BYTE_LENGTH_SHA512);
    2851                 :            : 
    2852                 :            :         /* Generate Crypto op data structure */
    2853                 :          5 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    2854                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    2855         [ -  + ]:          5 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    2856                 :            :                         "Failed to allocate symmetric crypto operation struct");
    2857                 :            : 
    2858                 :            :         rte_crypto_op_attach_sym_session(ut_params->op, sess);
    2859                 :            : 
    2860                 :          5 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    2861                 :            : 
    2862                 :            :         /* set crypto operation source mbuf */
    2863                 :          5 :         sym_op->m_src = ut_params->ibuf;
    2864                 :            : 
    2865                 :          5 :         sym_op->auth.digest.data = ut_params->digest;
    2866         [ -  + ]:          5 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    2867                 :            :                         ut_params->ibuf, QUOTE_512_BYTES);
    2868                 :            : 
    2869                 :          5 :         sym_op->auth.data.offset = 0;
    2870                 :          5 :         sym_op->auth.data.length = QUOTE_512_BYTES;
    2871                 :            : 
    2872                 :            :         /* Copy IV at the end of the crypto operation */
    2873         [ -  + ]:          5 :         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
    2874                 :            :                         iv, CIPHER_IV_LENGTH_AES_CBC);
    2875                 :            : 
    2876                 :          5 :         sym_op->cipher.data.offset = 0;
    2877                 :          5 :         sym_op->cipher.data.length = QUOTE_512_BYTES;
    2878                 :            : 
    2879                 :            :         /* Process crypto operation */
    2880         [ -  + ]:          5 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    2881                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
    2882                 :            :                         ut_params->op);
    2883         [ -  + ]:          5 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    2884                 :          0 :                 ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
    2885         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
    2886                 :            :                         return ret;
    2887                 :            :         } else
    2888         [ -  + ]:          5 :                 TEST_ASSERT_NOT_NULL(
    2889                 :            :                                 process_crypto_request(ts_params->valid_devs[0],
    2890                 :            :                                         ut_params->op),
    2891                 :            :                                         "failed to process sym crypto op");
    2892                 :            : 
    2893         [ -  + ]:          5 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    2894                 :            :                         "crypto op processing failed");
    2895                 :            : 
    2896                 :          5 :         ut_params->obuf = ut_params->op->sym->m_src;
    2897                 :            : 
    2898                 :            :         /* Validate obuf */
    2899         [ -  + ]:          5 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    2900                 :            :                         rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
    2901                 :            :                         catch_22_quote,
    2902                 :            :                         QUOTE_512_BYTES,
    2903                 :            :                         "Plaintext data not as expected");
    2904                 :            : 
    2905                 :            :         /* Validate obuf */
    2906         [ -  + ]:          5 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    2907                 :            :                         "Digest verification failed");
    2908                 :            : 
    2909                 :            :         return TEST_SUCCESS;
    2910                 :            : }
    2911                 :            : 
    2912                 :            : /* ***** SNOW 3G Tests ***** */
    2913                 :            : static int
    2914                 :          0 : create_wireless_algo_hash_session(uint8_t dev_id,
    2915                 :            :         const uint8_t *key, const uint8_t key_len,
    2916                 :            :         const uint8_t iv_len, const uint8_t auth_len,
    2917                 :            :         enum rte_crypto_auth_operation op,
    2918                 :            :         enum rte_crypto_auth_algorithm algo)
    2919                 :            : {
    2920                 :          0 :         uint8_t *hash_key = alloca(key_len);
    2921                 :            : 
    2922                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    2923                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    2924                 :            : 
    2925                 :            :         memcpy(hash_key, key, key_len);
    2926                 :            : 
    2927                 :          0 :         debug_hexdump(stdout, "key:", key, key_len);
    2928                 :            : 
    2929                 :            :         /* Setup Authentication Parameters */
    2930                 :          0 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    2931                 :          0 :         ut_params->auth_xform.next = NULL;
    2932                 :            : 
    2933                 :          0 :         ut_params->auth_xform.auth.op = op;
    2934                 :          0 :         ut_params->auth_xform.auth.algo = algo;
    2935                 :          0 :         ut_params->auth_xform.auth.key.length = key_len;
    2936                 :          0 :         ut_params->auth_xform.auth.key.data = hash_key;
    2937                 :          0 :         ut_params->auth_xform.auth.digest_length = auth_len;
    2938                 :          0 :         ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
    2939                 :          0 :         ut_params->auth_xform.auth.iv.length = iv_len;
    2940                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    2941                 :            :                         &ut_params->auth_xform, ts_params->session_mpool);
    2942   [ #  #  #  # ]:          0 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
    2943                 :            :                 return TEST_SKIPPED;
    2944                 :            : 
    2945         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    2946                 :            :         return 0;
    2947                 :            : }
    2948                 :            : 
    2949                 :            : static int
    2950                 :          0 : create_wireless_algo_cipher_session(uint8_t dev_id,
    2951                 :            :                         enum rte_crypto_cipher_operation op,
    2952                 :            :                         enum rte_crypto_cipher_algorithm algo,
    2953                 :            :                         const uint8_t *key, const uint8_t key_len,
    2954                 :            :                         uint8_t iv_len)
    2955                 :            : {
    2956                 :          0 :         uint8_t *cipher_key = alloca(key_len);
    2957                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    2958                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    2959                 :            : 
    2960                 :            :         memcpy(cipher_key, key, key_len);
    2961                 :            : 
    2962                 :            :         /* Setup Cipher Parameters */
    2963                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    2964                 :          0 :         ut_params->cipher_xform.next = NULL;
    2965                 :            : 
    2966                 :          0 :         ut_params->cipher_xform.cipher.algo = algo;
    2967                 :          0 :         ut_params->cipher_xform.cipher.op = op;
    2968                 :          0 :         ut_params->cipher_xform.cipher.key.data = cipher_key;
    2969                 :          0 :         ut_params->cipher_xform.cipher.key.length = key_len;
    2970                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    2971                 :          0 :         ut_params->cipher_xform.cipher.iv.length = iv_len;
    2972                 :            : 
    2973                 :          0 :         debug_hexdump(stdout, "key:", key, key_len);
    2974                 :            : 
    2975                 :            :         /* Create Crypto session */
    2976                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    2977                 :            :                         &ut_params->cipher_xform, ts_params->session_mpool);
    2978                 :            : 
    2979   [ #  #  #  # ]:          0 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
    2980                 :            :                 return TEST_SKIPPED;
    2981                 :            : 
    2982         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    2983                 :            :         return 0;
    2984                 :            : }
    2985                 :            : 
    2986                 :            : static int
    2987                 :          0 : create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
    2988                 :            :                         unsigned int cipher_len,
    2989                 :            :                         unsigned int cipher_offset)
    2990                 :            : {
    2991                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    2992                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    2993                 :            : 
    2994                 :            :         /* Generate Crypto op data structure */
    2995                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    2996                 :            :                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    2997         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    2998                 :            :                                 "Failed to allocate pktmbuf offload");
    2999                 :            : 
    3000                 :            :         /* Set crypto operation data parameters */
    3001         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    3002                 :            : 
    3003                 :          0 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    3004                 :            : 
    3005                 :            :         /* set crypto operation source mbuf */
    3006                 :          0 :         sym_op->m_src = ut_params->ibuf;
    3007                 :            : 
    3008                 :            :         /* iv */
    3009         [ #  # ]:          0 :         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
    3010                 :            :                         iv, iv_len);
    3011                 :          0 :         sym_op->cipher.data.length = cipher_len;
    3012                 :          0 :         sym_op->cipher.data.offset = cipher_offset;
    3013                 :          0 :         return 0;
    3014                 :            : }
    3015                 :            : 
    3016                 :            : static int
    3017                 :          0 : create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
    3018                 :            :                         unsigned int cipher_len,
    3019                 :            :                         unsigned int cipher_offset)
    3020                 :            : {
    3021                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3022                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3023                 :            : 
    3024                 :            :         /* Generate Crypto op data structure */
    3025                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    3026                 :            :                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    3027         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    3028                 :            :                                 "Failed to allocate pktmbuf offload");
    3029                 :            : 
    3030                 :            :         /* Set crypto operation data parameters */
    3031         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    3032                 :            : 
    3033                 :          0 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    3034                 :            : 
    3035                 :            :         /* set crypto operation source mbuf */
    3036                 :          0 :         sym_op->m_src = ut_params->ibuf;
    3037                 :          0 :         sym_op->m_dst = ut_params->obuf;
    3038                 :            : 
    3039                 :            :         /* iv */
    3040         [ #  # ]:          0 :         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
    3041                 :            :                         iv, iv_len);
    3042                 :          0 :         sym_op->cipher.data.length = cipher_len;
    3043                 :          0 :         sym_op->cipher.data.offset = cipher_offset;
    3044                 :          0 :         return 0;
    3045                 :            : }
    3046                 :            : 
    3047                 :            : static int
    3048                 :          1 : create_wireless_algo_cipher_auth_session(uint8_t dev_id,
    3049                 :            :                 enum rte_crypto_cipher_operation cipher_op,
    3050                 :            :                 enum rte_crypto_auth_operation auth_op,
    3051                 :            :                 enum rte_crypto_auth_algorithm auth_algo,
    3052                 :            :                 enum rte_crypto_cipher_algorithm cipher_algo,
    3053                 :            :                 const uint8_t *a_key, uint8_t a_key_len,
    3054                 :            :                 const uint8_t *c_key, uint8_t c_key_len,
    3055                 :            :                 uint8_t auth_iv_len, uint8_t auth_len,
    3056                 :            :                 uint8_t cipher_iv_len)
    3057                 :            : 
    3058                 :            : {
    3059                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3060                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3061                 :            : 
    3062                 :            :         /* Setup Authentication Parameters */
    3063                 :          1 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3064                 :          1 :         ut_params->auth_xform.next = NULL;
    3065                 :            : 
    3066                 :          1 :         ut_params->auth_xform.auth.op = auth_op;
    3067                 :          1 :         ut_params->auth_xform.auth.algo = auth_algo;
    3068                 :          1 :         ut_params->auth_xform.auth.key.length = a_key_len;
    3069                 :          1 :         ut_params->auth_xform.auth.key.data = a_key;
    3070                 :          1 :         ut_params->auth_xform.auth.digest_length = auth_len;
    3071                 :            :         /* Auth IV will be after cipher IV */
    3072                 :          1 :         ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
    3073                 :          1 :         ut_params->auth_xform.auth.iv.length = auth_iv_len;
    3074                 :            : 
    3075                 :            :         /* Setup Cipher Parameters */
    3076                 :          1 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    3077                 :          1 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
    3078                 :            : 
    3079                 :          1 :         ut_params->cipher_xform.cipher.algo = cipher_algo;
    3080                 :          1 :         ut_params->cipher_xform.cipher.op = cipher_op;
    3081                 :          1 :         ut_params->cipher_xform.cipher.key.data = c_key;
    3082                 :          1 :         ut_params->cipher_xform.cipher.key.length = c_key_len;
    3083                 :          1 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    3084                 :          1 :         ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
    3085                 :            : 
    3086                 :          1 :         debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
    3087                 :          1 :         debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
    3088                 :            : 
    3089                 :            :         /* Create Crypto session*/
    3090                 :          1 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    3091                 :            :                         &ut_params->cipher_xform, ts_params->session_mpool);
    3092   [ -  +  -  - ]:          1 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
    3093                 :            :                 return TEST_SKIPPED;
    3094                 :            : 
    3095         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    3096                 :            :         return 0;
    3097                 :            : }
    3098                 :            : 
    3099                 :            : static int
    3100                 :          0 : create_wireless_cipher_auth_session(uint8_t dev_id,
    3101                 :            :                 enum rte_crypto_cipher_operation cipher_op,
    3102                 :            :                 enum rte_crypto_auth_operation auth_op,
    3103                 :            :                 enum rte_crypto_auth_algorithm auth_algo,
    3104                 :            :                 enum rte_crypto_cipher_algorithm cipher_algo,
    3105                 :            :                 const struct wireless_test_data *tdata)
    3106                 :            : {
    3107                 :          0 :         const uint8_t key_len = tdata->key.len;
    3108                 :          0 :         uint8_t *cipher_auth_key = alloca(key_len);
    3109                 :            : 
    3110                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3111                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3112                 :          0 :         const uint8_t *key = tdata->key.data;
    3113                 :          0 :         const uint8_t auth_len = tdata->digest.len;
    3114                 :          0 :         uint8_t cipher_iv_len = tdata->cipher_iv.len;
    3115                 :          0 :         uint8_t auth_iv_len = tdata->auth_iv.len;
    3116                 :            : 
    3117                 :            :         memcpy(cipher_auth_key, key, key_len);
    3118                 :            : 
    3119                 :            :         /* Setup Authentication Parameters */
    3120                 :          0 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3121                 :          0 :         ut_params->auth_xform.next = NULL;
    3122                 :            : 
    3123                 :          0 :         ut_params->auth_xform.auth.op = auth_op;
    3124                 :          0 :         ut_params->auth_xform.auth.algo = auth_algo;
    3125                 :          0 :         ut_params->auth_xform.auth.key.length = key_len;
    3126                 :            :         /* Hash key = cipher key */
    3127                 :          0 :         ut_params->auth_xform.auth.key.data = cipher_auth_key;
    3128                 :          0 :         ut_params->auth_xform.auth.digest_length = auth_len;
    3129                 :            :         /* Auth IV will be after cipher IV */
    3130                 :          0 :         ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
    3131                 :          0 :         ut_params->auth_xform.auth.iv.length = auth_iv_len;
    3132                 :            : 
    3133                 :            :         /* Setup Cipher Parameters */
    3134                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    3135                 :          0 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
    3136                 :            : 
    3137                 :          0 :         ut_params->cipher_xform.cipher.algo = cipher_algo;
    3138                 :          0 :         ut_params->cipher_xform.cipher.op = cipher_op;
    3139                 :          0 :         ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
    3140                 :          0 :         ut_params->cipher_xform.cipher.key.length = key_len;
    3141                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    3142                 :          0 :         ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
    3143                 :            : 
    3144                 :            : 
    3145                 :          0 :         debug_hexdump(stdout, "key:", key, key_len);
    3146                 :            : 
    3147                 :            :         /* Create Crypto session*/
    3148                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    3149                 :            :                         &ut_params->cipher_xform, ts_params->session_mpool);
    3150   [ #  #  #  # ]:          0 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
    3151                 :            :                 return TEST_SKIPPED;
    3152                 :            : 
    3153         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    3154                 :            :         return 0;
    3155                 :            : }
    3156                 :            : 
    3157                 :            : static int
    3158                 :            : create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
    3159                 :            :                 const struct wireless_test_data *tdata)
    3160                 :            : {
    3161                 :          0 :         return create_wireless_cipher_auth_session(dev_id,
    3162                 :            :                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    3163                 :            :                 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
    3164                 :            :                 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
    3165                 :            : }
    3166                 :            : 
    3167                 :            : static int
    3168                 :          1 : create_wireless_algo_auth_cipher_session(uint8_t dev_id,
    3169                 :            :                 enum rte_crypto_cipher_operation cipher_op,
    3170                 :            :                 enum rte_crypto_auth_operation auth_op,
    3171                 :            :                 enum rte_crypto_auth_algorithm auth_algo,
    3172                 :            :                 enum rte_crypto_cipher_algorithm cipher_algo,
    3173                 :            :                 const uint8_t *a_key, const uint8_t a_key_len,
    3174                 :            :                 const uint8_t *c_key, const uint8_t c_key_len,
    3175                 :            :                 uint8_t auth_iv_len, uint8_t auth_len,
    3176                 :            :                 uint8_t cipher_iv_len)
    3177                 :            : {
    3178                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3179                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3180                 :            : 
    3181                 :            :         /* Setup Authentication Parameters */
    3182                 :          1 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3183                 :          1 :         ut_params->auth_xform.auth.op = auth_op;
    3184                 :          1 :         ut_params->auth_xform.next = &ut_params->cipher_xform;
    3185                 :          1 :         ut_params->auth_xform.auth.algo = auth_algo;
    3186                 :          1 :         ut_params->auth_xform.auth.key.length = a_key_len;
    3187                 :          1 :         ut_params->auth_xform.auth.key.data = a_key;
    3188                 :          1 :         ut_params->auth_xform.auth.digest_length = auth_len;
    3189                 :            :         /* Auth IV will be after cipher IV */
    3190                 :          1 :         ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
    3191                 :          1 :         ut_params->auth_xform.auth.iv.length = auth_iv_len;
    3192                 :            : 
    3193                 :            :         /* Setup Cipher Parameters */
    3194                 :          1 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    3195                 :          1 :         ut_params->cipher_xform.next = NULL;
    3196                 :          1 :         ut_params->cipher_xform.cipher.algo = cipher_algo;
    3197                 :          1 :         ut_params->cipher_xform.cipher.op = cipher_op;
    3198                 :          1 :         ut_params->cipher_xform.cipher.key.data = c_key;
    3199                 :          1 :         ut_params->cipher_xform.cipher.key.length = c_key_len;
    3200                 :          1 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    3201                 :          1 :         ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
    3202                 :            : 
    3203                 :          1 :         debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
    3204                 :          1 :         debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
    3205                 :            : 
    3206                 :            :         /* Create Crypto session*/
    3207         [ -  + ]:          1 :         if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
    3208                 :          0 :                 ut_params->auth_xform.next = NULL;
    3209                 :          0 :                 ut_params->cipher_xform.next = &ut_params->auth_xform;
    3210                 :          0 :                 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    3211                 :            :                         &ut_params->cipher_xform, ts_params->session_mpool);
    3212                 :            :         } else
    3213                 :          1 :                 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    3214                 :            :                         &ut_params->auth_xform, ts_params->session_mpool);
    3215                 :            : 
    3216   [ -  +  -  - ]:          1 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
    3217                 :            :                 return TEST_SKIPPED;
    3218                 :            : 
    3219         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    3220                 :            : 
    3221                 :            :         return 0;
    3222                 :            : }
    3223                 :            : 
    3224                 :            : static int
    3225                 :          0 : create_wireless_algo_hash_operation(const uint8_t *auth_tag,
    3226                 :            :                 unsigned int auth_tag_len,
    3227                 :            :                 const uint8_t *iv, unsigned int iv_len,
    3228                 :            :                 unsigned int data_pad_len,
    3229                 :            :                 enum rte_crypto_auth_operation op,
    3230                 :            :                 unsigned int auth_len, unsigned int auth_offset)
    3231                 :            : {
    3232                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3233                 :            : 
    3234                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3235                 :            : 
    3236                 :            :         /* Generate Crypto op data structure */
    3237                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    3238                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    3239         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    3240                 :            :                 "Failed to allocate pktmbuf offload");
    3241                 :            : 
    3242                 :            :         /* Set crypto operation data parameters */
    3243         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    3244                 :            : 
    3245                 :          0 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    3246                 :            : 
    3247                 :            :         /* set crypto operation source mbuf */
    3248                 :          0 :         sym_op->m_src = ut_params->ibuf;
    3249                 :            : 
    3250                 :            :         /* iv */
    3251         [ #  # ]:          0 :         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
    3252                 :            :                         iv, iv_len);
    3253                 :            :         /* digest */
    3254                 :          0 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
    3255                 :            :                                         ut_params->ibuf, auth_tag_len);
    3256                 :            : 
    3257         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
    3258                 :            :                                 "no room to append auth tag");
    3259                 :          0 :         ut_params->digest = sym_op->auth.digest.data;
    3260         [ #  # ]:          0 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    3261                 :            :                         ut_params->ibuf, data_pad_len);
    3262         [ #  # ]:          0 :         if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
    3263                 :          0 :                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
    3264                 :            :         else
    3265         [ #  # ]:          0 :                 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
    3266                 :            : 
    3267                 :          0 :         debug_hexdump(stdout, "digest:",
    3268                 :          0 :                 sym_op->auth.digest.data,
    3269                 :            :                 auth_tag_len);
    3270                 :            : 
    3271                 :          0 :         sym_op->auth.data.length = auth_len;
    3272                 :          0 :         sym_op->auth.data.offset = auth_offset;
    3273                 :            : 
    3274                 :          0 :         return 0;
    3275                 :            : }
    3276                 :            : 
    3277                 :            : static int
    3278                 :          0 : create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
    3279                 :            :         enum rte_crypto_auth_operation op)
    3280                 :            : {
    3281                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3282                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3283                 :            : 
    3284                 :          0 :         const uint8_t *auth_tag = tdata->digest.data;
    3285                 :          0 :         const unsigned int auth_tag_len = tdata->digest.len;
    3286         [ #  # ]:          0 :         unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
    3287                 :          0 :         unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    3288                 :            : 
    3289                 :          0 :         const uint8_t *cipher_iv = tdata->cipher_iv.data;
    3290                 :          0 :         const uint8_t cipher_iv_len = tdata->cipher_iv.len;
    3291                 :          0 :         const uint8_t *auth_iv = tdata->auth_iv.data;
    3292                 :          0 :         const uint8_t auth_iv_len = tdata->auth_iv.len;
    3293                 :          0 :         const unsigned int cipher_len = tdata->validCipherLenInBits.len;
    3294                 :          0 :         const unsigned int auth_len = tdata->validAuthLenInBits.len;
    3295                 :            : 
    3296                 :            :         /* Generate Crypto op data structure */
    3297                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    3298                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    3299         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    3300                 :            :                         "Failed to allocate pktmbuf offload");
    3301                 :            :         /* Set crypto operation data parameters */
    3302         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    3303                 :            : 
    3304                 :          0 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    3305                 :            : 
    3306                 :            :         /* set crypto operation source mbuf */
    3307                 :          0 :         sym_op->m_src = ut_params->ibuf;
    3308                 :            : 
    3309                 :            :         /* digest */
    3310                 :          0 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
    3311                 :            :                         ut_params->ibuf, auth_tag_len);
    3312                 :            : 
    3313         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
    3314                 :            :                         "no room to append auth tag");
    3315                 :          0 :         ut_params->digest = sym_op->auth.digest.data;
    3316         [ #  # ]:          0 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    3317                 :            :                         ut_params->ibuf, data_pad_len);
    3318         [ #  # ]:          0 :         if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
    3319                 :          0 :                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
    3320                 :            :         else
    3321         [ #  # ]:          0 :                 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
    3322                 :            : 
    3323                 :          0 :         debug_hexdump(stdout, "digest:",
    3324                 :          0 :                 sym_op->auth.digest.data,
    3325                 :            :                 auth_tag_len);
    3326                 :            : 
    3327                 :            :         /* Copy cipher and auth IVs at the end of the crypto operation */
    3328                 :          0 :         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
    3329                 :            :                                                 IV_OFFSET);
    3330         [ #  # ]:          0 :         rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
    3331                 :          0 :         iv_ptr += cipher_iv_len;
    3332         [ #  # ]:          0 :         rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
    3333                 :            : 
    3334                 :          0 :         sym_op->cipher.data.length = cipher_len;
    3335                 :          0 :         sym_op->cipher.data.offset = 0;
    3336                 :          0 :         sym_op->auth.data.length = auth_len;
    3337                 :          0 :         sym_op->auth.data.offset = 0;
    3338                 :            : 
    3339                 :          0 :         return 0;
    3340                 :            : }
    3341                 :            : 
    3342                 :            : static int
    3343                 :            : create_zuc_cipher_hash_generate_operation(
    3344                 :            :                 const struct wireless_test_data *tdata)
    3345                 :            : {
    3346                 :          0 :         return create_wireless_cipher_hash_operation(tdata,
    3347                 :            :                 RTE_CRYPTO_AUTH_OP_GENERATE);
    3348                 :            : }
    3349                 :            : 
    3350                 :            : static int
    3351                 :          0 : create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
    3352                 :            :                 const unsigned auth_tag_len,
    3353                 :            :                 const uint8_t *auth_iv, uint8_t auth_iv_len,
    3354                 :            :                 unsigned data_pad_len,
    3355                 :            :                 enum rte_crypto_auth_operation op,
    3356                 :            :                 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
    3357                 :            :                 const unsigned cipher_len, const unsigned cipher_offset,
    3358                 :            :                 const unsigned auth_len, const unsigned auth_offset)
    3359                 :            : {
    3360                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3361                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3362                 :            : 
    3363                 :          0 :         enum rte_crypto_cipher_algorithm cipher_algo =
    3364                 :            :                         ut_params->cipher_xform.cipher.algo;
    3365                 :          0 :         enum rte_crypto_auth_algorithm auth_algo =
    3366                 :            :                         ut_params->auth_xform.auth.algo;
    3367                 :            : 
    3368                 :            :         /* Generate Crypto op data structure */
    3369                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    3370                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    3371         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    3372                 :            :                         "Failed to allocate pktmbuf offload");
    3373                 :            :         /* Set crypto operation data parameters */
    3374         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    3375                 :            : 
    3376                 :          0 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    3377                 :            : 
    3378                 :            :         /* set crypto operation source mbuf */
    3379                 :          0 :         sym_op->m_src = ut_params->ibuf;
    3380                 :            : 
    3381                 :            :         /* digest */
    3382                 :          0 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
    3383                 :            :                         ut_params->ibuf, auth_tag_len);
    3384                 :            : 
    3385         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
    3386                 :            :                         "no room to append auth tag");
    3387                 :          0 :         ut_params->digest = sym_op->auth.digest.data;
    3388                 :            : 
    3389         [ #  # ]:          0 :         if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
    3390                 :          0 :                 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    3391                 :            :                                 ut_params->ibuf, data_pad_len);
    3392                 :            :         } else {
    3393                 :            :                 struct rte_mbuf *m = ut_params->ibuf;
    3394                 :            :                 unsigned int offset = data_pad_len;
    3395                 :            : 
    3396   [ #  #  #  # ]:          0 :                 while (offset > m->data_len && m->next != NULL) {
    3397                 :          0 :                         offset -= m->data_len;
    3398                 :            :                         m = m->next;
    3399                 :            :                 }
    3400                 :          0 :                 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    3401                 :            :                         m, offset);
    3402                 :            :         }
    3403                 :            : 
    3404         [ #  # ]:          0 :         if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
    3405                 :          0 :                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
    3406                 :            :         else
    3407         [ #  # ]:          0 :                 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
    3408                 :            : 
    3409                 :          0 :         debug_hexdump(stdout, "digest:",
    3410                 :          0 :                 sym_op->auth.digest.data,
    3411                 :            :                 auth_tag_len);
    3412                 :            : 
    3413                 :            :         /* Copy cipher and auth IVs at the end of the crypto operation */
    3414                 :          0 :         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
    3415                 :            :                                                 IV_OFFSET);
    3416         [ #  # ]:          0 :         rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
    3417                 :          0 :         iv_ptr += cipher_iv_len;
    3418         [ #  # ]:          0 :         rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
    3419                 :            : 
    3420                 :          0 :         if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
    3421         [ #  # ]:          0 :                 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
    3422                 :            :                 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
    3423                 :          0 :                 sym_op->cipher.data.length = cipher_len;
    3424                 :          0 :                 sym_op->cipher.data.offset = cipher_offset;
    3425                 :            :         } else {
    3426                 :          0 :                 sym_op->cipher.data.length = cipher_len >> 3;
    3427                 :          0 :                 sym_op->cipher.data.offset = cipher_offset >> 3;
    3428                 :            :         }
    3429                 :            : 
    3430                 :          0 :         if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
    3431   [ #  #  #  # ]:          0 :                 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
    3432                 :            :                 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
    3433                 :          0 :                 sym_op->auth.data.length = auth_len;
    3434                 :          0 :                 sym_op->auth.data.offset = auth_offset;
    3435                 :            :         } else {
    3436                 :          0 :                 sym_op->auth.data.length = auth_len >> 3;
    3437                 :          0 :                 sym_op->auth.data.offset = auth_offset >> 3;
    3438                 :            :         }
    3439                 :            : 
    3440                 :            :         return 0;
    3441                 :            : }
    3442                 :            : 
    3443                 :            : static int
    3444                 :          2 : create_wireless_algo_auth_cipher_operation(
    3445                 :            :                 const uint8_t *auth_tag, unsigned int auth_tag_len,
    3446                 :            :                 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
    3447                 :            :                 const uint8_t *auth_iv, uint8_t auth_iv_len,
    3448                 :            :                 unsigned int data_pad_len,
    3449                 :            :                 unsigned int cipher_len, unsigned int cipher_offset,
    3450                 :            :                 unsigned int auth_len, unsigned int auth_offset,
    3451                 :            :                 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
    3452                 :            : {
    3453                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3454                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3455                 :            : 
    3456                 :          2 :         enum rte_crypto_cipher_algorithm cipher_algo =
    3457                 :            :                         ut_params->cipher_xform.cipher.algo;
    3458                 :          2 :         enum rte_crypto_auth_algorithm auth_algo =
    3459                 :            :                         ut_params->auth_xform.auth.algo;
    3460                 :            : 
    3461                 :            :         /* Generate Crypto op data structure */
    3462                 :          2 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    3463                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    3464         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    3465                 :            :                         "Failed to allocate pktmbuf offload");
    3466                 :            : 
    3467                 :            :         /* Set crypto operation data parameters */
    3468         [ +  - ]:          2 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    3469                 :            : 
    3470                 :          2 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    3471                 :            : 
    3472                 :            :         /* set crypto operation mbufs */
    3473                 :          2 :         sym_op->m_src = ut_params->ibuf;
    3474         [ -  + ]:          2 :         if (op_mode == OUT_OF_PLACE)
    3475                 :          0 :                 sym_op->m_dst = ut_params->obuf;
    3476                 :            : 
    3477                 :            :         /* digest */
    3478         [ -  + ]:          2 :         if (!do_sgl) {
    3479         [ #  # ]:          0 :                 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
    3480                 :            :                         (op_mode == IN_PLACE ?
    3481                 :            :                                 ut_params->ibuf : ut_params->obuf),
    3482                 :            :                         uint8_t *, data_pad_len);
    3483         [ #  # ]:          0 :                 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    3484                 :            :                         (op_mode == IN_PLACE ?
    3485                 :            :                                 ut_params->ibuf : ut_params->obuf),
    3486                 :            :                         data_pad_len);
    3487                 :          0 :                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
    3488                 :            :         } else {
    3489                 :          2 :                 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
    3490                 :            :                 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
    3491         [ -  + ]:          2 :                                 sym_op->m_src : sym_op->m_dst);
    3492                 :            :                 struct rte_mbuf *sgl_buf_head = sgl_buf;
    3493                 :            : 
    3494         [ +  + ]:         32 :                 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
    3495                 :         30 :                         remaining_off -= rte_pktmbuf_data_len(sgl_buf);
    3496                 :         30 :                         sgl_buf = sgl_buf->next;
    3497                 :            :                 }
    3498                 :            : 
    3499                 :            :                 /* The last segment should be large enough to hold full digest */
    3500         [ -  + ]:          2 :                 if (sgl_buf->data_len < auth_tag_len) {
    3501                 :            :                         uint16_t next_data_len = 0;
    3502         [ #  # ]:          0 :                         if (sgl_buf->next != NULL) {
    3503                 :          0 :                                 next_data_len = sgl_buf->next->data_len;
    3504                 :            : 
    3505                 :          0 :                                 rte_pktmbuf_free(sgl_buf->next);
    3506                 :          0 :                                 sgl_buf->next = NULL;
    3507                 :          0 :                                 sgl_buf_head->nb_segs -= 1;
    3508                 :          0 :                                 sgl_buf_head->pkt_len -= next_data_len;
    3509                 :            :                         }
    3510         [ #  # ]:          0 :                         TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(
    3511                 :            :                                                 sgl_buf_head, auth_tag_len - sgl_buf->data_len),
    3512                 :            :                                                 "No room to append auth tag");
    3513                 :            :                 }
    3514                 :            : 
    3515                 :          2 :                 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
    3516                 :            :                                 uint8_t *, remaining_off);
    3517                 :          2 :                 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
    3518                 :            :                                 remaining_off);
    3519                 :            :                 memset(sym_op->auth.digest.data, 0, remaining_off);
    3520         [ -  + ]:          2 :                 while (sgl_buf->next != NULL) {
    3521                 :          0 :                         memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
    3522                 :          0 :                                 0, rte_pktmbuf_data_len(sgl_buf));
    3523                 :          0 :                         sgl_buf = sgl_buf->next;
    3524                 :            :                 }
    3525                 :            :         }
    3526                 :            : 
    3527                 :            :         /* Copy digest for the verification */
    3528         [ +  + ]:          2 :         if (verify)
    3529                 :          1 :                 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
    3530                 :            : 
    3531                 :            :         /* Copy cipher and auth IVs at the end of the crypto operation */
    3532                 :          2 :         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
    3533                 :            :                         ut_params->op, uint8_t *, IV_OFFSET);
    3534                 :            : 
    3535         [ -  + ]:          2 :         rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
    3536                 :          2 :         iv_ptr += cipher_iv_len;
    3537         [ -  + ]:          2 :         rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
    3538                 :            : 
    3539                 :            :         /* Only copy over the offset data needed from src to dst in OOP,
    3540                 :            :          * if the auth and cipher offsets are not aligned
    3541                 :            :          */
    3542         [ -  + ]:          2 :         if (op_mode == OUT_OF_PLACE) {
    3543         [ #  # ]:          0 :                 if (cipher_offset > auth_offset)
    3544                 :          0 :                         rte_memcpy(
    3545                 :          0 :                                 rte_pktmbuf_mtod_offset(
    3546                 :            :                                         sym_op->m_dst,
    3547                 :            :                                         uint8_t *, auth_offset >> 3),
    3548                 :          0 :                                 rte_pktmbuf_mtod_offset(
    3549                 :            :                                         sym_op->m_src,
    3550                 :            :                                         uint8_t *, auth_offset >> 3),
    3551         [ #  # ]:          0 :                                 ((cipher_offset >> 3) - (auth_offset >> 3)));
    3552                 :            :         }
    3553                 :            : 
    3554                 :          2 :         if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
    3555         [ -  + ]:          2 :                 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
    3556                 :            :                 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
    3557                 :          0 :                 sym_op->cipher.data.length = cipher_len;
    3558                 :          0 :                 sym_op->cipher.data.offset = cipher_offset;
    3559                 :            :         } else {
    3560                 :          2 :                 sym_op->cipher.data.length = cipher_len >> 3;
    3561                 :          2 :                 sym_op->cipher.data.offset = cipher_offset >> 3;
    3562                 :            :         }
    3563                 :            : 
    3564                 :          2 :         if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
    3565   [ +  -  -  + ]:          2 :                 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
    3566                 :            :                 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
    3567                 :          0 :                 sym_op->auth.data.length = auth_len;
    3568                 :          0 :                 sym_op->auth.data.offset = auth_offset;
    3569                 :            :         } else {
    3570                 :          2 :                 sym_op->auth.data.length = auth_len >> 3;
    3571                 :          2 :                 sym_op->auth.data.offset = auth_offset >> 3;
    3572                 :            :         }
    3573                 :            : 
    3574                 :            :         return 0;
    3575                 :            : }
    3576                 :            : 
    3577                 :            : static int
    3578                 :          0 : test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
    3579                 :            : {
    3580                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3581                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3582                 :            : 
    3583                 :            :         int retval;
    3584                 :            :         unsigned plaintext_pad_len;
    3585                 :            :         unsigned plaintext_len;
    3586                 :            :         uint8_t *plaintext;
    3587                 :            :         struct rte_cryptodev_info dev_info;
    3588                 :            : 
    3589                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    3590                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    3591                 :            : 
    3592         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
    3593         [ #  # ]:          0 :                         ((tdata->validAuthLenInBits.len % 8) != 0)) {
    3594                 :            :                 printf("Device doesn't support NON-Byte Aligned Data.\n");
    3595                 :          0 :                 return TEST_SKIPPED;
    3596                 :            :         }
    3597                 :            : 
    3598         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    3599         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    3600                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    3601                 :          0 :                 return TEST_SKIPPED;
    3602                 :            :         }
    3603                 :            : 
    3604         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    3605                 :            :                 return TEST_SKIPPED;
    3606                 :            : 
    3607                 :            :         /* Verify the capabilities */
    3608                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    3609                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3610                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
    3611         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    3612                 :            :                         &cap_idx) == NULL)
    3613                 :            :                 return TEST_SKIPPED;
    3614                 :            : 
    3615                 :            :         /* Create SNOW 3G session */
    3616                 :          0 :         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
    3617                 :          0 :                         tdata->key.data, tdata->key.len,
    3618                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    3619                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
    3620                 :            :                         RTE_CRYPTO_AUTH_SNOW3G_UIA2);
    3621         [ #  # ]:          0 :         if (retval < 0)
    3622                 :            :                 return retval;
    3623                 :            : 
    3624                 :            :         /* alloc mbuf and set payload */
    3625         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    3626                 :            : 
    3627         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    3628                 :            :         rte_pktmbuf_tailroom(ut_params->ibuf));
    3629                 :            : 
    3630         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    3631                 :            :         /* Append data which is padded to a multiple of */
    3632                 :            :         /* the algorithms block size */
    3633                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    3634                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    3635                 :            :                                 plaintext_pad_len);
    3636                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    3637                 :            : 
    3638                 :            :         /* Create SNOW 3G operation */
    3639                 :          0 :         retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
    3640                 :          0 :                         tdata->auth_iv.data, tdata->auth_iv.len,
    3641                 :            :                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
    3642                 :          0 :                         tdata->validAuthLenInBits.len,
    3643                 :            :                         0);
    3644         [ #  # ]:          0 :         if (retval < 0)
    3645                 :            :                 return retval;
    3646                 :            : 
    3647         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    3648                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
    3649                 :            :                                                0);
    3650         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    3651                 :            :                         return retval;
    3652                 :            :         } else
    3653                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    3654                 :            :                                 ut_params->op);
    3655                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    3656                 :            :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    3657                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    3658                 :            :                                                     uint8_t *,
    3659                 :            :                                                     plaintext_pad_len);
    3660                 :            : 
    3661                 :            :         /* Validate obuf */
    3662         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    3663                 :            :         ut_params->digest,
    3664                 :            :         tdata->digest.data,
    3665                 :            :         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
    3666                 :            :         "SNOW 3G Generated auth tag not as expected");
    3667                 :            : 
    3668                 :            :         return 0;
    3669                 :            : }
    3670                 :            : 
    3671                 :            : static int
    3672                 :          0 : test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
    3673                 :            : {
    3674                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3675                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3676                 :            : 
    3677                 :            :         int retval;
    3678                 :            :         unsigned plaintext_pad_len;
    3679                 :            :         unsigned plaintext_len;
    3680                 :            :         uint8_t *plaintext;
    3681                 :            :         struct rte_cryptodev_info dev_info;
    3682                 :            : 
    3683                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    3684                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    3685                 :            : 
    3686         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
    3687         [ #  # ]:          0 :                         ((tdata->validAuthLenInBits.len % 8) != 0)) {
    3688                 :            :                 printf("Device doesn't support NON-Byte Aligned Data.\n");
    3689                 :          0 :                 return TEST_SKIPPED;
    3690                 :            :         }
    3691                 :            : 
    3692         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    3693         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    3694                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    3695                 :          0 :                 return TEST_SKIPPED;
    3696                 :            :         }
    3697                 :            : 
    3698         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    3699                 :            :                 return TEST_SKIPPED;
    3700                 :            : 
    3701                 :            :         /* Verify the capabilities */
    3702                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    3703                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3704                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
    3705         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    3706                 :            :                         &cap_idx) == NULL)
    3707                 :            :                 return TEST_SKIPPED;
    3708                 :            : 
    3709                 :            :         /* Create SNOW 3G session */
    3710                 :          0 :         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
    3711                 :          0 :                                 tdata->key.data, tdata->key.len,
    3712                 :          0 :                                 tdata->auth_iv.len, tdata->digest.len,
    3713                 :            :                                 RTE_CRYPTO_AUTH_OP_VERIFY,
    3714                 :            :                                 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
    3715         [ #  # ]:          0 :         if (retval < 0)
    3716                 :            :                 return retval;
    3717                 :            :         /* alloc mbuf and set payload */
    3718         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    3719                 :            : 
    3720         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    3721                 :            :         rte_pktmbuf_tailroom(ut_params->ibuf));
    3722                 :            : 
    3723         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    3724                 :            :         /* Append data which is padded to a multiple of */
    3725                 :            :         /* the algorithms block size */
    3726                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    3727                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    3728                 :            :                                 plaintext_pad_len);
    3729                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    3730                 :            : 
    3731                 :            :         /* Create SNOW 3G operation */
    3732                 :          0 :         retval = create_wireless_algo_hash_operation(tdata->digest.data,
    3733                 :          0 :                         tdata->digest.len,
    3734                 :          0 :                         tdata->auth_iv.data, tdata->auth_iv.len,
    3735                 :            :                         plaintext_pad_len,
    3736                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY,
    3737                 :          0 :                         tdata->validAuthLenInBits.len,
    3738                 :            :                         0);
    3739         [ #  # ]:          0 :         if (retval < 0)
    3740                 :            :                 return retval;
    3741                 :            : 
    3742         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    3743                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
    3744                 :            :                                                0);
    3745         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    3746                 :            :                         return retval;
    3747                 :            :         } else
    3748                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    3749                 :            :                                 ut_params->op);
    3750         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    3751                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    3752                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    3753                 :            :                                                     uint8_t *,
    3754                 :            :                                                     plaintext_pad_len);
    3755                 :            : 
    3756                 :            :         /* Validate obuf */
    3757         [ #  # ]:          0 :         if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
    3758                 :            :                 return 0;
    3759                 :            :         else
    3760                 :          0 :                 return -1;
    3761                 :            : 
    3762                 :            :         return 0;
    3763                 :            : }
    3764                 :            : 
    3765                 :            : static int
    3766                 :          0 : test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
    3767                 :            : {
    3768                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3769                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3770                 :            : 
    3771                 :            :         int retval;
    3772                 :            :         unsigned plaintext_pad_len;
    3773                 :            :         unsigned plaintext_len;
    3774                 :            :         uint8_t *plaintext;
    3775                 :            :         struct rte_cryptodev_info dev_info;
    3776                 :            : 
    3777                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    3778                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    3779                 :            : 
    3780         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    3781         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    3782                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    3783                 :          0 :                 return TEST_SKIPPED;
    3784                 :            :         }
    3785                 :            : 
    3786         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    3787                 :            :                 return TEST_SKIPPED;
    3788                 :            : 
    3789                 :            :         /* Verify the capabilities */
    3790                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    3791                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3792                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
    3793         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    3794                 :            :                         &cap_idx) == NULL)
    3795                 :            :                 return TEST_SKIPPED;
    3796                 :            : 
    3797                 :            :         /* Create KASUMI session */
    3798                 :          0 :         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
    3799                 :          0 :                         tdata->key.data, tdata->key.len,
    3800                 :          0 :                         0, tdata->digest.len,
    3801                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
    3802                 :            :                         RTE_CRYPTO_AUTH_KASUMI_F9);
    3803         [ #  # ]:          0 :         if (retval < 0)
    3804                 :            :                 return retval;
    3805                 :            : 
    3806                 :            :         /* alloc mbuf and set payload */
    3807         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    3808                 :            : 
    3809         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    3810                 :            :         rte_pktmbuf_tailroom(ut_params->ibuf));
    3811                 :            : 
    3812         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    3813                 :            :         /* Append data which is padded to a multiple of */
    3814                 :            :         /* the algorithms block size */
    3815                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    3816                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    3817                 :            :                                 plaintext_pad_len);
    3818                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    3819                 :            : 
    3820                 :            :         /* Create KASUMI operation */
    3821                 :          0 :         retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
    3822                 :            :                         NULL, 0,
    3823                 :            :                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
    3824                 :          0 :                         tdata->plaintext.len,
    3825                 :            :                         0);
    3826         [ #  # ]:          0 :         if (retval < 0)
    3827                 :            :                 return retval;
    3828                 :            : 
    3829         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    3830                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
    3831                 :            :                         ut_params->op);
    3832         [ #  # ]:          0 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    3833                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
    3834                 :            :                                                0);
    3835         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    3836                 :            :                         return retval;
    3837                 :            :         } else
    3838                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    3839                 :            :                         ut_params->op);
    3840                 :            : 
    3841                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    3842                 :            :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    3843                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    3844                 :            :                                                     uint8_t *,
    3845                 :            :                                                     plaintext_pad_len);
    3846                 :            : 
    3847                 :            :         /* Validate obuf */
    3848         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    3849                 :            :         ut_params->digest,
    3850                 :            :         tdata->digest.data,
    3851                 :            :         DIGEST_BYTE_LENGTH_KASUMI_F9,
    3852                 :            :         "KASUMI Generated auth tag not as expected");
    3853                 :            : 
    3854                 :            :         return 0;
    3855                 :            : }
    3856                 :            : 
    3857                 :            : static int
    3858                 :          0 : test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
    3859                 :            : {
    3860                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3861                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3862                 :            : 
    3863                 :            :         int retval;
    3864                 :            :         unsigned plaintext_pad_len;
    3865                 :            :         unsigned plaintext_len;
    3866                 :            :         uint8_t *plaintext;
    3867                 :            :         struct rte_cryptodev_info dev_info;
    3868                 :            : 
    3869                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    3870                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    3871                 :            : 
    3872         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    3873         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    3874                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    3875                 :          0 :                 return TEST_SKIPPED;
    3876                 :            :         }
    3877                 :            : 
    3878         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    3879                 :            :                 return TEST_SKIPPED;
    3880                 :            : 
    3881                 :            :         /* Verify the capabilities */
    3882                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    3883                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3884                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
    3885         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    3886                 :            :                         &cap_idx) == NULL)
    3887                 :            :                 return TEST_SKIPPED;
    3888                 :            : 
    3889                 :            :         /* Create KASUMI session */
    3890                 :          0 :         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
    3891                 :          0 :                                 tdata->key.data, tdata->key.len,
    3892                 :          0 :                                 0, tdata->digest.len,
    3893                 :            :                                 RTE_CRYPTO_AUTH_OP_VERIFY,
    3894                 :            :                                 RTE_CRYPTO_AUTH_KASUMI_F9);
    3895         [ #  # ]:          0 :         if (retval < 0)
    3896                 :            :                 return retval;
    3897                 :            :         /* alloc mbuf and set payload */
    3898         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    3899                 :            : 
    3900         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    3901                 :            :         rte_pktmbuf_tailroom(ut_params->ibuf));
    3902                 :            : 
    3903         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    3904                 :            :         /* Append data which is padded to a multiple */
    3905                 :            :         /* of the algorithms block size */
    3906                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    3907                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    3908                 :            :                                 plaintext_pad_len);
    3909                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    3910                 :            : 
    3911                 :            :         /* Create KASUMI operation */
    3912                 :          0 :         retval = create_wireless_algo_hash_operation(tdata->digest.data,
    3913                 :          0 :                         tdata->digest.len,
    3914                 :            :                         NULL, 0,
    3915                 :            :                         plaintext_pad_len,
    3916                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY,
    3917                 :          0 :                         tdata->plaintext.len,
    3918                 :            :                         0);
    3919         [ #  # ]:          0 :         if (retval < 0)
    3920                 :            :                 return retval;
    3921                 :            : 
    3922         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    3923                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
    3924                 :            :                                                0);
    3925         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    3926                 :            :                         return retval;
    3927                 :            :         } else
    3928                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    3929                 :            :                                 ut_params->op);
    3930         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    3931                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    3932                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    3933                 :            :                                                     uint8_t *,
    3934                 :            :                                                     plaintext_pad_len);
    3935                 :            : 
    3936                 :            :         /* Validate obuf */
    3937         [ #  # ]:          0 :         if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
    3938                 :            :                 return 0;
    3939                 :            :         else
    3940                 :          0 :                 return -1;
    3941                 :            : 
    3942                 :            :         return 0;
    3943                 :            : }
    3944                 :            : 
    3945                 :            : static int
    3946                 :          0 : test_snow3g_hash_generate_test_case_1(void)
    3947                 :            : {
    3948                 :          0 :         return test_snow3g_authentication(&snow3g_hash_test_case_1);
    3949                 :            : }
    3950                 :            : 
    3951                 :            : static int
    3952                 :          0 : test_snow3g_hash_generate_test_case_2(void)
    3953                 :            : {
    3954                 :          0 :         return test_snow3g_authentication(&snow3g_hash_test_case_2);
    3955                 :            : }
    3956                 :            : 
    3957                 :            : static int
    3958                 :          0 : test_snow3g_hash_generate_test_case_3(void)
    3959                 :            : {
    3960                 :          0 :         return test_snow3g_authentication(&snow3g_hash_test_case_3);
    3961                 :            : }
    3962                 :            : 
    3963                 :            : static int
    3964                 :          0 : test_snow3g_hash_generate_test_case_4(void)
    3965                 :            : {
    3966                 :          0 :         return test_snow3g_authentication(&snow3g_hash_test_case_4);
    3967                 :            : }
    3968                 :            : 
    3969                 :            : static int
    3970                 :          0 : test_snow3g_hash_generate_test_case_5(void)
    3971                 :            : {
    3972                 :          0 :         return test_snow3g_authentication(&snow3g_hash_test_case_5);
    3973                 :            : }
    3974                 :            : 
    3975                 :            : static int
    3976                 :          0 : test_snow3g_hash_generate_test_case_6(void)
    3977                 :            : {
    3978                 :          0 :         return test_snow3g_authentication(&snow3g_hash_test_case_6);
    3979                 :            : }
    3980                 :            : 
    3981                 :            : static int
    3982                 :          0 : test_snow3g_hash_verify_test_case_1(void)
    3983                 :            : {
    3984                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
    3985                 :            : 
    3986                 :            : }
    3987                 :            : 
    3988                 :            : static int
    3989                 :          0 : test_snow3g_hash_verify_test_case_2(void)
    3990                 :            : {
    3991                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
    3992                 :            : }
    3993                 :            : 
    3994                 :            : static int
    3995                 :          0 : test_snow3g_hash_verify_test_case_3(void)
    3996                 :            : {
    3997                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
    3998                 :            : }
    3999                 :            : 
    4000                 :            : static int
    4001                 :          0 : test_snow3g_hash_verify_test_case_4(void)
    4002                 :            : {
    4003                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
    4004                 :            : }
    4005                 :            : 
    4006                 :            : static int
    4007                 :          0 : test_snow3g_hash_verify_test_case_5(void)
    4008                 :            : {
    4009                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
    4010                 :            : }
    4011                 :            : 
    4012                 :            : static int
    4013                 :          0 : test_snow3g_hash_verify_test_case_6(void)
    4014                 :            : {
    4015                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
    4016                 :            : }
    4017                 :            : 
    4018                 :            : static int
    4019                 :          0 : test_kasumi_hash_generate_test_case_1(void)
    4020                 :            : {
    4021                 :          0 :         return test_kasumi_authentication(&kasumi_hash_test_case_1);
    4022                 :            : }
    4023                 :            : 
    4024                 :            : static int
    4025                 :          0 : test_kasumi_hash_generate_test_case_2(void)
    4026                 :            : {
    4027                 :          0 :         return test_kasumi_authentication(&kasumi_hash_test_case_2);
    4028                 :            : }
    4029                 :            : 
    4030                 :            : static int
    4031                 :          0 : test_kasumi_hash_generate_test_case_3(void)
    4032                 :            : {
    4033                 :          0 :         return test_kasumi_authentication(&kasumi_hash_test_case_3);
    4034                 :            : }
    4035                 :            : 
    4036                 :            : static int
    4037                 :          0 : test_kasumi_hash_generate_test_case_4(void)
    4038                 :            : {
    4039                 :          0 :         return test_kasumi_authentication(&kasumi_hash_test_case_4);
    4040                 :            : }
    4041                 :            : 
    4042                 :            : static int
    4043                 :          0 : test_kasumi_hash_generate_test_case_5(void)
    4044                 :            : {
    4045                 :          0 :         return test_kasumi_authentication(&kasumi_hash_test_case_5);
    4046                 :            : }
    4047                 :            : 
    4048                 :            : static int
    4049                 :          0 : test_kasumi_hash_generate_test_case_6(void)
    4050                 :            : {
    4051                 :          0 :         return test_kasumi_authentication(&kasumi_hash_test_case_6);
    4052                 :            : }
    4053                 :            : 
    4054                 :            : static int
    4055                 :          0 : test_kasumi_hash_verify_test_case_1(void)
    4056                 :            : {
    4057                 :          0 :         return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
    4058                 :            : }
    4059                 :            : 
    4060                 :            : static int
    4061                 :          0 : test_kasumi_hash_verify_test_case_2(void)
    4062                 :            : {
    4063                 :          0 :         return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
    4064                 :            : }
    4065                 :            : 
    4066                 :            : static int
    4067                 :          0 : test_kasumi_hash_verify_test_case_3(void)
    4068                 :            : {
    4069                 :          0 :         return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
    4070                 :            : }
    4071                 :            : 
    4072                 :            : static int
    4073                 :          0 : test_kasumi_hash_verify_test_case_4(void)
    4074                 :            : {
    4075                 :          0 :         return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
    4076                 :            : }
    4077                 :            : 
    4078                 :            : static int
    4079                 :          0 : test_kasumi_hash_verify_test_case_5(void)
    4080                 :            : {
    4081                 :          0 :         return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
    4082                 :            : }
    4083                 :            : 
    4084                 :            : static int
    4085                 :          0 : test_kasumi_encryption(const struct kasumi_test_data *tdata)
    4086                 :            : {
    4087                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4088                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4089                 :            : 
    4090                 :            :         int retval;
    4091                 :            :         uint8_t *plaintext, *ciphertext;
    4092                 :            :         unsigned plaintext_pad_len;
    4093                 :            :         unsigned plaintext_len;
    4094                 :            :         struct rte_cryptodev_info dev_info;
    4095                 :            : 
    4096                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4097                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4098                 :            : 
    4099         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    4100         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    4101                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    4102                 :          0 :                 return TEST_SKIPPED;
    4103                 :            :         }
    4104                 :            : 
    4105         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4106                 :            :                 return TEST_SKIPPED;
    4107                 :            : 
    4108                 :            :         /* Verify the capabilities */
    4109                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4110                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4111                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    4112         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4113                 :            :                         &cap_idx) == NULL)
    4114                 :            :                 return TEST_SKIPPED;
    4115                 :            : 
    4116                 :            :         /* Create KASUMI session */
    4117                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4118                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4119                 :            :                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    4120                 :          0 :                                         tdata->key.data, tdata->key.len,
    4121                 :          0 :                                         tdata->cipher_iv.len);
    4122         [ #  # ]:          0 :         if (retval < 0)
    4123                 :            :                 return retval;
    4124                 :            : 
    4125         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4126                 :            : 
    4127                 :            :         /* Clear mbuf payload */
    4128         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    4129                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    4130                 :            : 
    4131         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4132                 :            :         /* Append data which is padded to a multiple */
    4133                 :            :         /* of the algorithms block size */
    4134                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    4135                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    4136                 :            :                                 plaintext_pad_len);
    4137                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    4138                 :            : 
    4139                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    4140                 :            : 
    4141                 :            :         /* Create KASUMI operation */
    4142                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    4143                 :          0 :                                 tdata->cipher_iv.len,
    4144                 :          0 :                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    4145                 :          0 :                                 tdata->validCipherOffsetInBits.len);
    4146         [ #  # ]:          0 :         if (retval < 0)
    4147                 :            :                 return retval;
    4148                 :            : 
    4149         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    4150                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    4151                 :          0 :                                                tdata->cipher_iv.len);
    4152         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    4153                 :            :                         return retval;
    4154                 :            :         } else
    4155                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4156                 :            :                                 ut_params->op);
    4157         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4158                 :            : 
    4159                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4160         [ #  # ]:          0 :         if (ut_params->obuf)
    4161                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    4162                 :            :         else
    4163                 :          0 :                 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
    4164                 :            : 
    4165                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    4166                 :            : 
    4167                 :          0 :         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
    4168                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    4169                 :            :         /* Validate obuf */
    4170   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4171                 :            :                 ciphertext,
    4172                 :            :                 reference_ciphertext,
    4173                 :            :                 tdata->validCipherLenInBits.len,
    4174                 :            :                 "KASUMI Ciphertext data not as expected");
    4175                 :            :         return 0;
    4176                 :            : }
    4177                 :            : 
    4178                 :            : static int
    4179                 :          0 : test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
    4180                 :            : {
    4181                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4182                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4183                 :            : 
    4184                 :            :         int retval;
    4185                 :            : 
    4186                 :            :         unsigned int plaintext_pad_len;
    4187                 :            :         unsigned int plaintext_len;
    4188                 :            : 
    4189                 :            :         uint8_t buffer[10000];
    4190                 :            :         const uint8_t *ciphertext;
    4191                 :            : 
    4192                 :            :         struct rte_cryptodev_info dev_info;
    4193                 :            : 
    4194                 :            :         /* Verify the capabilities */
    4195                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4196                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4197                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    4198         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4199                 :            :                         &cap_idx) == NULL)
    4200                 :            :                 return TEST_SKIPPED;
    4201                 :            : 
    4202                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4203                 :            : 
    4204                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4205                 :            : 
    4206         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    4207                 :            :                 printf("Device doesn't support in-place scatter-gather. "
    4208                 :            :                                 "Test Skipped.\n");
    4209                 :          0 :                 return TEST_SKIPPED;
    4210                 :            :         }
    4211                 :            : 
    4212         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    4213         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    4214                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    4215                 :          0 :                 return TEST_SKIPPED;
    4216                 :            :         }
    4217                 :            : 
    4218         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4219                 :            :                 return TEST_SKIPPED;
    4220                 :            : 
    4221                 :            :         /* Create KASUMI session */
    4222                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4223                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4224                 :            :                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    4225                 :          0 :                                         tdata->key.data, tdata->key.len,
    4226                 :          0 :                                         tdata->cipher_iv.len);
    4227         [ #  # ]:          0 :         if (retval < 0)
    4228                 :            :                 return retval;
    4229                 :            : 
    4230         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4231                 :            : 
    4232                 :            : 
    4233                 :            :         /* Append data which is padded to a multiple */
    4234                 :            :         /* of the algorithms block size */
    4235                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    4236                 :            : 
    4237                 :          0 :         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    4238                 :            :                         plaintext_pad_len, 10, 0);
    4239                 :            : 
    4240                 :          0 :         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
    4241                 :            : 
    4242                 :            :         /* Create KASUMI operation */
    4243                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    4244                 :          0 :                                 tdata->cipher_iv.len,
    4245                 :          0 :                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    4246                 :          0 :                                 tdata->validCipherOffsetInBits.len);
    4247         [ #  # ]:          0 :         if (retval < 0)
    4248                 :            :                 return retval;
    4249                 :            : 
    4250         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    4251                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    4252                 :          0 :                                                tdata->cipher_iv.len);
    4253         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    4254                 :            :                         return retval;
    4255                 :            :         } else
    4256                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4257                 :            :                                                 ut_params->op);
    4258         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4259                 :            : 
    4260                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4261                 :            : 
    4262         [ #  # ]:          0 :         if (ut_params->obuf)
    4263                 :            :                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    4264                 :            :                                 plaintext_len, buffer);
    4265                 :            :         else
    4266                 :          0 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
    4267         [ #  # ]:          0 :                                 tdata->validCipherOffsetInBits.len >> 3,
    4268                 :            :                                 plaintext_len, buffer);
    4269                 :            : 
    4270                 :            :         /* Validate obuf */
    4271                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    4272                 :            : 
    4273                 :          0 :         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
    4274                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    4275                 :            :         /* Validate obuf */
    4276   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4277                 :            :                 ciphertext,
    4278                 :            :                 reference_ciphertext,
    4279                 :            :                 tdata->validCipherLenInBits.len,
    4280                 :            :                 "KASUMI Ciphertext data not as expected");
    4281                 :            :         return 0;
    4282                 :            : }
    4283                 :            : 
    4284                 :            : static int
    4285                 :          0 : test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
    4286                 :            : {
    4287                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4288                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4289                 :            : 
    4290                 :            :         int retval;
    4291                 :            :         uint8_t *plaintext, *ciphertext;
    4292                 :            :         unsigned plaintext_pad_len;
    4293                 :            :         unsigned plaintext_len;
    4294                 :            : 
    4295                 :            :         /* Verify the capabilities */
    4296                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4297                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4298                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    4299                 :            :         /* Data-path service does not support OOP */
    4300         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4301                 :            :                         &cap_idx) == NULL)
    4302                 :            :                 return TEST_SKIPPED;
    4303                 :            : 
    4304         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    4305                 :            :                 return TEST_SKIPPED;
    4306                 :            : 
    4307         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4308                 :            :                 return TEST_SKIPPED;
    4309                 :            : 
    4310                 :            :         /* Create KASUMI session */
    4311                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4312                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4313                 :            :                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    4314                 :          0 :                                         tdata->key.data, tdata->key.len,
    4315                 :          0 :                                         tdata->cipher_iv.len);
    4316         [ #  # ]:          0 :         if (retval < 0)
    4317                 :            :                 return retval;
    4318                 :            : 
    4319                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4320                 :          0 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4321                 :            : 
    4322                 :            :         /* Clear mbuf payload */
    4323         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    4324         [ #  # ]:          0 :                rte_pktmbuf_tailroom(ut_params->ibuf));
    4325                 :            : 
    4326         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4327                 :            :         /* Append data which is padded to a multiple */
    4328                 :            :         /* of the algorithms block size */
    4329                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    4330                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    4331                 :            :                                 plaintext_pad_len);
    4332                 :          0 :         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
    4333                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    4334                 :            : 
    4335                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    4336                 :            : 
    4337                 :            :         /* Create KASUMI operation */
    4338                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    4339                 :          0 :                                 tdata->cipher_iv.len,
    4340                 :          0 :                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    4341                 :          0 :                                 tdata->validCipherOffsetInBits.len);
    4342         [ #  # ]:          0 :         if (retval < 0)
    4343                 :            :                 return retval;
    4344                 :            : 
    4345                 :          0 :         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4346                 :            :                                                 ut_params->op);
    4347         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4348                 :            : 
    4349                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4350         [ #  # ]:          0 :         if (ut_params->obuf)
    4351                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    4352                 :            :         else
    4353                 :          0 :                 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
    4354                 :            : 
    4355                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    4356                 :            : 
    4357                 :          0 :         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
    4358                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    4359                 :            :         /* Validate obuf */
    4360   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4361                 :            :                 ciphertext,
    4362                 :            :                 reference_ciphertext,
    4363                 :            :                 tdata->validCipherLenInBits.len,
    4364                 :            :                 "KASUMI Ciphertext data not as expected");
    4365                 :            :         return 0;
    4366                 :            : }
    4367                 :            : 
    4368                 :            : static int
    4369                 :          0 : test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
    4370                 :            : {
    4371                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4372                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4373                 :            : 
    4374                 :            :         int retval;
    4375                 :            :         unsigned int plaintext_pad_len;
    4376                 :            :         unsigned int plaintext_len;
    4377                 :            : 
    4378                 :            :         const uint8_t *ciphertext;
    4379                 :            :         uint8_t buffer[2048];
    4380                 :            : 
    4381                 :            :         struct rte_cryptodev_info dev_info;
    4382                 :            : 
    4383                 :            :         /* Verify the capabilities */
    4384                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4385                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4386                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    4387         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4388                 :            :                         &cap_idx) == NULL)
    4389                 :            :                 return TEST_SKIPPED;
    4390                 :            : 
    4391         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    4392                 :            :                 return TEST_SKIPPED;
    4393                 :            : 
    4394         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4395                 :            :                 return TEST_SKIPPED;
    4396                 :            : 
    4397                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4398                 :            : 
    4399                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4400         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
    4401                 :            :                 printf("Device doesn't support out-of-place scatter-gather "
    4402                 :            :                                 "in both input and output mbufs. "
    4403                 :            :                                 "Test Skipped.\n");
    4404                 :          0 :                 return TEST_SKIPPED;
    4405                 :            :         }
    4406                 :            : 
    4407                 :            :         /* Create KASUMI session */
    4408                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4409                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4410                 :            :                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    4411                 :          0 :                                         tdata->key.data, tdata->key.len,
    4412                 :          0 :                                         tdata->cipher_iv.len);
    4413         [ #  # ]:          0 :         if (retval < 0)
    4414                 :            :                 return retval;
    4415                 :            : 
    4416         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4417                 :            :         /* Append data which is padded to a multiple */
    4418                 :            :         /* of the algorithms block size */
    4419                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    4420                 :            : 
    4421                 :          0 :         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    4422                 :            :                         plaintext_pad_len, 10, 0);
    4423                 :          0 :         ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
    4424                 :            :                         plaintext_pad_len, 3, 0);
    4425                 :            : 
    4426                 :            :         /* Append data which is padded to a multiple */
    4427                 :            :         /* of the algorithms block size */
    4428                 :          0 :         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
    4429                 :            : 
    4430                 :            :         /* Create KASUMI operation */
    4431                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    4432                 :          0 :                                 tdata->cipher_iv.len,
    4433                 :          0 :                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    4434                 :          0 :                                 tdata->validCipherOffsetInBits.len);
    4435         [ #  # ]:          0 :         if (retval < 0)
    4436                 :            :                 return retval;
    4437                 :            : 
    4438                 :          0 :         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4439                 :            :                                                 ut_params->op);
    4440         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4441                 :            : 
    4442                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4443         [ #  # ]:          0 :         if (ut_params->obuf)
    4444                 :            :                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    4445                 :            :                                 plaintext_pad_len, buffer);
    4446                 :            :         else
    4447                 :          0 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
    4448         [ #  # ]:          0 :                                 tdata->validCipherOffsetInBits.len >> 3,
    4449                 :            :                                 plaintext_pad_len, buffer);
    4450                 :            : 
    4451                 :          0 :         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
    4452                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    4453                 :            :         /* Validate obuf */
    4454   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4455                 :            :                 ciphertext,
    4456                 :            :                 reference_ciphertext,
    4457                 :            :                 tdata->validCipherLenInBits.len,
    4458                 :            :                 "KASUMI Ciphertext data not as expected");
    4459                 :            :         return 0;
    4460                 :            : }
    4461                 :            : 
    4462                 :            : 
    4463                 :            : static int
    4464                 :          0 : test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
    4465                 :            : {
    4466                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4467                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4468                 :            : 
    4469                 :            :         int retval;
    4470                 :            :         uint8_t *ciphertext, *plaintext;
    4471                 :            :         unsigned ciphertext_pad_len;
    4472                 :            :         unsigned ciphertext_len;
    4473                 :            : 
    4474                 :            :         /* Verify the capabilities */
    4475                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4476                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4477                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    4478         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4479                 :            :                         &cap_idx) == NULL)
    4480                 :            :                 return TEST_SKIPPED;
    4481                 :            : 
    4482         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    4483                 :            :                 return TEST_SKIPPED;
    4484                 :            : 
    4485         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4486                 :            :                 return TEST_SKIPPED;
    4487                 :            : 
    4488                 :            :         /* Create KASUMI session */
    4489                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4490                 :            :                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
    4491                 :            :                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    4492                 :          0 :                                         tdata->key.data, tdata->key.len,
    4493                 :          0 :                                         tdata->cipher_iv.len);
    4494         [ #  # ]:          0 :         if (retval < 0)
    4495                 :            :                 return retval;
    4496                 :            : 
    4497                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4498                 :          0 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4499                 :            : 
    4500                 :            :         /* Clear mbuf payload */
    4501         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    4502         [ #  # ]:          0 :                rte_pktmbuf_tailroom(ut_params->ibuf));
    4503                 :            : 
    4504         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    4505                 :            :         /* Append data which is padded to a multiple */
    4506                 :            :         /* of the algorithms block size */
    4507                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
    4508                 :          0 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    4509                 :            :                                 ciphertext_pad_len);
    4510                 :          0 :         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
    4511                 :          0 :         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    4512                 :            : 
    4513                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
    4514                 :            : 
    4515                 :            :         /* Create KASUMI operation */
    4516                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    4517                 :          0 :                                 tdata->cipher_iv.len,
    4518                 :          0 :                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    4519                 :          0 :                                 tdata->validCipherOffsetInBits.len);
    4520         [ #  # ]:          0 :         if (retval < 0)
    4521                 :            :                 return retval;
    4522                 :            : 
    4523                 :          0 :         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4524                 :            :                                                 ut_params->op);
    4525         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4526                 :            : 
    4527                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4528         [ #  # ]:          0 :         if (ut_params->obuf)
    4529                 :          0 :                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    4530                 :            :         else
    4531                 :          0 :                 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
    4532                 :            : 
    4533                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
    4534                 :            : 
    4535                 :          0 :         const uint8_t *reference_plaintext = tdata->plaintext.data +
    4536                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    4537                 :            :         /* Validate obuf */
    4538   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4539                 :            :                 plaintext,
    4540                 :            :                 reference_plaintext,
    4541                 :            :                 tdata->validCipherLenInBits.len,
    4542                 :            :                 "KASUMI Plaintext data not as expected");
    4543                 :            :         return 0;
    4544                 :            : }
    4545                 :            : 
    4546                 :            : static int
    4547                 :          0 : test_kasumi_decryption(const struct kasumi_test_data *tdata)
    4548                 :            : {
    4549                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4550                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4551                 :            : 
    4552                 :            :         int retval;
    4553                 :            :         uint8_t *ciphertext, *plaintext;
    4554                 :            :         unsigned ciphertext_pad_len;
    4555                 :            :         unsigned ciphertext_len;
    4556                 :            :         struct rte_cryptodev_info dev_info;
    4557                 :            : 
    4558                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4559                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4560                 :            : 
    4561         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    4562         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    4563                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    4564                 :          0 :                 return TEST_SKIPPED;
    4565                 :            :         }
    4566                 :            : 
    4567         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4568                 :            :                 return TEST_SKIPPED;
    4569                 :            : 
    4570                 :            :         /* Verify the capabilities */
    4571                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4572                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4573                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    4574         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4575                 :            :                         &cap_idx) == NULL)
    4576                 :            :                 return TEST_SKIPPED;
    4577                 :            : 
    4578                 :            :         /* Create KASUMI session */
    4579                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4580                 :            :                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
    4581                 :            :                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    4582                 :          0 :                                         tdata->key.data, tdata->key.len,
    4583                 :          0 :                                         tdata->cipher_iv.len);
    4584         [ #  # ]:          0 :         if (retval < 0)
    4585                 :            :                 return retval;
    4586                 :            : 
    4587         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4588                 :            : 
    4589                 :            :         /* Clear mbuf payload */
    4590         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    4591                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    4592                 :            : 
    4593         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    4594                 :            :         /* Append data which is padded to a multiple */
    4595                 :            :         /* of the algorithms block size */
    4596                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
    4597                 :          0 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    4598                 :            :                                 ciphertext_pad_len);
    4599                 :          0 :         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    4600                 :            : 
    4601                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
    4602                 :            : 
    4603                 :            :         /* Create KASUMI operation */
    4604                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    4605                 :          0 :                         tdata->cipher_iv.len,
    4606                 :          0 :                         RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    4607                 :          0 :                         tdata->validCipherOffsetInBits.len);
    4608         [ #  # ]:          0 :         if (retval < 0)
    4609                 :            :                 return retval;
    4610                 :            : 
    4611         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    4612                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    4613                 :            :                                                0);
    4614         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    4615                 :            :                         return retval;
    4616                 :            :         } else
    4617                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4618                 :            :                                                 ut_params->op);
    4619         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4620                 :            : 
    4621                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4622         [ #  # ]:          0 :         if (ut_params->obuf)
    4623                 :          0 :                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    4624                 :            :         else
    4625                 :          0 :                 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
    4626                 :            : 
    4627                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
    4628                 :            : 
    4629                 :          0 :         const uint8_t *reference_plaintext = tdata->plaintext.data +
    4630                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    4631                 :            :         /* Validate obuf */
    4632   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4633                 :            :                 plaintext,
    4634                 :            :                 reference_plaintext,
    4635                 :            :                 tdata->validCipherLenInBits.len,
    4636                 :            :                 "KASUMI Plaintext data not as expected");
    4637                 :            :         return 0;
    4638                 :            : }
    4639                 :            : 
    4640                 :            : static int
    4641                 :          0 : test_snow3g_encryption(const struct snow3g_test_data *tdata)
    4642                 :            : {
    4643                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4644                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4645                 :            : 
    4646                 :            :         int retval;
    4647                 :            :         uint8_t *plaintext, *ciphertext;
    4648                 :            :         unsigned plaintext_pad_len;
    4649                 :            :         unsigned plaintext_len;
    4650                 :            :         struct rte_cryptodev_info dev_info;
    4651                 :            : 
    4652                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4653                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4654                 :            : 
    4655         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    4656         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    4657                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    4658                 :          0 :                 return TEST_SKIPPED;
    4659                 :            :         }
    4660                 :            : 
    4661         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4662                 :            :                 return TEST_SKIPPED;
    4663                 :            : 
    4664                 :            :         /* Verify the capabilities */
    4665                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4666                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4667                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    4668         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4669                 :            :                         &cap_idx) == NULL)
    4670                 :            :                 return TEST_SKIPPED;
    4671                 :            : 
    4672                 :            :         /* Create SNOW 3G session */
    4673                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4674                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4675                 :            :                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    4676                 :          0 :                                         tdata->key.data, tdata->key.len,
    4677                 :          0 :                                         tdata->cipher_iv.len);
    4678         [ #  # ]:          0 :         if (retval < 0)
    4679                 :            :                 return retval;
    4680                 :            : 
    4681         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4682                 :            : 
    4683                 :            :         /* Clear mbuf payload */
    4684         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    4685                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    4686                 :            : 
    4687         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4688                 :            :         /* Append data which is padded to a multiple of */
    4689                 :            :         /* the algorithms block size */
    4690                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    4691                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    4692                 :            :                                 plaintext_pad_len);
    4693                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    4694                 :            : 
    4695                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    4696                 :            : 
    4697                 :            :         /* Create SNOW 3G operation */
    4698                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    4699                 :          0 :                                         tdata->cipher_iv.len,
    4700                 :          0 :                                         tdata->validCipherLenInBits.len,
    4701                 :            :                                         0);
    4702         [ #  # ]:          0 :         if (retval < 0)
    4703                 :            :                 return retval;
    4704                 :            : 
    4705         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    4706                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    4707                 :          0 :                                                tdata->cipher_iv.len);
    4708         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    4709                 :            :                         return retval;
    4710                 :            :         } else
    4711                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4712                 :            :                                                 ut_params->op);
    4713         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4714                 :            : 
    4715                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4716         [ #  # ]:          0 :         if (ut_params->obuf)
    4717                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    4718                 :            :         else
    4719                 :            :                 ciphertext = plaintext;
    4720                 :            : 
    4721                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    4722                 :            : 
    4723                 :            :         /* Validate obuf */
    4724   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4725                 :            :                 ciphertext,
    4726                 :            :                 tdata->ciphertext.data,
    4727                 :            :                 tdata->validDataLenInBits.len,
    4728                 :            :                 "SNOW 3G Ciphertext data not as expected");
    4729                 :            :         return 0;
    4730                 :            : }
    4731                 :            : 
    4732                 :            : 
    4733                 :            : static int
    4734                 :          0 : test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
    4735                 :            : {
    4736                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4737                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4738                 :            :         uint8_t *plaintext, *ciphertext;
    4739                 :            : 
    4740                 :            :         int retval;
    4741                 :            :         unsigned plaintext_pad_len;
    4742                 :            :         unsigned plaintext_len;
    4743                 :            :         struct rte_cryptodev_info dev_info;
    4744                 :            : 
    4745                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4746                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4747                 :            : 
    4748         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    4749         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    4750                 :            :                 printf("Device does not support RAW data-path APIs.\n");
    4751                 :          0 :                 return -ENOTSUP;
    4752                 :            :         }
    4753                 :            : 
    4754                 :            :         /* Verify the capabilities */
    4755                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4756                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4757                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    4758         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4759                 :            :                         &cap_idx) == NULL)
    4760                 :            :                 return TEST_SKIPPED;
    4761                 :            : 
    4762         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    4763                 :            :                 return TEST_SKIPPED;
    4764                 :            : 
    4765         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4766                 :            :                 return TEST_SKIPPED;
    4767                 :            : 
    4768                 :            :         /* Create SNOW 3G session */
    4769                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4770                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4771                 :            :                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    4772                 :          0 :                                         tdata->key.data, tdata->key.len,
    4773                 :          0 :                                         tdata->cipher_iv.len);
    4774         [ #  # ]:          0 :         if (retval < 0)
    4775                 :            :                 return retval;
    4776                 :            : 
    4777                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4778                 :          0 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4779                 :            : 
    4780         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    4781                 :            :                         "Failed to allocate input buffer in mempool");
    4782         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->obuf,
    4783                 :            :                         "Failed to allocate output buffer in mempool");
    4784                 :            : 
    4785                 :            :         /* Clear mbuf payload */
    4786         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    4787                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    4788                 :            : 
    4789         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4790                 :            :         /* Append data which is padded to a multiple of */
    4791                 :            :         /* the algorithms block size */
    4792                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    4793                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    4794                 :            :                                 plaintext_pad_len);
    4795                 :          0 :         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
    4796                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    4797                 :            : 
    4798                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    4799                 :            : 
    4800                 :            :         /* Create SNOW 3G operation */
    4801                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    4802                 :          0 :                                         tdata->cipher_iv.len,
    4803                 :          0 :                                         tdata->validCipherLenInBits.len,
    4804                 :            :                                         0);
    4805         [ #  # ]:          0 :         if (retval < 0)
    4806                 :            :                 return retval;
    4807                 :            : 
    4808         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    4809                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    4810                 :          0 :                                                tdata->cipher_iv.len);
    4811         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    4812                 :            :                         return retval;
    4813                 :            :         } else
    4814                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4815                 :            :                                                 ut_params->op);
    4816         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4817                 :            : 
    4818                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4819         [ #  # ]:          0 :         if (ut_params->obuf)
    4820                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    4821                 :            :         else
    4822                 :            :                 ciphertext = plaintext;
    4823                 :            : 
    4824                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    4825                 :            : 
    4826                 :            :         /* Validate obuf */
    4827   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4828                 :            :                 ciphertext,
    4829                 :            :                 tdata->ciphertext.data,
    4830                 :            :                 tdata->validDataLenInBits.len,
    4831                 :            :                 "SNOW 3G Ciphertext data not as expected");
    4832                 :            :         return 0;
    4833                 :            : }
    4834                 :            : 
    4835                 :            : static int
    4836                 :          0 : test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
    4837                 :            :                 uint8_t sgl_in, uint8_t sgl_out)
    4838                 :            : {
    4839                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4840                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4841                 :            : 
    4842                 :            :         int retval;
    4843                 :            :         unsigned int plaintext_pad_len;
    4844                 :            :         unsigned int plaintext_len;
    4845                 :            :         uint8_t buffer[10000];
    4846                 :            :         const uint8_t *ciphertext;
    4847                 :            : 
    4848                 :            :         struct rte_cryptodev_info dev_info;
    4849                 :            : 
    4850                 :            :         /* Verify the capabilities */
    4851                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4852                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4853                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    4854         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4855                 :            :                         &cap_idx) == NULL)
    4856                 :            :                 return TEST_SKIPPED;
    4857                 :            : 
    4858         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    4859                 :            :                 return TEST_SKIPPED;
    4860                 :            : 
    4861         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4862                 :            :                 return TEST_SKIPPED;
    4863                 :            : 
    4864                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4865                 :            : 
    4866                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4867                 :            : 
    4868   [ #  #  #  # ]:          0 :         if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
    4869         [ #  # ]:          0 :                         || ((!sgl_in && sgl_out) &&
    4870         [ #  # ]:          0 :                         !(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
    4871         [ #  # ]:          0 :                         || ((sgl_in && !sgl_out) &&
    4872         [ #  # ]:          0 :                         !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
    4873                 :            :                 printf("Device doesn't support out-of-place scatter gather type. "
    4874                 :            :                                 "Test Skipped.\n");
    4875                 :          0 :                 return TEST_SKIPPED;
    4876                 :            :         }
    4877                 :            : 
    4878         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    4879         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    4880                 :            :                 printf("Device does not support RAW data-path APIs.\n");
    4881                 :          0 :                 return -ENOTSUP;
    4882                 :            :         }
    4883                 :            : 
    4884                 :            :         /* Create SNOW 3G session */
    4885                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4886                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4887                 :            :                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    4888                 :          0 :                                         tdata->key.data, tdata->key.len,
    4889                 :          0 :                                         tdata->cipher_iv.len);
    4890         [ #  # ]:          0 :         if (retval < 0)
    4891                 :            :                 return retval;
    4892                 :            : 
    4893         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4894                 :            :         /* Append data which is padded to a multiple of */
    4895                 :            :         /* the algorithms block size */
    4896                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    4897                 :            : 
    4898         [ #  # ]:          0 :         if (sgl_in)
    4899                 :          0 :                 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    4900                 :            :                                 plaintext_pad_len, 10, 0);
    4901                 :            :         else {
    4902                 :          0 :                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4903                 :            :                 rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
    4904                 :            :         }
    4905                 :            : 
    4906         [ #  # ]:          0 :         if (sgl_out)
    4907                 :          0 :                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
    4908                 :            :                                 plaintext_pad_len, 3, 0);
    4909                 :            :         else {
    4910                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4911                 :            :                 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
    4912                 :            :         }
    4913                 :            : 
    4914         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    4915                 :            :                         "Failed to allocate input buffer in mempool");
    4916         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->obuf,
    4917                 :            :                         "Failed to allocate output buffer in mempool");
    4918                 :            : 
    4919                 :          0 :         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
    4920                 :            : 
    4921                 :            :         /* Create SNOW 3G operation */
    4922                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    4923                 :          0 :                                         tdata->cipher_iv.len,
    4924                 :          0 :                                         tdata->validCipherLenInBits.len,
    4925                 :            :                                         0);
    4926         [ #  # ]:          0 :         if (retval < 0)
    4927                 :            :                 return retval;
    4928                 :            : 
    4929         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    4930                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    4931                 :          0 :                                                tdata->cipher_iv.len);
    4932         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    4933                 :            :                         return retval;
    4934                 :            :         } else
    4935                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4936                 :            :                                                 ut_params->op);
    4937         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4938                 :            : 
    4939                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4940         [ #  # ]:          0 :         if (ut_params->obuf)
    4941                 :            :                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    4942                 :            :                                 plaintext_len, buffer);
    4943                 :            :         else
    4944         [ #  # ]:          0 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    4945                 :            :                                 plaintext_len, buffer);
    4946                 :            : 
    4947                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    4948                 :            : 
    4949                 :            :         /* Validate obuf */
    4950   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4951                 :            :                 ciphertext,
    4952                 :            :                 tdata->ciphertext.data,
    4953                 :            :                 tdata->validDataLenInBits.len,
    4954                 :            :                 "SNOW 3G Ciphertext data not as expected");
    4955                 :            : 
    4956                 :            :         return 0;
    4957                 :            : }
    4958                 :            : 
    4959                 :            : /* Shift right a buffer by "offset" bits, "offset" < 8 */
    4960                 :            : static void
    4961                 :          0 : buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
    4962                 :            : {
    4963                 :            :         uint8_t curr_byte, prev_byte;
    4964         [ #  # ]:          0 :         uint32_t length_in_bytes = ceil_byte_length(length + offset);
    4965                 :          0 :         uint8_t lower_byte_mask = (1 << offset) - 1;
    4966                 :            :         unsigned i;
    4967                 :            : 
    4968                 :          0 :         prev_byte = buffer[0];
    4969                 :          0 :         buffer[0] >>= offset;
    4970                 :            : 
    4971         [ #  # ]:          0 :         for (i = 1; i < length_in_bytes; i++) {
    4972                 :          0 :                 curr_byte = buffer[i];
    4973                 :          0 :                 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
    4974                 :          0 :                                 (curr_byte >> offset);
    4975                 :            :                 prev_byte = curr_byte;
    4976                 :            :         }
    4977                 :          0 : }
    4978                 :            : 
    4979                 :            : static int
    4980                 :          0 : test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
    4981                 :            : {
    4982                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4983                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4984                 :            :         uint8_t *plaintext, *ciphertext;
    4985                 :            :         int retval;
    4986                 :            :         uint32_t plaintext_len;
    4987                 :            :         uint32_t plaintext_pad_len;
    4988                 :            :         uint8_t extra_offset = 4;
    4989                 :            :         uint8_t *expected_ciphertext_shifted;
    4990                 :            :         struct rte_cryptodev_info dev_info;
    4991                 :            : 
    4992                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4993                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4994                 :            : 
    4995         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
    4996         [ #  # ]:          0 :                         ((tdata->validDataLenInBits.len % 8) != 0)) {
    4997                 :            :                 printf("Device doesn't support NON-Byte Aligned Data.\n");
    4998                 :          0 :                 return TEST_SKIPPED;
    4999                 :            :         }
    5000                 :            : 
    5001                 :            :         /* Verify the capabilities */
    5002                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    5003                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    5004                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    5005         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5006                 :            :                         &cap_idx) == NULL)
    5007                 :            :                 return TEST_SKIPPED;
    5008                 :            : 
    5009         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    5010                 :            :                 return TEST_SKIPPED;
    5011                 :            : 
    5012         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5013                 :            :                 return TEST_SKIPPED;
    5014                 :            : 
    5015                 :            :         /* Create SNOW 3G session */
    5016                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    5017                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    5018                 :            :                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    5019                 :          0 :                                         tdata->key.data, tdata->key.len,
    5020                 :          0 :                                         tdata->cipher_iv.len);
    5021         [ #  # ]:          0 :         if (retval < 0)
    5022                 :            :                 return retval;
    5023                 :            : 
    5024                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5025                 :          0 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5026                 :            : 
    5027         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    5028                 :            :                         "Failed to allocate input buffer in mempool");
    5029         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->obuf,
    5030                 :            :                         "Failed to allocate output buffer in mempool");
    5031                 :            : 
    5032                 :            :         /* Clear mbuf payload */
    5033         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    5034                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    5035                 :            : 
    5036         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
    5037                 :            :         /*
    5038                 :            :          * Append data which is padded to a
    5039                 :            :          * multiple of the algorithms block size
    5040                 :            :          */
    5041                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    5042                 :            : 
    5043                 :          0 :         plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
    5044                 :            :                                                 plaintext_pad_len);
    5045                 :            : 
    5046                 :          0 :         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
    5047                 :            : 
    5048                 :          0 :         memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
    5049                 :          0 :         buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
    5050                 :            : 
    5051                 :            : #ifdef RTE_APP_TEST_DEBUG
    5052                 :            :         rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
    5053                 :            : #endif
    5054                 :            :         /* Create SNOW 3G operation */
    5055                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    5056                 :          0 :                                         tdata->cipher_iv.len,
    5057                 :          0 :                                         tdata->validCipherLenInBits.len,
    5058                 :            :                                         extra_offset);
    5059         [ #  # ]:          0 :         if (retval < 0)
    5060                 :            :                 return retval;
    5061                 :            : 
    5062         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5063                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    5064                 :          0 :                                                tdata->cipher_iv.len);
    5065         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5066                 :            :                         return retval;
    5067                 :            :         } else
    5068                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5069                 :            :                                                 ut_params->op);
    5070         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5071                 :            : 
    5072                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    5073         [ #  # ]:          0 :         if (ut_params->obuf)
    5074                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    5075                 :            :         else
    5076                 :            :                 ciphertext = plaintext;
    5077                 :            : 
    5078                 :            : #ifdef RTE_APP_TEST_DEBUG
    5079                 :            :         rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    5080                 :            : #endif
    5081                 :            : 
    5082                 :          0 :         expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
    5083                 :            : 
    5084         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
    5085                 :            :                         "failed to reserve memory for ciphertext shifted\n");
    5086                 :            : 
    5087                 :          0 :         memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
    5088         [ #  # ]:          0 :                         ceil_byte_length(tdata->ciphertext.len));
    5089                 :          0 :         buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
    5090                 :            :                         extra_offset);
    5091                 :            :         /* Validate obuf */
    5092   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
             #  #  #  # ]
    5093                 :            :                 ciphertext,
    5094                 :            :                 expected_ciphertext_shifted,
    5095                 :            :                 tdata->validDataLenInBits.len,
    5096                 :            :                 extra_offset,
    5097                 :            :                 "SNOW 3G Ciphertext data not as expected");
    5098                 :            :         return 0;
    5099                 :            : }
    5100                 :            : 
    5101                 :          0 : static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
    5102                 :            : {
    5103                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5104                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5105                 :            : 
    5106                 :            :         int retval;
    5107                 :            : 
    5108                 :            :         uint8_t *plaintext, *ciphertext;
    5109                 :            :         unsigned ciphertext_pad_len;
    5110                 :            :         unsigned ciphertext_len;
    5111                 :            :         struct rte_cryptodev_info dev_info;
    5112                 :            : 
    5113                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5114                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5115                 :            : 
    5116         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5117         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5118                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    5119                 :          0 :                 return TEST_SKIPPED;
    5120                 :            :         }
    5121                 :            : 
    5122         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5123                 :            :                 return TEST_SKIPPED;
    5124                 :            : 
    5125                 :            :         /* Verify the capabilities */
    5126                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    5127                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    5128                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    5129         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5130                 :            :                         &cap_idx) == NULL)
    5131                 :            :                 return TEST_SKIPPED;
    5132                 :            : 
    5133                 :            :         /* Create SNOW 3G session */
    5134                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    5135                 :            :                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
    5136                 :            :                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    5137                 :          0 :                                         tdata->key.data, tdata->key.len,
    5138                 :          0 :                                         tdata->cipher_iv.len);
    5139         [ #  # ]:          0 :         if (retval < 0)
    5140                 :            :                 return retval;
    5141                 :            : 
    5142         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5143                 :            : 
    5144                 :            :         /* Clear mbuf payload */
    5145         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    5146                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    5147                 :            : 
    5148         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    5149                 :            :         /* Append data which is padded to a multiple of */
    5150                 :            :         /* the algorithms block size */
    5151                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    5152                 :          0 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5153                 :            :                                 ciphertext_pad_len);
    5154                 :          0 :         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    5155                 :            : 
    5156                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
    5157                 :            : 
    5158                 :            :         /* Create SNOW 3G operation */
    5159                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    5160                 :          0 :                                         tdata->cipher_iv.len,
    5161                 :          0 :                                         tdata->validCipherLenInBits.len,
    5162                 :          0 :                                         tdata->cipher.offset_bits);
    5163         [ #  # ]:          0 :         if (retval < 0)
    5164                 :            :                 return retval;
    5165                 :            : 
    5166         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5167                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    5168                 :          0 :                                                tdata->cipher_iv.len);
    5169         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5170                 :            :                         return retval;
    5171                 :            :         } else
    5172                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5173                 :            :                                                 ut_params->op);
    5174         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5175                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    5176         [ #  # ]:          0 :         if (ut_params->obuf)
    5177                 :          0 :                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    5178                 :            :         else
    5179                 :            :                 plaintext = ciphertext;
    5180                 :            : 
    5181                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
    5182                 :            : 
    5183                 :            :         /* Validate obuf */
    5184   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
                   #  # ]
    5185                 :            :                                 tdata->plaintext.data,
    5186                 :            :                                 tdata->validDataLenInBits.len,
    5187                 :            :                                 "SNOW 3G Plaintext data not as expected");
    5188                 :            :         return 0;
    5189                 :            : }
    5190                 :            : 
    5191                 :          0 : static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
    5192                 :            : {
    5193                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5194                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5195                 :            : 
    5196                 :            :         int retval;
    5197                 :            : 
    5198                 :            :         uint8_t *plaintext, *ciphertext;
    5199                 :            :         unsigned ciphertext_pad_len;
    5200                 :            :         unsigned ciphertext_len;
    5201                 :            :         struct rte_cryptodev_info dev_info;
    5202                 :            : 
    5203                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5204                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5205                 :            : 
    5206         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5207         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5208                 :            :                 printf("Device does not support RAW data-path APIs.\n");
    5209                 :          0 :                 return -ENOTSUP;
    5210                 :            :         }
    5211                 :            :         /* Verify the capabilities */
    5212                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    5213                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    5214                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    5215         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5216                 :            :                         &cap_idx) == NULL)
    5217                 :            :                 return TEST_SKIPPED;
    5218                 :            : 
    5219         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    5220                 :            :                 return TEST_SKIPPED;
    5221                 :            : 
    5222         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5223                 :            :                 return TEST_SKIPPED;
    5224                 :            : 
    5225                 :            :         /* Create SNOW 3G session */
    5226                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    5227                 :            :                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
    5228                 :            :                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    5229                 :          0 :                                         tdata->key.data, tdata->key.len,
    5230                 :          0 :                                         tdata->cipher_iv.len);
    5231         [ #  # ]:          0 :         if (retval < 0)
    5232                 :            :                 return retval;
    5233                 :            : 
    5234                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5235                 :          0 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5236                 :            : 
    5237         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    5238                 :            :                         "Failed to allocate input buffer");
    5239         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->obuf,
    5240                 :            :                         "Failed to allocate output buffer");
    5241                 :            : 
    5242                 :            :         /* Clear mbuf payload */
    5243         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    5244                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    5245                 :            : 
    5246                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
    5247                 :          0 :                        rte_pktmbuf_tailroom(ut_params->obuf));
    5248                 :            : 
    5249         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    5250                 :            :         /* Append data which is padded to a multiple of */
    5251                 :            :         /* the algorithms block size */
    5252                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    5253                 :          0 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5254                 :            :                                 ciphertext_pad_len);
    5255                 :          0 :         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
    5256                 :          0 :         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    5257                 :            : 
    5258                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
    5259                 :            : 
    5260                 :            :         /* Create SNOW 3G operation */
    5261                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    5262                 :          0 :                                         tdata->cipher_iv.len,
    5263                 :          0 :                                         tdata->validCipherLenInBits.len,
    5264                 :            :                                         0);
    5265         [ #  # ]:          0 :         if (retval < 0)
    5266                 :            :                 return retval;
    5267                 :            : 
    5268         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5269                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    5270                 :          0 :                                                tdata->cipher_iv.len);
    5271         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5272                 :            :                         return retval;
    5273                 :            :         } else
    5274                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5275                 :            :                                                 ut_params->op);
    5276         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5277                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    5278         [ #  # ]:          0 :         if (ut_params->obuf)
    5279                 :          0 :                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    5280                 :            :         else
    5281                 :            :                 plaintext = ciphertext;
    5282                 :            : 
    5283                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
    5284                 :            : 
    5285                 :            :         /* Validate obuf */
    5286   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
                   #  # ]
    5287                 :            :                                 tdata->plaintext.data,
    5288                 :            :                                 tdata->validDataLenInBits.len,
    5289                 :            :                                 "SNOW 3G Plaintext data not as expected");
    5290                 :            :         return 0;
    5291                 :            : }
    5292                 :            : 
    5293                 :            : static int
    5294                 :          0 : test_zuc_cipher_auth(const struct wireless_test_data *tdata)
    5295                 :            : {
    5296                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5297                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5298                 :            : 
    5299                 :            :         int retval;
    5300                 :            : 
    5301                 :            :         uint8_t *plaintext, *ciphertext;
    5302                 :            :         unsigned int plaintext_pad_len;
    5303                 :            :         unsigned int plaintext_len;
    5304                 :            : 
    5305                 :            :         struct rte_cryptodev_info dev_info;
    5306                 :            : 
    5307                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5308                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5309                 :            : 
    5310         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
    5311         [ #  # ]:          0 :                         ((tdata->validAuthLenInBits.len % 8 != 0) ||
    5312         [ #  # ]:          0 :                         (tdata->validDataLenInBits.len % 8 != 0))) {
    5313                 :            :                 printf("Device doesn't support NON-Byte Aligned Data.\n");
    5314                 :          0 :                 return TEST_SKIPPED;
    5315                 :            :         }
    5316                 :            : 
    5317         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5318         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5319                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    5320                 :          0 :                 return TEST_SKIPPED;
    5321                 :            :         }
    5322                 :            : 
    5323         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5324                 :            :                 return TEST_SKIPPED;
    5325                 :            : 
    5326                 :            :         /* Check if device supports ZUC EEA3 */
    5327         [ #  # ]:          0 :         if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
    5328                 :          0 :                         tdata->key.len, tdata->cipher_iv.len) < 0)
    5329                 :            :                 return TEST_SKIPPED;
    5330                 :            : 
    5331                 :            :         /* Check if device supports ZUC EIA3 */
    5332         [ #  # ]:          0 :         if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
    5333                 :          0 :                         tdata->key.len, tdata->auth_iv.len,
    5334                 :          0 :                         tdata->digest.len) < 0)
    5335                 :            :                 return TEST_SKIPPED;
    5336                 :            : 
    5337                 :            :         /* Create ZUC session */
    5338                 :          0 :         retval = create_zuc_cipher_auth_encrypt_generate_session(
    5339                 :          0 :                         ts_params->valid_devs[0],
    5340                 :            :                         tdata);
    5341         [ #  # ]:          0 :         if (retval != 0)
    5342                 :            :                 return retval;
    5343         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5344                 :            : 
    5345                 :            :         /* clear mbuf payload */
    5346         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    5347                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
    5348                 :            : 
    5349         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    5350                 :            :         /* Append data which is padded to a multiple of */
    5351                 :            :         /* the algorithms block size */
    5352                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    5353                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5354                 :            :                                 plaintext_pad_len);
    5355                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    5356                 :            : 
    5357                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    5358                 :            : 
    5359                 :            :         /* Create ZUC operation */
    5360                 :            :         retval = create_zuc_cipher_hash_generate_operation(tdata);
    5361         [ #  # ]:          0 :         if (retval < 0)
    5362                 :            :                 return retval;
    5363                 :            : 
    5364         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5365                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    5366                 :          0 :                                                tdata->cipher_iv.len);
    5367         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5368                 :            :                         return retval;
    5369                 :            :         } else
    5370                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5371                 :            :                         ut_params->op);
    5372         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5373                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    5374         [ #  # ]:          0 :         if (ut_params->obuf)
    5375                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    5376                 :            :         else
    5377                 :            :                 ciphertext = plaintext;
    5378                 :            : 
    5379                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    5380                 :            :         /* Validate obuf */
    5381   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    5382                 :            :                         ciphertext,
    5383                 :            :                         tdata->ciphertext.data,
    5384                 :            :                         tdata->validDataLenInBits.len,
    5385                 :            :                         "ZUC Ciphertext data not as expected");
    5386                 :            : 
    5387                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    5388                 :            :                                                     uint8_t *,
    5389                 :            :                                                     plaintext_pad_len);
    5390                 :            : 
    5391                 :            :         /* Validate obuf */
    5392         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    5393                 :            :                         ut_params->digest,
    5394                 :            :                         tdata->digest.data,
    5395                 :            :                         tdata->digest.len,
    5396                 :            :                         "ZUC Generated auth tag not as expected");
    5397                 :            :         return 0;
    5398                 :            : }
    5399                 :            : 
    5400                 :            : static int
    5401                 :          0 : test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
    5402                 :            : {
    5403                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5404                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5405                 :            : 
    5406                 :            :         int retval;
    5407                 :            : 
    5408                 :            :         uint8_t *plaintext, *ciphertext;
    5409                 :            :         unsigned plaintext_pad_len;
    5410                 :            :         unsigned plaintext_len;
    5411                 :            :         struct rte_cryptodev_info dev_info;
    5412                 :            : 
    5413                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5414                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5415                 :            : 
    5416         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5417         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5418                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    5419                 :          0 :                 return TEST_SKIPPED;
    5420                 :            :         }
    5421                 :            : 
    5422         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5423                 :            :                 return TEST_SKIPPED;
    5424                 :            : 
    5425                 :            :         /* Verify the capabilities */
    5426                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    5427                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    5428                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
    5429         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5430                 :            :                         &cap_idx) == NULL)
    5431                 :            :                 return TEST_SKIPPED;
    5432                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    5433                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    5434         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5435                 :            :                         &cap_idx) == NULL)
    5436                 :            :                 return TEST_SKIPPED;
    5437                 :            : 
    5438                 :            :         /* Create SNOW 3G session */
    5439                 :          0 :         retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
    5440                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    5441                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
    5442                 :            :                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
    5443                 :            :                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    5444                 :            :                         tdata->key.data, tdata->key.len,
    5445                 :          0 :                         tdata->key.data, tdata->key.len,
    5446                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    5447                 :          0 :                         tdata->cipher_iv.len);
    5448         [ #  # ]:          0 :         if (retval != 0)
    5449                 :            :                 return retval;
    5450         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5451                 :            : 
    5452                 :            :         /* clear mbuf payload */
    5453         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    5454                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
    5455                 :            : 
    5456         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    5457                 :            :         /* Append data which is padded to a multiple of */
    5458                 :            :         /* the algorithms block size */
    5459                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    5460                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5461                 :            :                                 plaintext_pad_len);
    5462                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    5463                 :            : 
    5464                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    5465                 :            : 
    5466                 :            :         /* Create SNOW 3G operation */
    5467                 :          0 :         retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
    5468                 :          0 :                         tdata->digest.len, tdata->auth_iv.data,
    5469                 :          0 :                         tdata->auth_iv.len,
    5470                 :            :                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
    5471                 :          0 :                         tdata->cipher_iv.data, tdata->cipher_iv.len,
    5472                 :          0 :                         tdata->validCipherLenInBits.len,
    5473                 :            :                         0,
    5474                 :          0 :                         tdata->validAuthLenInBits.len,
    5475                 :            :                         0
    5476                 :            :                         );
    5477         [ #  # ]:          0 :         if (retval < 0)
    5478                 :            :                 return retval;
    5479                 :            : 
    5480         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5481                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    5482                 :          0 :                                                tdata->cipher_iv.len);
    5483         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5484                 :            :                         return retval;
    5485                 :            :         } else
    5486                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5487                 :            :                         ut_params->op);
    5488         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5489                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    5490         [ #  # ]:          0 :         if (ut_params->obuf)
    5491                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    5492                 :            :         else
    5493                 :            :                 ciphertext = plaintext;
    5494                 :            : 
    5495                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    5496                 :            :         /* Validate obuf */
    5497   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    5498                 :            :                         ciphertext,
    5499                 :            :                         tdata->ciphertext.data,
    5500                 :            :                         tdata->validDataLenInBits.len,
    5501                 :            :                         "SNOW 3G Ciphertext data not as expected");
    5502                 :            : 
    5503                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    5504                 :            :                                                     uint8_t *,
    5505                 :            :                                                     plaintext_pad_len);
    5506                 :            : 
    5507                 :            :         /* Validate obuf */
    5508         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    5509                 :            :                         ut_params->digest,
    5510                 :            :                         tdata->digest.data,
    5511                 :            :                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
    5512                 :            :                         "SNOW 3G Generated auth tag not as expected");
    5513                 :            :         return 0;
    5514                 :            : }
    5515                 :            : 
    5516                 :            : static int
    5517                 :          0 : test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
    5518                 :            :         uint8_t op_mode, uint8_t verify)
    5519                 :            : {
    5520                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5521                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5522                 :            : 
    5523                 :            :         int retval;
    5524                 :            : 
    5525                 :            :         uint8_t *plaintext = NULL, *ciphertext = NULL;
    5526                 :            :         unsigned int plaintext_pad_len;
    5527                 :            :         unsigned int plaintext_len;
    5528                 :            :         unsigned int ciphertext_pad_len;
    5529                 :            :         unsigned int ciphertext_len;
    5530                 :            :         unsigned int digest_offset;
    5531                 :            : 
    5532                 :            :         struct rte_cryptodev_info dev_info;
    5533                 :            : 
    5534                 :            :         /* Verify the capabilities */
    5535                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    5536                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    5537                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
    5538         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5539                 :            :                         &cap_idx) == NULL)
    5540                 :            :                 return TEST_SKIPPED;
    5541                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    5542                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    5543         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5544                 :            :                         &cap_idx) == NULL)
    5545                 :            :                 return TEST_SKIPPED;
    5546                 :            : 
    5547         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5548                 :            :                 return TEST_SKIPPED;
    5549                 :            : 
    5550                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5551                 :            : 
    5552                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5553                 :            : 
    5554         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE) {
    5555         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    5556                 :            :                         printf("Device doesn't support digest encrypted.\n");
    5557                 :          0 :                         return TEST_SKIPPED;
    5558                 :            :                 }
    5559         [ #  # ]:          0 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    5560                 :            :                         return TEST_SKIPPED;
    5561                 :            :         }
    5562                 :            : 
    5563         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5564         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5565                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    5566                 :          0 :                 return TEST_SKIPPED;
    5567                 :            :         }
    5568                 :            : 
    5569                 :            :         /* Create SNOW 3G session */
    5570                 :          0 :         retval = create_wireless_algo_auth_cipher_session(
    5571                 :          0 :                         ts_params->valid_devs[0],
    5572                 :            :                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
    5573                 :            :                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
    5574                 :            :                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
    5575                 :            :                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
    5576                 :            :                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
    5577                 :            :                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    5578                 :            :                         tdata->key.data, tdata->key.len,
    5579                 :          0 :                         tdata->key.data, tdata->key.len,
    5580                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    5581                 :          0 :                         tdata->cipher_iv.len);
    5582         [ #  # ]:          0 :         if (retval != 0)
    5583                 :            :                 return retval;
    5584                 :            : 
    5585                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5586         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    5587                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5588                 :            : 
    5589                 :            :         /* clear mbuf payload */
    5590         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    5591         [ #  # ]:          0 :                 rte_pktmbuf_tailroom(ut_params->ibuf));
    5592         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    5593                 :          0 :                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
    5594                 :          0 :                         rte_pktmbuf_tailroom(ut_params->obuf));
    5595                 :            : 
    5596         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    5597         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    5598                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    5599                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    5600                 :            : 
    5601         [ #  # ]:          0 :         if (verify) {
    5602                 :          0 :                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5603                 :            :                                         ciphertext_pad_len);
    5604         [ #  # ]:          0 :                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    5605         [ #  # ]:          0 :                 if (op_mode == OUT_OF_PLACE)
    5606                 :          0 :                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
    5607                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    5608                 :            :                         ciphertext_len);
    5609                 :            :         } else {
    5610                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5611                 :            :                                         plaintext_pad_len);
    5612         [ #  # ]:          0 :                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    5613         [ #  # ]:          0 :                 if (op_mode == OUT_OF_PLACE)
    5614                 :          0 :                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
    5615                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    5616                 :            :         }
    5617                 :            : 
    5618                 :            :         /* Create SNOW 3G operation */
    5619                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    5620                 :          0 :                 tdata->digest.data, tdata->digest.len,
    5621                 :          0 :                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    5622                 :          0 :                 tdata->auth_iv.data, tdata->auth_iv.len,
    5623                 :          0 :                 (tdata->digest.offset_bytes == 0 ?
    5624         [ #  # ]:          0 :                 (verify ? ciphertext_pad_len : plaintext_pad_len)
    5625                 :            :                         : tdata->digest.offset_bytes),
    5626                 :          0 :                 tdata->validCipherLenInBits.len,
    5627                 :          0 :                 tdata->cipher.offset_bits,
    5628                 :          0 :                 tdata->validAuthLenInBits.len,
    5629         [ #  # ]:          0 :                 tdata->auth.offset_bits,
    5630                 :            :                 op_mode, 0, verify);
    5631                 :            : 
    5632         [ #  # ]:          0 :         if (retval < 0)
    5633                 :            :                 return retval;
    5634                 :            : 
    5635         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5636                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    5637                 :          0 :                                                tdata->cipher_iv.len);
    5638         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5639                 :            :                         return retval;
    5640                 :            :         } else
    5641                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5642                 :            :                         ut_params->op);
    5643                 :            : 
    5644         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5645                 :            : 
    5646                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    5647         [ #  # ]:          0 :                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    5648                 :            : 
    5649         [ #  # ]:          0 :         if (verify) {
    5650         [ #  # ]:          0 :                 if (ut_params->obuf)
    5651                 :          0 :                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
    5652                 :            :                                                         uint8_t *);
    5653                 :            :                 else
    5654                 :          0 :                         plaintext = ciphertext +
    5655                 :          0 :                                 (tdata->cipher.offset_bits >> 3);
    5656                 :            : 
    5657                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    5658                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    5659                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    5660                 :          0 :                         tdata->plaintext.data,
    5661                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    5662                 :            :         } else {
    5663         [ #  # ]:          0 :                 if (ut_params->obuf)
    5664                 :          0 :                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
    5665                 :            :                                                         uint8_t *);
    5666                 :            :                 else
    5667                 :            :                         ciphertext = plaintext;
    5668                 :            : 
    5669                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    5670                 :            :                         ciphertext_len);
    5671                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    5672                 :          0 :                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
    5673                 :            : 
    5674         [ #  # ]:          0 :                 if (tdata->digest.offset_bytes == 0)
    5675                 :            :                         digest_offset = plaintext_pad_len;
    5676                 :            :                 else
    5677                 :            :                         digest_offset = tdata->digest.offset_bytes;
    5678                 :          0 :                 ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    5679                 :            :                                                     uint8_t *, digest_offset);
    5680                 :            : 
    5681                 :          0 :                 debug_hexdump(stdout, "digest:", ut_params->digest,
    5682                 :          0 :                         tdata->digest.len);
    5683                 :          0 :                 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
    5684                 :          0 :                                 tdata->digest.len);
    5685                 :            :         }
    5686                 :            : 
    5687                 :            :         /* Validate obuf */
    5688         [ #  # ]:          0 :         if (verify) {
    5689   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
          #  #  #  #  #  
             #  #  #  #  
                      # ]
    5690                 :            :                         plaintext,
    5691                 :            :                         tdata->plaintext.data,
    5692                 :            :                         (tdata->plaintext.len - tdata->cipher.offset_bits -
    5693                 :            :                          (tdata->digest.len << 3)),
    5694                 :            :                         tdata->cipher.offset_bits,
    5695                 :            :                         "SNOW 3G Plaintext data not as expected");
    5696                 :            :         } else {
    5697   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
          #  #  #  #  #  
             #  #  #  #  
                      # ]
    5698                 :            :                         ciphertext,
    5699                 :            :                         tdata->ciphertext.data,
    5700                 :            :                         (tdata->validDataLenInBits.len -
    5701                 :            :                          tdata->cipher.offset_bits),
    5702                 :            :                         tdata->cipher.offset_bits,
    5703                 :            :                         "SNOW 3G Ciphertext data not as expected");
    5704                 :            : 
    5705         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    5706                 :            :                         ut_params->digest,
    5707                 :            :                         tdata->digest.data,
    5708                 :            :                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
    5709                 :            :                         "SNOW 3G Generated auth tag not as expected");
    5710                 :            :         }
    5711                 :            :         return 0;
    5712                 :            : }
    5713                 :            : 
    5714                 :            : static int
    5715                 :          0 : test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
    5716                 :            :         uint8_t op_mode, uint8_t verify)
    5717                 :            : {
    5718                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5719                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5720                 :            : 
    5721                 :            :         int retval;
    5722                 :            : 
    5723                 :            :         const uint8_t *plaintext = NULL;
    5724                 :            :         const uint8_t *ciphertext = NULL;
    5725                 :            :         const uint8_t *digest = NULL;
    5726                 :            :         unsigned int plaintext_pad_len;
    5727                 :            :         unsigned int plaintext_len;
    5728                 :            :         unsigned int ciphertext_pad_len;
    5729                 :            :         unsigned int ciphertext_len;
    5730                 :            :         uint8_t buffer[10000];
    5731                 :            :         uint8_t digest_buffer[10000];
    5732                 :            : 
    5733                 :            :         struct rte_cryptodev_info dev_info;
    5734                 :            : 
    5735                 :            :         /* Verify the capabilities */
    5736                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    5737                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    5738                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
    5739         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5740                 :            :                         &cap_idx) == NULL)
    5741                 :            :                 return TEST_SKIPPED;
    5742                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    5743                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    5744         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5745                 :            :                         &cap_idx) == NULL)
    5746                 :            :                 return TEST_SKIPPED;
    5747                 :            : 
    5748         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5749                 :            :                 return TEST_SKIPPED;
    5750                 :            : 
    5751                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5752                 :            : 
    5753                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5754                 :            : 
    5755         [ #  # ]:          0 :         if (op_mode == IN_PLACE) {
    5756         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    5757                 :            :                         printf("Device doesn't support in-place scatter-gather "
    5758                 :            :                                         "in both input and output mbufs.\n");
    5759                 :          0 :                         return TEST_SKIPPED;
    5760                 :            :                 }
    5761         [ #  # ]:          0 :                 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5762         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5763                 :            :                         printf("Device doesn't support RAW data-path APIs.\n");
    5764                 :          0 :                         return TEST_SKIPPED;
    5765                 :            :                 }
    5766                 :            :         } else {
    5767         [ #  # ]:          0 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    5768                 :            :                         return TEST_SKIPPED;
    5769         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
    5770                 :            :                         printf("Device doesn't support out-of-place scatter-gather "
    5771                 :            :                                         "in both input and output mbufs.\n");
    5772                 :          0 :                         return TEST_SKIPPED;
    5773                 :            :                 }
    5774         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    5775                 :            :                         printf("Device doesn't support digest encrypted.\n");
    5776                 :          0 :                         return TEST_SKIPPED;
    5777                 :            :                 }
    5778                 :            :         }
    5779                 :            : 
    5780                 :            :         /* Create SNOW 3G session */
    5781                 :          0 :         retval = create_wireless_algo_auth_cipher_session(
    5782                 :          0 :                         ts_params->valid_devs[0],
    5783                 :            :                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
    5784                 :            :                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
    5785                 :            :                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
    5786                 :            :                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
    5787                 :            :                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
    5788                 :            :                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    5789                 :            :                         tdata->key.data, tdata->key.len,
    5790                 :          0 :                         tdata->key.data, tdata->key.len,
    5791                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    5792                 :          0 :                         tdata->cipher_iv.len);
    5793                 :            : 
    5794         [ #  # ]:          0 :         if (retval != 0)
    5795                 :            :                 return retval;
    5796                 :            : 
    5797         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    5798         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    5799                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    5800                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    5801                 :            : 
    5802                 :          0 :         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    5803                 :            :                         plaintext_pad_len, 15, 0);
    5804         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    5805                 :            :                         "Failed to allocate input buffer in mempool");
    5806                 :            : 
    5807         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE) {
    5808                 :          0 :                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
    5809                 :            :                                 plaintext_pad_len, 15, 0);
    5810         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
    5811                 :            :                                 "Failed to allocate output buffer in mempool");
    5812                 :            :         }
    5813                 :            : 
    5814         [ #  # ]:          0 :         if (verify) {
    5815                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
    5816                 :          0 :                         tdata->ciphertext.data);
    5817         [ #  # ]:          0 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    5818                 :            :                                         ciphertext_len, buffer);
    5819                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    5820                 :            :                         ciphertext_len);
    5821                 :            :         } else {
    5822                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
    5823                 :          0 :                         tdata->plaintext.data);
    5824         [ #  # ]:          0 :                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    5825                 :            :                                         plaintext_len, buffer);
    5826                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    5827                 :            :                         plaintext_len);
    5828                 :            :         }
    5829                 :            :         memset(buffer, 0, sizeof(buffer));
    5830                 :            : 
    5831                 :            :         /* Create SNOW 3G operation */
    5832                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    5833                 :          0 :                 tdata->digest.data, tdata->digest.len,
    5834                 :          0 :                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    5835                 :          0 :                 tdata->auth_iv.data, tdata->auth_iv.len,
    5836                 :          0 :                 (tdata->digest.offset_bytes == 0 ?
    5837         [ #  # ]:          0 :                 (verify ? ciphertext_pad_len : plaintext_pad_len)
    5838                 :            :                         : tdata->digest.offset_bytes),
    5839                 :          0 :                 tdata->validCipherLenInBits.len,
    5840                 :          0 :                 tdata->cipher.offset_bits,
    5841                 :          0 :                 tdata->validAuthLenInBits.len,
    5842         [ #  # ]:          0 :                 tdata->auth.offset_bits,
    5843                 :            :                 op_mode, 1, verify);
    5844                 :            : 
    5845         [ #  # ]:          0 :         if (retval < 0)
    5846                 :            :                 return retval;
    5847                 :            : 
    5848         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5849                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    5850                 :          0 :                                                tdata->cipher_iv.len);
    5851         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5852                 :            :                         return retval;
    5853                 :            :         } else
    5854                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5855                 :            :                         ut_params->op);
    5856                 :            : 
    5857         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5858                 :            : 
    5859                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    5860         [ #  # ]:          0 :                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    5861                 :            : 
    5862         [ #  # ]:          0 :         if (verify) {
    5863         [ #  # ]:          0 :                 if (ut_params->obuf)
    5864                 :            :                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
    5865                 :            :                                         plaintext_len, buffer);
    5866                 :            :                 else
    5867         [ #  # ]:          0 :                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    5868                 :            :                                         plaintext_len, buffer);
    5869                 :            : 
    5870                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    5871                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    5872                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    5873                 :          0 :                         tdata->plaintext.data,
    5874                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    5875                 :            :         } else {
    5876         [ #  # ]:          0 :                 if (ut_params->obuf)
    5877                 :            :                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    5878                 :            :                                         ciphertext_len, buffer);
    5879                 :            :                 else
    5880         [ #  # ]:          0 :                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    5881                 :            :                                         ciphertext_len, buffer);
    5882                 :            : 
    5883                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    5884                 :            :                         ciphertext_len);
    5885                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    5886                 :          0 :                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
    5887                 :            : 
    5888         [ #  # ]:          0 :                 if (ut_params->obuf)
    5889                 :          0 :                         digest = rte_pktmbuf_read(ut_params->obuf,
    5890                 :          0 :                                 (tdata->digest.offset_bytes == 0 ?
    5891                 :            :                                 plaintext_pad_len : tdata->digest.offset_bytes),
    5892         [ #  # ]:          0 :                                 tdata->digest.len, digest_buffer);
    5893                 :            :                 else
    5894         [ #  # ]:          0 :                         digest = rte_pktmbuf_read(ut_params->ibuf,
    5895                 :          0 :                                 (tdata->digest.offset_bytes == 0 ?
    5896                 :            :                                 plaintext_pad_len : tdata->digest.offset_bytes),
    5897         [ #  # ]:          0 :                                 tdata->digest.len, digest_buffer);
    5898                 :            : 
    5899                 :          0 :                 debug_hexdump(stdout, "digest:", digest,
    5900                 :          0 :                         tdata->digest.len);
    5901                 :          0 :                 debug_hexdump(stdout, "digest expected:",
    5902                 :          0 :                         tdata->digest.data, tdata->digest.len);
    5903                 :            :         }
    5904                 :            : 
    5905                 :            :         /* Validate obuf */
    5906         [ #  # ]:          0 :         if (verify) {
    5907   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
          #  #  #  #  #  
             #  #  #  #  
                      # ]
    5908                 :            :                         plaintext,
    5909                 :            :                         tdata->plaintext.data,
    5910                 :            :                         (tdata->plaintext.len - tdata->cipher.offset_bits -
    5911                 :            :                          (tdata->digest.len << 3)),
    5912                 :            :                         tdata->cipher.offset_bits,
    5913                 :            :                         "SNOW 3G Plaintext data not as expected");
    5914                 :            :         } else {
    5915   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
          #  #  #  #  #  
             #  #  #  #  
                      # ]
    5916                 :            :                         ciphertext,
    5917                 :            :                         tdata->ciphertext.data,
    5918                 :            :                         (tdata->validDataLenInBits.len -
    5919                 :            :                          tdata->cipher.offset_bits),
    5920                 :            :                         tdata->cipher.offset_bits,
    5921                 :            :                         "SNOW 3G Ciphertext data not as expected");
    5922                 :            : 
    5923         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    5924                 :            :                         digest,
    5925                 :            :                         tdata->digest.data,
    5926                 :            :                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
    5927                 :            :                         "SNOW 3G Generated auth tag not as expected");
    5928                 :            :         }
    5929                 :            :         return 0;
    5930                 :            : }
    5931                 :            : 
    5932                 :            : static int
    5933                 :          0 : test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
    5934                 :            :         uint8_t op_mode, uint8_t verify)
    5935                 :            : {
    5936                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5937                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5938                 :            : 
    5939                 :            :         int retval;
    5940                 :            : 
    5941                 :            :         uint8_t *plaintext = NULL, *ciphertext = NULL;
    5942                 :            :         unsigned int plaintext_pad_len;
    5943                 :            :         unsigned int plaintext_len;
    5944                 :            :         unsigned int ciphertext_pad_len;
    5945                 :            :         unsigned int ciphertext_len;
    5946                 :            :         unsigned int digest_offset;
    5947                 :            : 
    5948                 :            :         struct rte_cryptodev_info dev_info;
    5949                 :            : 
    5950                 :            :         /* Verify the capabilities */
    5951                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    5952                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    5953                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
    5954         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5955                 :            :                         &cap_idx) == NULL)
    5956                 :            :                 return TEST_SKIPPED;
    5957                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    5958                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    5959         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5960                 :            :                         &cap_idx) == NULL)
    5961                 :            :                 return TEST_SKIPPED;
    5962                 :            : 
    5963                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5964                 :            : 
    5965                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5966                 :            : 
    5967         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5968         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5969                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    5970                 :          0 :                 return TEST_SKIPPED;
    5971                 :            :         }
    5972                 :            : 
    5973         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5974                 :            :                 return TEST_SKIPPED;
    5975                 :            : 
    5976         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE) {
    5977         [ #  # ]:          0 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    5978                 :            :                         return TEST_SKIPPED;
    5979         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    5980                 :            :                         printf("Device doesn't support digest encrypted.\n");
    5981                 :          0 :                         return TEST_SKIPPED;
    5982                 :            :                 }
    5983                 :            :         }
    5984                 :            : 
    5985                 :            :         /* Create KASUMI session */
    5986                 :          0 :         retval = create_wireless_algo_auth_cipher_session(
    5987                 :          0 :                         ts_params->valid_devs[0],
    5988                 :            :                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
    5989                 :            :                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
    5990                 :            :                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
    5991                 :            :                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
    5992                 :            :                         RTE_CRYPTO_AUTH_KASUMI_F9,
    5993                 :            :                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    5994                 :            :                         tdata->key.data, tdata->key.len,
    5995                 :          0 :                         tdata->key.data, tdata->key.len,
    5996                 :          0 :                         0, tdata->digest.len,
    5997                 :          0 :                         tdata->cipher_iv.len);
    5998                 :            : 
    5999         [ #  # ]:          0 :         if (retval != 0)
    6000                 :            :                 return retval;
    6001                 :            : 
    6002                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    6003         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    6004                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    6005                 :            : 
    6006                 :            :         /* clear mbuf payload */
    6007         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    6008         [ #  # ]:          0 :                 rte_pktmbuf_tailroom(ut_params->ibuf));
    6009         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    6010                 :          0 :                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
    6011                 :          0 :                         rte_pktmbuf_tailroom(ut_params->obuf));
    6012                 :            : 
    6013         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    6014         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    6015                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    6016                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    6017                 :            : 
    6018         [ #  # ]:          0 :         if (verify) {
    6019                 :          0 :                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6020                 :            :                                         ciphertext_pad_len);
    6021         [ #  # ]:          0 :                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    6022         [ #  # ]:          0 :                 if (op_mode == OUT_OF_PLACE)
    6023                 :          0 :                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
    6024                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    6025                 :            :                         ciphertext_len);
    6026                 :            :         } else {
    6027                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6028                 :            :                                         plaintext_pad_len);
    6029         [ #  # ]:          0 :                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    6030         [ #  # ]:          0 :                 if (op_mode == OUT_OF_PLACE)
    6031                 :          0 :                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
    6032                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    6033                 :            :                         plaintext_len);
    6034                 :            :         }
    6035                 :            : 
    6036                 :            :         /* Create KASUMI operation */
    6037                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    6038                 :          0 :                 tdata->digest.data, tdata->digest.len,
    6039                 :          0 :                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    6040                 :            :                 NULL, 0,
    6041                 :          0 :                 (tdata->digest.offset_bytes == 0 ?
    6042         [ #  # ]:          0 :                 (verify ? ciphertext_pad_len : plaintext_pad_len)
    6043                 :            :                         : tdata->digest.offset_bytes),
    6044                 :          0 :                 tdata->validCipherLenInBits.len,
    6045                 :          0 :                 tdata->validCipherOffsetInBits.len,
    6046         [ #  # ]:          0 :                 tdata->validAuthLenInBits.len,
    6047                 :            :                 0,
    6048                 :            :                 op_mode, 0, verify);
    6049                 :            : 
    6050         [ #  # ]:          0 :         if (retval < 0)
    6051                 :            :                 return retval;
    6052                 :            : 
    6053         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    6054                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    6055                 :          0 :                                                tdata->cipher_iv.len);
    6056         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    6057                 :            :                         return retval;
    6058                 :            :         } else
    6059                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    6060                 :            :                         ut_params->op);
    6061                 :            : 
    6062         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    6063                 :            : 
    6064                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    6065         [ #  # ]:          0 :                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    6066                 :            : 
    6067                 :            : 
    6068         [ #  # ]:          0 :         if (verify) {
    6069         [ #  # ]:          0 :                 if (ut_params->obuf)
    6070                 :          0 :                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
    6071                 :            :                                                         uint8_t *);
    6072                 :            :                 else
    6073                 :            :                         plaintext = ciphertext;
    6074                 :            : 
    6075                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    6076                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    6077                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    6078                 :          0 :                         tdata->plaintext.data,
    6079                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    6080                 :            :         } else {
    6081         [ #  # ]:          0 :                 if (ut_params->obuf)
    6082                 :          0 :                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
    6083                 :            :                                                         uint8_t *);
    6084                 :            :                 else
    6085                 :            :                         ciphertext = plaintext;
    6086                 :            : 
    6087                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    6088                 :            :                         ciphertext_len);
    6089                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    6090                 :          0 :                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
    6091                 :            : 
    6092         [ #  # ]:          0 :                 if (tdata->digest.offset_bytes == 0)
    6093                 :            :                         digest_offset = plaintext_pad_len;
    6094                 :            :                 else
    6095                 :            :                         digest_offset = tdata->digest.offset_bytes;
    6096                 :          0 :                 ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    6097                 :            :                                                     uint8_t *, digest_offset);
    6098                 :            : 
    6099                 :          0 :                 debug_hexdump(stdout, "digest:", ut_params->digest,
    6100                 :          0 :                         tdata->digest.len);
    6101                 :          0 :                 debug_hexdump(stdout, "digest expected:",
    6102                 :          0 :                         tdata->digest.data, tdata->digest.len);
    6103                 :            :         }
    6104                 :            : 
    6105                 :            :         /* Validate obuf */
    6106         [ #  # ]:          0 :         if (verify) {
    6107   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6108                 :            :                         plaintext,
    6109                 :            :                         tdata->plaintext.data,
    6110                 :            :                         tdata->plaintext.len >> 3,
    6111                 :            :                         "KASUMI Plaintext data not as expected");
    6112                 :            :         } else {
    6113   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6114                 :            :                         ciphertext,
    6115                 :            :                         tdata->ciphertext.data,
    6116                 :            :                         tdata->ciphertext.len >> 3,
    6117                 :            :                         "KASUMI Ciphertext data not as expected");
    6118                 :            : 
    6119         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    6120                 :            :                         ut_params->digest,
    6121                 :            :                         tdata->digest.data,
    6122                 :            :                         DIGEST_BYTE_LENGTH_KASUMI_F9,
    6123                 :            :                         "KASUMI Generated auth tag not as expected");
    6124                 :            :         }
    6125                 :            :         return 0;
    6126                 :            : }
    6127                 :            : 
    6128                 :            : static int
    6129                 :          0 : test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
    6130                 :            :         uint8_t op_mode, uint8_t verify)
    6131                 :            : {
    6132                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    6133                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    6134                 :            : 
    6135                 :            :         int retval;
    6136                 :            : 
    6137                 :            :         const uint8_t *plaintext = NULL;
    6138                 :            :         const uint8_t *ciphertext = NULL;
    6139                 :            :         const uint8_t *digest = NULL;
    6140                 :            :         unsigned int plaintext_pad_len;
    6141                 :            :         unsigned int plaintext_len;
    6142                 :            :         unsigned int ciphertext_pad_len;
    6143                 :            :         unsigned int ciphertext_len;
    6144                 :            :         uint8_t buffer[10000];
    6145                 :            :         uint8_t digest_buffer[10000];
    6146                 :            : 
    6147                 :            :         struct rte_cryptodev_info dev_info;
    6148                 :            : 
    6149                 :            :         /* Verify the capabilities */
    6150                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    6151                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    6152                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
    6153         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    6154                 :            :                         &cap_idx) == NULL)
    6155                 :            :                 return TEST_SKIPPED;
    6156                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    6157                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    6158         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    6159                 :            :                         &cap_idx) == NULL)
    6160                 :            :                 return TEST_SKIPPED;
    6161                 :            : 
    6162         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    6163                 :            :                 return TEST_SKIPPED;
    6164                 :            : 
    6165                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    6166                 :            : 
    6167                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    6168                 :            : 
    6169         [ #  # ]:          0 :         if (op_mode == IN_PLACE) {
    6170         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    6171                 :            :                         printf("Device doesn't support in-place scatter-gather "
    6172                 :            :                                         "in both input and output mbufs.\n");
    6173                 :          0 :                         return TEST_SKIPPED;
    6174                 :            :                 }
    6175         [ #  # ]:          0 :                 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    6176         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    6177                 :            :                         printf("Device doesn't support RAW data-path APIs.\n");
    6178                 :          0 :                         return TEST_SKIPPED;
    6179                 :            :                 }
    6180                 :            :         } else {
    6181         [ #  # ]:          0 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    6182                 :            :                         return TEST_SKIPPED;
    6183         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
    6184                 :            :                         printf("Device doesn't support out-of-place scatter-gather "
    6185                 :            :                                         "in both input and output mbufs.\n");
    6186                 :          0 :                         return TEST_SKIPPED;
    6187                 :            :                 }
    6188         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    6189                 :            :                         printf("Device doesn't support digest encrypted.\n");
    6190                 :          0 :                         return TEST_SKIPPED;
    6191                 :            :                 }
    6192                 :            :         }
    6193                 :            : 
    6194                 :            :         /* Create KASUMI session */
    6195                 :          0 :         retval = create_wireless_algo_auth_cipher_session(
    6196                 :          0 :                         ts_params->valid_devs[0],
    6197                 :            :                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
    6198                 :            :                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
    6199                 :            :                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
    6200                 :            :                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
    6201                 :            :                         RTE_CRYPTO_AUTH_KASUMI_F9,
    6202                 :            :                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    6203                 :            :                         tdata->key.data, tdata->key.len,
    6204                 :          0 :                         tdata->key.data, tdata->key.len,
    6205                 :          0 :                         0, tdata->digest.len,
    6206                 :          0 :                         tdata->cipher_iv.len);
    6207                 :            : 
    6208         [ #  # ]:          0 :         if (retval != 0)
    6209                 :            :                 return retval;
    6210                 :            : 
    6211         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    6212         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    6213                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    6214                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    6215                 :            : 
    6216                 :          0 :         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    6217                 :            :                         plaintext_pad_len, 15, 0);
    6218         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    6219                 :            :                         "Failed to allocate input buffer in mempool");
    6220                 :            : 
    6221         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE) {
    6222                 :          0 :                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
    6223                 :            :                                 plaintext_pad_len, 15, 0);
    6224         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
    6225                 :            :                                 "Failed to allocate output buffer in mempool");
    6226                 :            :         }
    6227                 :            : 
    6228         [ #  # ]:          0 :         if (verify) {
    6229                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
    6230                 :          0 :                         tdata->ciphertext.data);
    6231         [ #  # ]:          0 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    6232                 :            :                                         ciphertext_len, buffer);
    6233                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    6234                 :            :                         ciphertext_len);
    6235                 :            :         } else {
    6236                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
    6237                 :          0 :                         tdata->plaintext.data);
    6238         [ #  # ]:          0 :                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    6239                 :            :                                         plaintext_len, buffer);
    6240                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    6241                 :            :                         plaintext_len);
    6242                 :            :         }
    6243                 :            :         memset(buffer, 0, sizeof(buffer));
    6244                 :            : 
    6245                 :            :         /* Create KASUMI operation */
    6246                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    6247                 :          0 :                 tdata->digest.data, tdata->digest.len,
    6248                 :          0 :                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    6249                 :            :                 NULL, 0,
    6250                 :          0 :                 (tdata->digest.offset_bytes == 0 ?
    6251         [ #  # ]:          0 :                 (verify ? ciphertext_pad_len : plaintext_pad_len)
    6252                 :            :                         : tdata->digest.offset_bytes),
    6253                 :          0 :                 tdata->validCipherLenInBits.len,
    6254                 :          0 :                 tdata->validCipherOffsetInBits.len,
    6255         [ #  # ]:          0 :                 tdata->validAuthLenInBits.len,
    6256                 :            :                 0,
    6257                 :            :                 op_mode, 1, verify);
    6258                 :            : 
    6259         [ #  # ]:          0 :         if (retval < 0)
    6260                 :            :                 return retval;
    6261                 :            : 
    6262         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    6263                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    6264                 :          0 :                                                tdata->cipher_iv.len);
    6265         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    6266                 :            :                         return retval;
    6267                 :            :         } else
    6268                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    6269                 :            :                         ut_params->op);
    6270                 :            : 
    6271         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    6272                 :            : 
    6273                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    6274         [ #  # ]:          0 :                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    6275                 :            : 
    6276         [ #  # ]:          0 :         if (verify) {
    6277         [ #  # ]:          0 :                 if (ut_params->obuf)
    6278                 :            :                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
    6279                 :            :                                         plaintext_len, buffer);
    6280                 :            :                 else
    6281         [ #  # ]:          0 :                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    6282                 :            :                                         plaintext_len, buffer);
    6283                 :            : 
    6284                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    6285                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    6286                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    6287                 :          0 :                         tdata->plaintext.data,
    6288                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    6289                 :            :         } else {
    6290         [ #  # ]:          0 :                 if (ut_params->obuf)
    6291                 :            :                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    6292                 :            :                                         ciphertext_len, buffer);
    6293                 :            :                 else
    6294         [ #  # ]:          0 :                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    6295                 :            :                                         ciphertext_len, buffer);
    6296                 :            : 
    6297                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    6298                 :            :                         ciphertext_len);
    6299                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    6300                 :          0 :                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
    6301                 :            : 
    6302         [ #  # ]:          0 :                 if (ut_params->obuf)
    6303                 :          0 :                         digest = rte_pktmbuf_read(ut_params->obuf,
    6304                 :          0 :                                 (tdata->digest.offset_bytes == 0 ?
    6305                 :            :                                 plaintext_pad_len : tdata->digest.offset_bytes),
    6306         [ #  # ]:          0 :                                 tdata->digest.len, digest_buffer);
    6307                 :            :                 else
    6308         [ #  # ]:          0 :                         digest = rte_pktmbuf_read(ut_params->ibuf,
    6309                 :          0 :                                 (tdata->digest.offset_bytes == 0 ?
    6310                 :            :                                 plaintext_pad_len : tdata->digest.offset_bytes),
    6311         [ #  # ]:          0 :                                 tdata->digest.len, digest_buffer);
    6312                 :            : 
    6313                 :          0 :                 debug_hexdump(stdout, "digest:", digest,
    6314                 :          0 :                         tdata->digest.len);
    6315                 :          0 :                 debug_hexdump(stdout, "digest expected:",
    6316                 :          0 :                         tdata->digest.data, tdata->digest.len);
    6317                 :            :         }
    6318                 :            : 
    6319                 :            :         /* Validate obuf */
    6320         [ #  # ]:          0 :         if (verify) {
    6321   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6322                 :            :                         plaintext,
    6323                 :            :                         tdata->plaintext.data,
    6324                 :            :                         tdata->plaintext.len >> 3,
    6325                 :            :                         "KASUMI Plaintext data not as expected");
    6326                 :            :         } else {
    6327   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6328                 :            :                         ciphertext,
    6329                 :            :                         tdata->ciphertext.data,
    6330                 :            :                         tdata->validDataLenInBits.len,
    6331                 :            :                         "KASUMI Ciphertext data not as expected");
    6332                 :            : 
    6333         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    6334                 :            :                         digest,
    6335                 :            :                         tdata->digest.data,
    6336                 :            :                         DIGEST_BYTE_LENGTH_KASUMI_F9,
    6337                 :            :                         "KASUMI Generated auth tag not as expected");
    6338                 :            :         }
    6339                 :            :         return 0;
    6340                 :            : }
    6341                 :            : 
    6342                 :            : static int
    6343                 :          0 : test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
    6344                 :            : {
    6345                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    6346                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    6347                 :            : 
    6348                 :            :         int retval;
    6349                 :            : 
    6350                 :            :         uint8_t *plaintext, *ciphertext;
    6351                 :            :         unsigned plaintext_pad_len;
    6352                 :            :         unsigned plaintext_len;
    6353                 :            :         struct rte_cryptodev_info dev_info;
    6354                 :            : 
    6355                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    6356                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    6357                 :            : 
    6358         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    6359         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    6360                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    6361                 :          0 :                 return TEST_SKIPPED;
    6362                 :            :         }
    6363                 :            : 
    6364         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    6365                 :            :                 return TEST_SKIPPED;
    6366                 :            : 
    6367                 :            :         /* Verify the capabilities */
    6368                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    6369                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    6370                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
    6371         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    6372                 :            :                         &cap_idx) == NULL)
    6373                 :            :                 return TEST_SKIPPED;
    6374                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    6375                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    6376         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    6377                 :            :                         &cap_idx) == NULL)
    6378                 :            :                 return TEST_SKIPPED;
    6379                 :            : 
    6380                 :            :         /* Create KASUMI session */
    6381                 :          0 :         retval = create_wireless_algo_cipher_auth_session(
    6382                 :          0 :                         ts_params->valid_devs[0],
    6383                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    6384                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
    6385                 :            :                         RTE_CRYPTO_AUTH_KASUMI_F9,
    6386                 :            :                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    6387                 :            :                         tdata->key.data, tdata->key.len,
    6388                 :          0 :                         tdata->key.data, tdata->key.len,
    6389                 :          0 :                         0, tdata->digest.len,
    6390                 :          0 :                         tdata->cipher_iv.len);
    6391         [ #  # ]:          0 :         if (retval != 0)
    6392                 :            :                 return retval;
    6393                 :            : 
    6394         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    6395                 :            : 
    6396                 :            :         /* clear mbuf payload */
    6397         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    6398                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
    6399                 :            : 
    6400         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    6401                 :            :         /* Append data which is padded to a multiple of */
    6402                 :            :         /* the algorithms block size */
    6403                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    6404                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6405                 :            :                                 plaintext_pad_len);
    6406                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    6407                 :            : 
    6408                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    6409                 :            : 
    6410                 :            :         /* Create KASUMI operation */
    6411                 :          0 :         retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
    6412                 :          0 :                                 tdata->digest.len, NULL, 0,
    6413                 :            :                                 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
    6414                 :          0 :                                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    6415                 :          0 :                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    6416                 :          0 :                                 tdata->validCipherOffsetInBits.len,
    6417                 :          0 :                                 tdata->validAuthLenInBits.len,
    6418                 :            :                                 0
    6419                 :            :                                 );
    6420         [ #  # ]:          0 :         if (retval < 0)
    6421                 :            :                 return retval;
    6422                 :            : 
    6423         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    6424                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    6425                 :          0 :                                                tdata->cipher_iv.len);
    6426         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    6427                 :            :                         return retval;
    6428                 :            :         } else
    6429                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    6430                 :            :                         ut_params->op);
    6431         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    6432                 :            : 
    6433         [ #  # ]:          0 :         if (ut_params->op->sym->m_dst)
    6434                 :          0 :                 ut_params->obuf = ut_params->op->sym->m_dst;
    6435                 :            :         else
    6436                 :          0 :                 ut_params->obuf = ut_params->op->sym->m_src;
    6437                 :            : 
    6438                 :          0 :         ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
    6439                 :            :                                 tdata->validCipherOffsetInBits.len >> 3);
    6440                 :            : 
    6441                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    6442                 :            :                                                     uint8_t *,
    6443                 :            :                                                     plaintext_pad_len);
    6444                 :            : 
    6445                 :          0 :         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
    6446                 :            :                                 (tdata->validCipherOffsetInBits.len >> 3);
    6447                 :            :         /* Validate obuf */
    6448   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6449                 :            :                 ciphertext,
    6450                 :            :                 reference_ciphertext,
    6451                 :            :                 tdata->validCipherLenInBits.len,
    6452                 :            :                 "KASUMI Ciphertext data not as expected");
    6453                 :            : 
    6454                 :            :         /* Validate obuf */
    6455         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    6456                 :            :                 ut_params->digest,
    6457                 :            :                 tdata->digest.data,
    6458                 :            :                 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
    6459                 :            :                 "KASUMI Generated auth tag not as expected");
    6460                 :            :         return 0;
    6461                 :            : }
    6462                 :            : 
    6463                 :            : static int
    6464                 :          0 : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
    6465                 :            :                         const enum rte_crypto_cipher_algorithm cipher_algo,
    6466                 :            :                         const uint16_t key_size, const uint16_t iv_size)
    6467                 :            : {
    6468                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    6469                 :            :         const struct rte_cryptodev_symmetric_capability *cap;
    6470                 :            : 
    6471                 :            :         /* Check if device supports the algorithm */
    6472                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    6473                 :          0 :         cap_idx.algo.cipher = cipher_algo;
    6474                 :            : 
    6475                 :          0 :         cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    6476                 :            :                         &cap_idx);
    6477                 :            : 
    6478         [ #  # ]:          0 :         if (cap == NULL)
    6479                 :            :                 return -1;
    6480                 :            : 
    6481                 :            :         /* Check if device supports key size and IV size */
    6482         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
    6483                 :            :                         iv_size) < 0) {
    6484                 :          0 :                 return -1;
    6485                 :            :         }
    6486                 :            : 
    6487                 :            :         return 0;
    6488                 :            : }
    6489                 :            : 
    6490                 :            : static int
    6491                 :          0 : check_auth_capability(const struct crypto_testsuite_params *ts_params,
    6492                 :            :                         const enum rte_crypto_auth_algorithm auth_algo,
    6493                 :            :                         const uint16_t key_size, const uint16_t iv_size,
    6494                 :            :                         const uint16_t tag_size)
    6495                 :            : {
    6496                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    6497                 :            :         const struct rte_cryptodev_symmetric_capability *cap;
    6498                 :            : 
    6499                 :            :         /* Check if device supports the algorithm */
    6500                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    6501                 :          0 :         cap_idx.algo.auth = auth_algo;
    6502                 :            : 
    6503                 :          0 :         cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    6504                 :            :                         &cap_idx);
    6505                 :            : 
    6506         [ #  # ]:          0 :         if (cap == NULL)
    6507                 :            :                 return -1;
    6508                 :            : 
    6509                 :            :         /* Check if device supports key size and IV size */
    6510         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
    6511                 :            :                         tag_size, iv_size) < 0) {
    6512                 :          0 :                 return -1;
    6513                 :            :         }
    6514                 :            : 
    6515                 :            :         return 0;
    6516                 :            : }
    6517                 :            : 
    6518                 :            : static int
    6519                 :          0 : test_zuc_cipher(const struct wireless_test_data *tdata,
    6520                 :            :                 enum rte_crypto_cipher_operation direction)
    6521                 :            : {
    6522                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    6523                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    6524                 :            : 
    6525                 :            :         int retval;
    6526                 :            :         uint8_t *plaintext = NULL;
    6527                 :            :         uint8_t *ciphertext = NULL;
    6528                 :            :         unsigned int plaintext_pad_len, ciphertext_pad_len;
    6529                 :            :         unsigned int plaintext_len = 0;
    6530                 :            :         unsigned int ciphertext_len = 0;
    6531                 :            :         struct rte_cryptodev_info dev_info;
    6532                 :            : 
    6533                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    6534                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    6535                 :            : 
    6536         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    6537         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    6538                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    6539                 :          0 :                 return TEST_SKIPPED;
    6540                 :            :         }
    6541                 :            : 
    6542         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    6543                 :            :                 return TEST_SKIPPED;
    6544                 :            : 
    6545                 :            :         /* Check if device supports ZUC EEA3 */
    6546         [ #  # ]:          0 :         if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
    6547                 :          0 :                         tdata->key.len, tdata->cipher_iv.len) < 0)
    6548                 :            :                 return TEST_SKIPPED;
    6549                 :            : 
    6550                 :            :         /* Create ZUC session */
    6551                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    6552                 :            :                                         direction,
    6553                 :            :                                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
    6554                 :          0 :                                         tdata->key.data, tdata->key.len,
    6555                 :          0 :                                         tdata->cipher_iv.len);
    6556         [ #  # ]:          0 :         if (retval != 0)
    6557                 :            :                 return retval;
    6558                 :            : 
    6559         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    6560                 :            : 
    6561                 :            :         /* Clear mbuf payload */
    6562         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    6563                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    6564                 :            : 
    6565         [ #  # ]:          0 :         if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
    6566         [ #  # ]:          0 :                 plaintext_len = ceil_byte_length(tdata->plaintext.len);
    6567                 :            :                 /* Append data which is padded to a multiple */
    6568                 :            :                 /* of the algorithms block size */
    6569                 :          0 :                 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    6570                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6571                 :            :                                 plaintext_pad_len);
    6572                 :          0 :                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    6573                 :            : 
    6574                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    6575                 :            :         } else {
    6576         [ #  # ]:          0 :                 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    6577                 :            :                 /* Append data which is padded to a multiple */
    6578                 :            :                 /* of the algorithms block size */
    6579                 :          0 :                 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
    6580                 :          0 :                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6581                 :            :                                 ciphertext_pad_len);
    6582                 :          0 :                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    6583                 :            : 
    6584                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
    6585                 :            :         }
    6586                 :            : 
    6587                 :            :         /* Create ZUC operation */
    6588                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    6589                 :          0 :                                         tdata->cipher_iv.len,
    6590                 :          0 :                                         tdata->plaintext.len,
    6591                 :          0 :                                         tdata->validCipherOffsetInBits.len);
    6592         [ #  # ]:          0 :         if (retval < 0)
    6593                 :            :                 return retval;
    6594                 :            : 
    6595         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    6596                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    6597                 :          0 :                                                tdata->cipher_iv.len);
    6598         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    6599                 :            :                         return retval;
    6600                 :            :         } else
    6601                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    6602                 :            :                                                 ut_params->op);
    6603         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    6604                 :            : 
    6605                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    6606                 :            : 
    6607         [ #  # ]:          0 :         if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
    6608         [ #  # ]:          0 :                 if (ut_params->obuf)
    6609                 :          0 :                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    6610                 :            :                 else
    6611                 :            :                         ciphertext = plaintext;
    6612                 :            : 
    6613                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    6614                 :            : 
    6615                 :            :                 /* Validate obuf */
    6616   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6617                 :            :                                 ciphertext,
    6618                 :            :                                 tdata->ciphertext.data,
    6619                 :            :                                 tdata->validCipherLenInBits.len,
    6620                 :            :                                 "ZUC Ciphertext data not as expected");
    6621                 :            :         } else {
    6622         [ #  # ]:          0 :                 if (ut_params->obuf)
    6623                 :          0 :                         plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    6624                 :            :                 else
    6625                 :            :                         plaintext = ciphertext;
    6626                 :            : 
    6627                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
    6628                 :            : 
    6629                 :          0 :                 const uint8_t *reference_plaintext = tdata->plaintext.data +
    6630                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    6631                 :            : 
    6632                 :            :                 /* Validate obuf */
    6633   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6634                 :            :                                 plaintext,
    6635                 :            :                                 reference_plaintext,
    6636                 :            :                                 tdata->validCipherLenInBits.len,
    6637                 :            :                                 "ZUC Plaintext data not as expected");
    6638                 :            :         }
    6639                 :            : 
    6640                 :            :         return 0;
    6641                 :            : }
    6642                 :            : 
    6643                 :            : static int
    6644                 :          0 : test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
    6645                 :            :                 enum rte_crypto_cipher_operation direction)
    6646                 :            : {
    6647                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    6648                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    6649                 :            : 
    6650                 :            :         int retval;
    6651                 :            : 
    6652                 :            :         unsigned int plaintext_pad_len, ciphertext_pad_len;
    6653                 :            :         unsigned int plaintext_len = 0;
    6654                 :            :         unsigned int ciphertext_len = 0;
    6655                 :            :         const uint8_t *ciphertext, *plaintext;
    6656                 :            :         uint8_t buffer[2048];
    6657                 :            :         struct rte_cryptodev_info dev_info;
    6658                 :            : 
    6659                 :            :         /* Check if device supports ZUC EEA3 */
    6660         [ #  # ]:          0 :         if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
    6661                 :          0 :                         tdata->key.len, tdata->cipher_iv.len) < 0)
    6662                 :            :                 return TEST_SKIPPED;
    6663                 :            : 
    6664         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    6665                 :            :                 return TEST_SKIPPED;
    6666                 :            : 
    6667                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    6668                 :            : 
    6669                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    6670                 :            : 
    6671         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    6672                 :            :                 printf("Device doesn't support in-place scatter-gather. "
    6673                 :            :                                 "Test Skipped.\n");
    6674                 :          0 :                 return TEST_SKIPPED;
    6675                 :            :         }
    6676                 :            : 
    6677         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    6678         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    6679                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    6680                 :          0 :                 return TEST_SKIPPED;
    6681                 :            :         }
    6682                 :            : 
    6683         [ #  # ]:          0 :         if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
    6684         [ #  # ]:          0 :                 plaintext_len = ceil_byte_length(tdata->plaintext.len);
    6685                 :            : 
    6686                 :            :                 /* Append data which is padded to a multiple */
    6687                 :            :                 /* of the algorithms block size */
    6688                 :          0 :                 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    6689                 :            : 
    6690                 :          0 :                 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    6691                 :            :                                 plaintext_pad_len, 10, 0);
    6692                 :            : 
    6693                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
    6694                 :          0 :                                 tdata->plaintext.data);
    6695                 :            :         } else {
    6696         [ #  # ]:          0 :                 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    6697                 :            : 
    6698                 :            :                 /* Append data which is padded to a multiple */
    6699                 :            :                 /* of the algorithms block size */
    6700                 :          0 :                 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
    6701                 :            : 
    6702                 :          0 :                 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    6703                 :            :                                 ciphertext_pad_len, 10, 0);
    6704                 :            : 
    6705                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
    6706                 :          0 :                                 tdata->ciphertext.data);
    6707                 :            : 
    6708                 :            :         }
    6709                 :            : 
    6710                 :            :         /* Create ZUC session */
    6711                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    6712                 :            :                         direction,
    6713                 :            :                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
    6714                 :          0 :                         tdata->key.data, tdata->key.len,
    6715                 :          0 :                         tdata->cipher_iv.len);
    6716         [ #  # ]:          0 :         if (retval < 0)
    6717                 :            :                 return retval;
    6718                 :            : 
    6719                 :            :         /* Clear mbuf payload */
    6720         [ #  # ]:          0 :         if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
    6721                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
    6722                 :            :         else
    6723                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
    6724                 :            : 
    6725                 :            :         /* Create ZUC operation */
    6726                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    6727                 :          0 :                         tdata->cipher_iv.len, tdata->plaintext.len,
    6728                 :          0 :                         tdata->validCipherOffsetInBits.len);
    6729         [ #  # ]:          0 :         if (retval < 0)
    6730                 :            :                 return retval;
    6731                 :            : 
    6732         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    6733                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    6734                 :          0 :                                                tdata->cipher_iv.len);
    6735         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    6736                 :            :                         return retval;
    6737                 :            :         } else
    6738                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    6739                 :            :                                                 ut_params->op);
    6740         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    6741                 :            : 
    6742                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    6743                 :            : 
    6744         [ #  # ]:          0 :         if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
    6745         [ #  # ]:          0 :                 if (ut_params->obuf)
    6746                 :            :                         ciphertext = rte_pktmbuf_read(ut_params->obuf,
    6747                 :            :                                 0, plaintext_len, buffer);
    6748                 :            :                 else
    6749         [ #  # ]:          0 :                         ciphertext = rte_pktmbuf_read(ut_params->ibuf,
    6750                 :            :                                 0, plaintext_len, buffer);
    6751                 :            : 
    6752                 :            :                 /* Validate obuf */
    6753                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    6754                 :            : 
    6755                 :            :                 /* Validate obuf */
    6756   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6757                 :            :                         ciphertext,
    6758                 :            :                         tdata->ciphertext.data,
    6759                 :            :                         tdata->validCipherLenInBits.len,
    6760                 :            :                         "ZUC Ciphertext data not as expected");
    6761                 :            :         } else {
    6762         [ #  # ]:          0 :                 if (ut_params->obuf)
    6763                 :            :                         plaintext = rte_pktmbuf_read(ut_params->obuf,
    6764                 :            :                                 0, ciphertext_len, buffer);
    6765                 :            :                 else
    6766         [ #  # ]:          0 :                         plaintext = rte_pktmbuf_read(ut_params->ibuf,
    6767                 :            :                                 0, ciphertext_len, buffer);
    6768                 :            : 
    6769                 :            :                 /* Validate obuf */
    6770                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
    6771                 :            : 
    6772                 :            :                 /* Validate obuf */
    6773   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6774                 :            :                         plaintext,
    6775                 :            :                         tdata->plaintext.data,
    6776                 :            :                         tdata->validCipherLenInBits.len,
    6777                 :            :                         "ZUC Plaintext data not as expected");
    6778                 :            :                 }
    6779                 :            : 
    6780                 :            :         return 0;
    6781                 :            : }
    6782                 :            : 
    6783                 :            : static int
    6784                 :          0 : test_zuc_authentication(const struct wireless_test_data *tdata,
    6785                 :            :                 enum rte_crypto_auth_operation auth_op)
    6786                 :            : {
    6787                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    6788                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    6789                 :            : 
    6790                 :            :         int retval;
    6791                 :            :         unsigned plaintext_pad_len;
    6792                 :            :         unsigned plaintext_len;
    6793                 :            :         uint8_t *plaintext;
    6794                 :            : 
    6795                 :            :         struct rte_cryptodev_info dev_info;
    6796                 :            : 
    6797                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    6798                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    6799                 :            : 
    6800         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
    6801         [ #  # ]:          0 :                         (tdata->validAuthLenInBits.len % 8 != 0)) {
    6802                 :            :                 printf("Device doesn't support NON-Byte Aligned Data.\n");
    6803                 :          0 :                 return TEST_SKIPPED;
    6804                 :            :         }
    6805                 :            : 
    6806         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    6807         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    6808                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    6809                 :          0 :                 return TEST_SKIPPED;
    6810                 :            :         }
    6811                 :            : 
    6812         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    6813                 :            :                 return TEST_SKIPPED;
    6814                 :            : 
    6815                 :            :         /* Check if device supports ZUC EIA3 */
    6816         [ #  # ]:          0 :         if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
    6817                 :          0 :                         tdata->key.len, tdata->auth_iv.len,
    6818                 :          0 :                         tdata->digest.len) < 0)
    6819                 :            :                 return TEST_SKIPPED;
    6820                 :            : 
    6821                 :            :         /* Create ZUC session */
    6822                 :          0 :         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
    6823                 :          0 :                         tdata->key.data, tdata->key.len,
    6824                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    6825                 :            :                         auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
    6826         [ #  # ]:          0 :         if (retval != 0)
    6827                 :            :                 return retval;
    6828                 :            : 
    6829                 :            :         /* alloc mbuf and set payload */
    6830         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    6831                 :            : 
    6832         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    6833                 :            :         rte_pktmbuf_tailroom(ut_params->ibuf));
    6834                 :            : 
    6835         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    6836                 :            :         /* Append data which is padded to a multiple of */
    6837                 :            :         /* the algorithms block size */
    6838                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    6839                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6840                 :            :                                 plaintext_pad_len);
    6841                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    6842                 :            : 
    6843                 :            :         /* Create ZUC operation */
    6844                 :          0 :         retval = create_wireless_algo_hash_operation(tdata->digest.data,
    6845                 :          0 :                         tdata->digest.len,
    6846                 :          0 :                         tdata->auth_iv.data, tdata->auth_iv.len,
    6847                 :            :                         plaintext_pad_len,
    6848                 :          0 :                         auth_op, tdata->validAuthLenInBits.len, 0);
    6849         [ #  # ]:          0 :         if (retval < 0)
    6850                 :            :                 return retval;
    6851                 :            : 
    6852         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    6853                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
    6854                 :            :                                                0);
    6855         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    6856                 :            :                         return retval;
    6857                 :            :         } else
    6858                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    6859                 :            :                                 ut_params->op);
    6860         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    6861                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    6862                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    6863                 :            :                                                     uint8_t *,
    6864                 :            :                                                     plaintext_pad_len);
    6865                 :            : 
    6866         [ #  # ]:          0 :         if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
    6867                 :            :                 /* Validate obuf */
    6868         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    6869                 :            :                                 ut_params->digest,
    6870                 :            :                                 tdata->digest.data,
    6871                 :            :                                 tdata->digest.len,
    6872                 :            :                                 "ZUC Generated auth tag not as expected");
    6873                 :            :                 return 0;
    6874                 :            :         }
    6875                 :            : 
    6876                 :            :         /* Validate obuf */
    6877         [ #  # ]:          0 :         if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
    6878                 :            :                 return 0;
    6879                 :            :         else
    6880                 :          0 :                 return -1;
    6881                 :            : 
    6882                 :            :         return 0;
    6883                 :            : }
    6884                 :            : 
    6885                 :            : static int
    6886                 :          0 : test_zuc_auth_cipher(const struct wireless_test_data *tdata,
    6887                 :            :         uint8_t op_mode, uint8_t verify)
    6888                 :            : {
    6889                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    6890                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    6891                 :            : 
    6892                 :            :         int retval;
    6893                 :            : 
    6894                 :            :         uint8_t *plaintext = NULL, *ciphertext = NULL;
    6895                 :            :         unsigned int plaintext_pad_len;
    6896                 :            :         unsigned int plaintext_len;
    6897                 :            :         unsigned int ciphertext_pad_len;
    6898                 :            :         unsigned int ciphertext_len;
    6899                 :            :         unsigned int digest_offset;
    6900                 :            : 
    6901                 :            :         struct rte_cryptodev_info dev_info;
    6902                 :            : 
    6903                 :            :         /* Check if device supports ZUC EEA3 */
    6904         [ #  # ]:          0 :         if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
    6905                 :          0 :                         tdata->key.len, tdata->cipher_iv.len) < 0)
    6906                 :            :                 return TEST_SKIPPED;
    6907                 :            : 
    6908                 :            :         /* Check if device supports ZUC EIA3 */
    6909         [ #  # ]:          0 :         if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
    6910                 :          0 :                         tdata->key.len, tdata->auth_iv.len,
    6911                 :          0 :                         tdata->digest.len) < 0)
    6912                 :            :                 return TEST_SKIPPED;
    6913                 :            : 
    6914         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    6915                 :            :                 return TEST_SKIPPED;
    6916                 :            : 
    6917                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    6918                 :            : 
    6919                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    6920                 :            : 
    6921         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    6922                 :            :                 printf("Device doesn't support digest encrypted.\n");
    6923                 :          0 :                 return TEST_SKIPPED;
    6924                 :            :         }
    6925         [ #  # ]:          0 :         if (op_mode == IN_PLACE) {
    6926         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    6927                 :            :                         printf("Device doesn't support in-place scatter-gather "
    6928                 :            :                                         "in both input and output mbufs.\n");
    6929                 :          0 :                         return TEST_SKIPPED;
    6930                 :            :                 }
    6931                 :            : 
    6932         [ #  # ]:          0 :                 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    6933         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    6934                 :            :                         printf("Device doesn't support RAW data-path APIs.\n");
    6935                 :          0 :                         return TEST_SKIPPED;
    6936                 :            :                 }
    6937                 :            :         } else {
    6938         [ #  # ]:          0 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    6939                 :            :                         return TEST_SKIPPED;
    6940         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
    6941                 :            :                         printf("Device doesn't support out-of-place scatter-gather "
    6942                 :            :                                         "in both input and output mbufs.\n");
    6943                 :          0 :                         return TEST_SKIPPED;
    6944                 :            :                 }
    6945                 :            :         }
    6946                 :            : 
    6947                 :            :         /* Create ZUC session */
    6948                 :          0 :         retval = create_wireless_algo_auth_cipher_session(
    6949                 :          0 :                         ts_params->valid_devs[0],
    6950                 :            :                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
    6951                 :            :                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
    6952                 :            :                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
    6953                 :            :                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
    6954                 :            :                         RTE_CRYPTO_AUTH_ZUC_EIA3,
    6955                 :            :                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
    6956                 :            :                         tdata->key.data, tdata->key.len,
    6957                 :          0 :                         tdata->key.data, tdata->key.len,
    6958                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    6959                 :          0 :                         tdata->cipher_iv.len);
    6960                 :            : 
    6961         [ #  # ]:          0 :         if (retval != 0)
    6962                 :            :                 return retval;
    6963                 :            : 
    6964                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    6965         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    6966                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    6967                 :            : 
    6968                 :            :         /* clear mbuf payload */
    6969         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    6970         [ #  # ]:          0 :                 rte_pktmbuf_tailroom(ut_params->ibuf));
    6971         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    6972                 :          0 :                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
    6973                 :          0 :                         rte_pktmbuf_tailroom(ut_params->obuf));
    6974                 :            : 
    6975         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    6976         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    6977                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    6978                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    6979                 :            : 
    6980         [ #  # ]:          0 :         if (verify) {
    6981                 :          0 :                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6982                 :            :                                         ciphertext_pad_len);
    6983                 :          0 :                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    6984                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    6985                 :            :                         ciphertext_len);
    6986                 :            :         } else {
    6987                 :            :                 /* make sure enough space to cover partial digest verify case */
    6988                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6989                 :            :                                         ciphertext_pad_len);
    6990                 :          0 :                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    6991                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    6992                 :            :                         plaintext_len);
    6993                 :            :         }
    6994                 :            : 
    6995         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    6996                 :          0 :                 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
    6997                 :            : 
    6998                 :            :         /* Create ZUC operation */
    6999                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    7000                 :          0 :                 tdata->digest.data, tdata->digest.len,
    7001                 :          0 :                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    7002                 :          0 :                 tdata->auth_iv.data, tdata->auth_iv.len,
    7003                 :          0 :                 (tdata->digest.offset_bytes == 0 ?
    7004         [ #  # ]:          0 :                 (verify ? ciphertext_pad_len : plaintext_pad_len)
    7005                 :            :                         : tdata->digest.offset_bytes),
    7006                 :          0 :                 tdata->validCipherLenInBits.len,
    7007                 :          0 :                 tdata->validCipherOffsetInBits.len,
    7008         [ #  # ]:          0 :                 tdata->validAuthLenInBits.len,
    7009                 :            :                 0,
    7010                 :            :                 op_mode, 0, verify);
    7011                 :            : 
    7012         [ #  # ]:          0 :         if (retval < 0)
    7013                 :            :                 return retval;
    7014                 :            : 
    7015         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    7016                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    7017                 :          0 :                                                tdata->cipher_iv.len);
    7018         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    7019                 :            :                         return retval;
    7020                 :            :         } else
    7021                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    7022                 :            :                         ut_params->op);
    7023                 :            : 
    7024         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    7025                 :            : 
    7026                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    7027         [ #  # ]:          0 :                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    7028                 :            : 
    7029                 :            : 
    7030         [ #  # ]:          0 :         if (verify) {
    7031         [ #  # ]:          0 :                 if (ut_params->obuf)
    7032                 :          0 :                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
    7033                 :            :                                                         uint8_t *);
    7034                 :            :                 else
    7035                 :            :                         plaintext = ciphertext;
    7036                 :            : 
    7037                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    7038                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    7039                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    7040                 :          0 :                         tdata->plaintext.data,
    7041                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    7042                 :            :         } else {
    7043         [ #  # ]:          0 :                 if (ut_params->obuf)
    7044                 :          0 :                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
    7045                 :            :                                                         uint8_t *);
    7046                 :            :                 else
    7047                 :            :                         ciphertext = plaintext;
    7048                 :            : 
    7049                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    7050                 :            :                         ciphertext_len);
    7051                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    7052                 :          0 :                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
    7053                 :            : 
    7054         [ #  # ]:          0 :                 if (tdata->digest.offset_bytes == 0)
    7055                 :            :                         digest_offset = plaintext_pad_len;
    7056                 :            :                 else
    7057                 :            :                         digest_offset =  tdata->digest.offset_bytes;
    7058                 :          0 :                 ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    7059                 :            :                                             uint8_t *, digest_offset);
    7060                 :            : 
    7061                 :          0 :                 debug_hexdump(stdout, "digest:", ut_params->digest,
    7062                 :          0 :                         tdata->digest.len);
    7063                 :          0 :                 debug_hexdump(stdout, "digest expected:",
    7064                 :          0 :                         tdata->digest.data, tdata->digest.len);
    7065                 :            :         }
    7066                 :            : 
    7067                 :            :         /* Validate obuf */
    7068         [ #  # ]:          0 :         if (verify) {
    7069   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    7070                 :            :                         plaintext,
    7071                 :            :                         tdata->plaintext.data,
    7072                 :            :                         tdata->plaintext.len >> 3,
    7073                 :            :                         "ZUC Plaintext data not as expected");
    7074                 :            :         } else {
    7075   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    7076                 :            :                         ciphertext,
    7077                 :            :                         tdata->ciphertext.data,
    7078                 :            :                         tdata->ciphertext.len >> 3,
    7079                 :            :                         "ZUC Ciphertext data not as expected");
    7080                 :            : 
    7081         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    7082                 :            :                         ut_params->digest,
    7083                 :            :                         tdata->digest.data,
    7084                 :            :                         tdata->digest.len,
    7085                 :            :                         "ZUC Generated auth tag not as expected");
    7086                 :            :         }
    7087                 :            :         return 0;
    7088                 :            : }
    7089                 :            : 
    7090                 :            : static int
    7091                 :          0 : test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
    7092                 :            :         uint8_t op_mode, uint8_t verify)
    7093                 :            : {
    7094                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    7095                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    7096                 :            : 
    7097                 :            :         int retval;
    7098                 :            : 
    7099                 :            :         const uint8_t *plaintext = NULL;
    7100                 :            :         const uint8_t *ciphertext = NULL;
    7101                 :            :         const uint8_t *digest = NULL;
    7102                 :            :         unsigned int plaintext_pad_len;
    7103                 :            :         unsigned int plaintext_len;
    7104                 :            :         unsigned int ciphertext_pad_len;
    7105                 :            :         unsigned int ciphertext_len;
    7106                 :            :         uint8_t buffer[10000];
    7107                 :            :         uint8_t digest_buffer[10000];
    7108                 :            : 
    7109                 :            :         struct rte_cryptodev_info dev_info;
    7110                 :            : 
    7111                 :            :         /* Check if device supports ZUC EEA3 */
    7112         [ #  # ]:          0 :         if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
    7113                 :          0 :                         tdata->key.len, tdata->cipher_iv.len) < 0)
    7114                 :            :                 return TEST_SKIPPED;
    7115                 :            : 
    7116                 :            :         /* Check if device supports ZUC EIA3 */
    7117         [ #  # ]:          0 :         if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
    7118                 :          0 :                         tdata->key.len, tdata->auth_iv.len,
    7119                 :          0 :                         tdata->digest.len) < 0)
    7120                 :            :                 return TEST_SKIPPED;
    7121                 :            : 
    7122         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    7123                 :            :                 return TEST_SKIPPED;
    7124                 :            : 
    7125                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    7126                 :            : 
    7127                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    7128                 :            : 
    7129         [ #  # ]:          0 :         if (op_mode == IN_PLACE) {
    7130         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    7131                 :            :                         printf("Device doesn't support in-place scatter-gather "
    7132                 :            :                                         "in both input and output mbufs.\n");
    7133                 :          0 :                         return TEST_SKIPPED;
    7134                 :            :                 }
    7135                 :            : 
    7136         [ #  # ]:          0 :                 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    7137         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    7138                 :            :                         printf("Device doesn't support RAW data-path APIs.\n");
    7139                 :          0 :                         return TEST_SKIPPED;
    7140                 :            :                 }
    7141                 :            :         } else {
    7142         [ #  # ]:          0 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    7143                 :            :                         return TEST_SKIPPED;
    7144         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
    7145                 :            :                         printf("Device doesn't support out-of-place scatter-gather "
    7146                 :            :                                         "in both input and output mbufs.\n");
    7147                 :          0 :                         return TEST_SKIPPED;
    7148                 :            :                 }
    7149         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    7150                 :            :                         printf("Device doesn't support digest encrypted.\n");
    7151                 :          0 :                         return TEST_SKIPPED;
    7152                 :            :                 }
    7153                 :            :         }
    7154                 :            : 
    7155                 :            :         /* Create ZUC session */
    7156                 :          0 :         retval = create_wireless_algo_auth_cipher_session(
    7157                 :          0 :                         ts_params->valid_devs[0],
    7158                 :            :                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
    7159                 :            :                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
    7160                 :            :                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
    7161                 :            :                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
    7162                 :            :                         RTE_CRYPTO_AUTH_ZUC_EIA3,
    7163                 :            :                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
    7164                 :            :                         tdata->key.data, tdata->key.len,
    7165                 :          0 :                         tdata->key.data, tdata->key.len,
    7166                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    7167                 :          0 :                         tdata->cipher_iv.len);
    7168                 :            : 
    7169         [ #  # ]:          0 :         if (retval != 0)
    7170                 :            :                 return retval;
    7171                 :            : 
    7172         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    7173         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    7174                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    7175                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    7176                 :            : 
    7177                 :          0 :         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    7178                 :            :                         plaintext_pad_len, 15, 0);
    7179         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    7180                 :            :                         "Failed to allocate input buffer in mempool");
    7181                 :            : 
    7182         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE) {
    7183                 :          0 :                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
    7184                 :            :                                 plaintext_pad_len, 15, 0);
    7185         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
    7186                 :            :                                 "Failed to allocate output buffer in mempool");
    7187                 :            :         }
    7188                 :            : 
    7189         [ #  # ]:          0 :         if (verify) {
    7190                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
    7191                 :          0 :                         tdata->ciphertext.data);
    7192         [ #  # ]:          0 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    7193                 :            :                                         ciphertext_len, buffer);
    7194                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    7195                 :            :                         ciphertext_len);
    7196                 :            :         } else {
    7197                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
    7198                 :          0 :                         tdata->plaintext.data);
    7199         [ #  # ]:          0 :                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    7200                 :            :                                         plaintext_len, buffer);
    7201                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    7202                 :            :                         plaintext_len);
    7203                 :            :         }
    7204                 :            :         memset(buffer, 0, sizeof(buffer));
    7205                 :            : 
    7206                 :            :         /* Create ZUC operation */
    7207                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    7208                 :          0 :                 tdata->digest.data, tdata->digest.len,
    7209                 :          0 :                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    7210                 :          0 :                 tdata->auth_iv.data, tdata->auth_iv.len,
    7211                 :          0 :                 (tdata->digest.offset_bytes == 0 ?
    7212         [ #  # ]:          0 :                 (verify ? ciphertext_pad_len : plaintext_pad_len)
    7213                 :            :                         : tdata->digest.offset_bytes),
    7214                 :          0 :                 tdata->validCipherLenInBits.len,
    7215                 :          0 :                 tdata->validCipherOffsetInBits.len,
    7216         [ #  # ]:          0 :                 tdata->validAuthLenInBits.len,
    7217                 :            :                 0,
    7218                 :            :                 op_mode, 1, verify);
    7219                 :            : 
    7220         [ #  # ]:          0 :         if (retval < 0)
    7221                 :            :                 return retval;
    7222                 :            : 
    7223         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    7224                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    7225                 :          0 :                                                tdata->cipher_iv.len);
    7226         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    7227                 :            :                         return retval;
    7228                 :            :         } else
    7229                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    7230                 :            :                         ut_params->op);
    7231                 :            : 
    7232         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    7233                 :            : 
    7234                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    7235         [ #  # ]:          0 :                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    7236                 :            : 
    7237         [ #  # ]:          0 :         if (verify) {
    7238         [ #  # ]:          0 :                 if (ut_params->obuf)
    7239                 :            :                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
    7240                 :            :                                         plaintext_len, buffer);
    7241                 :            :                 else
    7242         [ #  # ]:          0 :                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    7243                 :            :                                         plaintext_len, buffer);
    7244                 :            : 
    7245                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    7246                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    7247                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    7248                 :          0 :                         tdata->plaintext.data,
    7249                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    7250                 :            :         } else {
    7251         [ #  # ]:          0 :                 if (ut_params->obuf)
    7252                 :            :                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    7253                 :            :                                         ciphertext_len, buffer);
    7254                 :            :                 else
    7255         [ #  # ]:          0 :                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    7256                 :            :                                         ciphertext_len, buffer);
    7257                 :            : 
    7258                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    7259                 :            :                         ciphertext_len);
    7260                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    7261                 :          0 :                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
    7262                 :            : 
    7263         [ #  # ]:          0 :                 if (ut_params->obuf)
    7264                 :          0 :                         digest = rte_pktmbuf_read(ut_params->obuf,
    7265                 :          0 :                                 (tdata->digest.offset_bytes == 0 ?
    7266                 :            :                                 plaintext_pad_len : tdata->digest.offset_bytes),
    7267         [ #  # ]:          0 :                                 tdata->digest.len, digest_buffer);
    7268                 :            :                 else
    7269         [ #  # ]:          0 :                         digest = rte_pktmbuf_read(ut_params->ibuf,
    7270                 :          0 :                                 (tdata->digest.offset_bytes == 0 ?
    7271                 :            :                                 plaintext_pad_len : tdata->digest.offset_bytes),
    7272         [ #  # ]:          0 :                                 tdata->digest.len, digest_buffer);
    7273                 :            : 
    7274                 :          0 :                 debug_hexdump(stdout, "digest:", digest,
    7275                 :          0 :                         tdata->digest.len);
    7276                 :          0 :                 debug_hexdump(stdout, "digest expected:",
    7277                 :          0 :                         tdata->digest.data, tdata->digest.len);
    7278                 :            :         }
    7279                 :            : 
    7280                 :            :         /* Validate obuf */
    7281         [ #  # ]:          0 :         if (verify) {
    7282   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    7283                 :            :                         plaintext,
    7284                 :            :                         tdata->plaintext.data,
    7285                 :            :                         tdata->plaintext.len >> 3,
    7286                 :            :                         "ZUC Plaintext data not as expected");
    7287                 :            :         } else {
    7288   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    7289                 :            :                         ciphertext,
    7290                 :            :                         tdata->ciphertext.data,
    7291                 :            :                         tdata->validDataLenInBits.len,
    7292                 :            :                         "ZUC Ciphertext data not as expected");
    7293                 :            : 
    7294         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    7295                 :            :                         digest,
    7296                 :            :                         tdata->digest.data,
    7297                 :            :                         tdata->digest.len,
    7298                 :            :                         "ZUC Generated auth tag not as expected");
    7299                 :            :         }
    7300                 :            :         return 0;
    7301                 :            : }
    7302                 :            : 
    7303                 :            : static int
    7304                 :          0 : test_kasumi_encryption_test_case_1(void)
    7305                 :            : {
    7306                 :          0 :         return test_kasumi_encryption(&kasumi_test_case_1);
    7307                 :            : }
    7308                 :            : 
    7309                 :            : static int
    7310                 :          0 : test_kasumi_encryption_test_case_1_sgl(void)
    7311                 :            : {
    7312                 :          0 :         return test_kasumi_encryption_sgl(&kasumi_test_case_1);
    7313                 :            : }
    7314                 :            : 
    7315                 :            : static int
    7316                 :          0 : test_kasumi_encryption_test_case_1_oop(void)
    7317                 :            : {
    7318                 :          0 :         return test_kasumi_encryption_oop(&kasumi_test_case_1);
    7319                 :            : }
    7320                 :            : 
    7321                 :            : static int
    7322                 :          0 : test_kasumi_encryption_test_case_1_oop_sgl(void)
    7323                 :            : {
    7324                 :          0 :         return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
    7325                 :            : }
    7326                 :            : 
    7327                 :            : static int
    7328                 :          0 : test_kasumi_encryption_test_case_2(void)
    7329                 :            : {
    7330                 :          0 :         return test_kasumi_encryption(&kasumi_test_case_2);
    7331                 :            : }
    7332                 :            : 
    7333                 :            : static int
    7334                 :          0 : test_kasumi_encryption_test_case_3(void)
    7335                 :            : {
    7336                 :          0 :         return test_kasumi_encryption(&kasumi_test_case_3);
    7337                 :            : }
    7338                 :            : 
    7339                 :            : static int
    7340                 :          0 : test_kasumi_encryption_test_case_4(void)
    7341                 :            : {
    7342                 :          0 :         return test_kasumi_encryption(&kasumi_test_case_4);
    7343                 :            : }
    7344                 :            : 
    7345                 :            : static int
    7346                 :          0 : test_kasumi_encryption_test_case_5(void)
    7347                 :            : {
    7348                 :          0 :         return test_kasumi_encryption(&kasumi_test_case_5);
    7349                 :            : }
    7350                 :            : 
    7351                 :            : static int
    7352                 :          0 : test_kasumi_decryption_test_case_1(void)
    7353                 :            : {
    7354                 :          0 :         return test_kasumi_decryption(&kasumi_test_case_1);
    7355                 :            : }
    7356                 :            : 
    7357                 :            : static int
    7358                 :          0 : test_kasumi_decryption_test_case_1_oop(void)
    7359                 :            : {
    7360                 :          0 :         return test_kasumi_decryption_oop(&kasumi_test_case_1);
    7361                 :            : }
    7362                 :            : 
    7363                 :            : static int
    7364                 :          0 : test_kasumi_decryption_test_case_2(void)
    7365                 :            : {
    7366                 :          0 :         return test_kasumi_decryption(&kasumi_test_case_2);
    7367                 :            : }
    7368                 :            : 
    7369                 :            : static int
    7370                 :          0 : test_kasumi_decryption_test_case_3(void)
    7371                 :            : {
    7372                 :            :         /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
    7373         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    7374                 :            :                 return TEST_SKIPPED;
    7375                 :          0 :         return test_kasumi_decryption(&kasumi_test_case_3);
    7376                 :            : }
    7377                 :            : 
    7378                 :            : static int
    7379                 :          0 : test_kasumi_decryption_test_case_4(void)
    7380                 :            : {
    7381                 :          0 :         return test_kasumi_decryption(&kasumi_test_case_4);
    7382                 :            : }
    7383                 :            : 
    7384                 :            : static int
    7385                 :          0 : test_kasumi_decryption_test_case_5(void)
    7386                 :            : {
    7387                 :          0 :         return test_kasumi_decryption(&kasumi_test_case_5);
    7388                 :            : }
    7389                 :            : static int
    7390                 :          0 : test_snow3g_encryption_test_case_1(void)
    7391                 :            : {
    7392                 :          0 :         return test_snow3g_encryption(&snow3g_test_case_1);
    7393                 :            : }
    7394                 :            : 
    7395                 :            : static int
    7396                 :          0 : test_snow3g_encryption_test_case_1_oop(void)
    7397                 :            : {
    7398                 :          0 :         return test_snow3g_encryption_oop(&snow3g_test_case_1);
    7399                 :            : }
    7400                 :            : 
    7401                 :            : static int
    7402                 :          0 : test_snow3g_encryption_test_case_1_oop_sgl(void)
    7403                 :            : {
    7404                 :          0 :         return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
    7405                 :            : }
    7406                 :            : 
    7407                 :            : static int
    7408                 :          0 : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
    7409                 :            : {
    7410                 :          0 :         return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
    7411                 :            : }
    7412                 :            : 
    7413                 :            : static int
    7414                 :          0 : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
    7415                 :            : {
    7416                 :          0 :         return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
    7417                 :            : }
    7418                 :            : 
    7419                 :            : static int
    7420                 :          0 : test_snow3g_encryption_test_case_1_offset_oop(void)
    7421                 :            : {
    7422                 :          0 :         return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
    7423                 :            : }
    7424                 :            : 
    7425                 :            : static int
    7426                 :          0 : test_snow3g_encryption_test_case_2(void)
    7427                 :            : {
    7428                 :          0 :         return test_snow3g_encryption(&snow3g_test_case_2);
    7429                 :            : }
    7430                 :            : 
    7431                 :            : static int
    7432                 :          0 : test_snow3g_encryption_test_case_3(void)
    7433                 :            : {
    7434                 :          0 :         return test_snow3g_encryption(&snow3g_test_case_3);
    7435                 :            : }
    7436                 :            : 
    7437                 :            : static int
    7438                 :          0 : test_snow3g_encryption_test_case_4(void)
    7439                 :            : {
    7440                 :          0 :         return test_snow3g_encryption(&snow3g_test_case_4);
    7441                 :            : }
    7442                 :            : 
    7443                 :            : static int
    7444                 :          0 : test_snow3g_encryption_test_case_5(void)
    7445                 :            : {
    7446                 :          0 :         return test_snow3g_encryption(&snow3g_test_case_5);
    7447                 :            : }
    7448                 :            : 
    7449                 :            : static int
    7450                 :          0 : test_snow3g_decryption_test_case_1(void)
    7451                 :            : {
    7452                 :          0 :         return test_snow3g_decryption(&snow3g_test_case_1);
    7453                 :            : }
    7454                 :            : 
    7455                 :            : static int
    7456                 :          0 : test_snow3g_decryption_test_case_1_oop(void)
    7457                 :            : {
    7458                 :          0 :         return test_snow3g_decryption_oop(&snow3g_test_case_1);
    7459                 :            : }
    7460                 :            : 
    7461                 :            : static int
    7462                 :          0 : test_snow3g_decryption_test_case_2(void)
    7463                 :            : {
    7464                 :          0 :         return test_snow3g_decryption(&snow3g_test_case_2);
    7465                 :            : }
    7466                 :            : 
    7467                 :            : static int
    7468                 :          0 : test_snow3g_decryption_test_case_3(void)
    7469                 :            : {
    7470                 :          0 :         return test_snow3g_decryption(&snow3g_test_case_3);
    7471                 :            : }
    7472                 :            : 
    7473                 :            : static int
    7474                 :          0 : test_snow3g_decryption_test_case_4(void)
    7475                 :            : {
    7476                 :          0 :         return test_snow3g_decryption(&snow3g_test_case_4);
    7477                 :            : }
    7478                 :            : 
    7479                 :            : static int
    7480                 :          0 : test_snow3g_decryption_test_case_5(void)
    7481                 :            : {
    7482                 :          0 :         return test_snow3g_decryption(&snow3g_test_case_5);
    7483                 :            : }
    7484                 :            : 
    7485                 :            : /*
    7486                 :            :  * Function prepares snow3g_hash_test_data from snow3g_test_data.
    7487                 :            :  * Pattern digest from snow3g_test_data must be allocated as
    7488                 :            :  * 4 last bytes in plaintext.
    7489                 :            :  */
    7490                 :            : static void
    7491                 :          0 : snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
    7492                 :            :                 struct snow3g_hash_test_data *output)
    7493                 :            : {
    7494         [ #  # ]:          0 :         if ((pattern != NULL) && (output != NULL)) {
    7495                 :          0 :                 output->key.len = pattern->key.len;
    7496                 :            : 
    7497                 :          0 :                 memcpy(output->key.data,
    7498                 :          0 :                 pattern->key.data, pattern->key.len);
    7499                 :            : 
    7500                 :          0 :                 output->auth_iv.len = pattern->auth_iv.len;
    7501                 :            : 
    7502                 :          0 :                 memcpy(output->auth_iv.data,
    7503                 :          0 :                 pattern->auth_iv.data, pattern->auth_iv.len);
    7504                 :            : 
    7505                 :          0 :                 output->plaintext.len = pattern->plaintext.len;
    7506                 :            : 
    7507                 :          0 :                 memcpy(output->plaintext.data,
    7508                 :          0 :                 pattern->plaintext.data, pattern->plaintext.len >> 3);
    7509                 :            : 
    7510                 :          0 :                 output->digest.len = pattern->digest.len;
    7511                 :            : 
    7512                 :          0 :                 memcpy(output->digest.data,
    7513                 :          0 :                 &pattern->plaintext.data[pattern->digest.offset_bytes],
    7514                 :            :                 pattern->digest.len);
    7515                 :            : 
    7516                 :          0 :                 output->validAuthLenInBits.len =
    7517                 :          0 :                 pattern->validAuthLenInBits.len;
    7518                 :            :         }
    7519                 :          0 : }
    7520                 :            : 
    7521                 :            : /*
    7522                 :            :  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
    7523                 :            :  */
    7524                 :            : static int
    7525                 :          0 : test_snow3g_decryption_with_digest_test_case_1(void)
    7526                 :            : {
    7527                 :            :         int ret;
    7528                 :            :         struct snow3g_hash_test_data snow3g_hash_data;
    7529                 :            :         struct rte_cryptodev_info dev_info;
    7530                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    7531                 :            : 
    7532                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    7533                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    7534                 :            : 
    7535         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    7536                 :            :                 printf("Device doesn't support encrypted digest operations.\n");
    7537                 :          0 :                 return TEST_SKIPPED;
    7538                 :            :         }
    7539                 :            : 
    7540                 :            :         /*
    7541                 :            :          * Function prepare data for hash verification test case.
    7542                 :            :          * Digest is allocated in 4 last bytes in plaintext, pattern.
    7543                 :            :          */
    7544                 :          0 :         snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
    7545                 :            : 
    7546                 :          0 :         ret = test_snow3g_decryption(&snow3g_test_case_7);
    7547         [ #  # ]:          0 :         if (ret != 0)
    7548                 :            :                 return ret;
    7549                 :            : 
    7550                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_data);
    7551                 :            : }
    7552                 :            : 
    7553                 :            : static int
    7554                 :          0 : test_snow3g_cipher_auth_test_case_1(void)
    7555                 :            : {
    7556                 :          0 :         return test_snow3g_cipher_auth(&snow3g_test_case_3);
    7557                 :            : }
    7558                 :            : 
    7559                 :            : static int
    7560                 :          0 : test_snow3g_auth_cipher_test_case_1(void)
    7561                 :            : {
    7562                 :          0 :         return test_snow3g_auth_cipher(
    7563                 :            :                 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
    7564                 :            : }
    7565                 :            : 
    7566                 :            : static int
    7567                 :          0 : test_snow3g_auth_cipher_test_case_2(void)
    7568                 :            : {
    7569                 :          0 :         return test_snow3g_auth_cipher(
    7570                 :            :                 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
    7571                 :            : }
    7572                 :            : 
    7573                 :            : static int
    7574                 :          0 : test_snow3g_auth_cipher_test_case_2_oop(void)
    7575                 :            : {
    7576                 :          0 :         return test_snow3g_auth_cipher(
    7577                 :            :                 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
    7578                 :            : }
    7579                 :            : 
    7580                 :            : static int
    7581                 :          0 : test_snow3g_auth_cipher_part_digest_enc(void)
    7582                 :            : {
    7583                 :          0 :         return test_snow3g_auth_cipher(
    7584                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7585                 :            :                         IN_PLACE, 0);
    7586                 :            : }
    7587                 :            : 
    7588                 :            : static int
    7589                 :          0 : test_snow3g_auth_cipher_part_digest_enc_oop(void)
    7590                 :            : {
    7591                 :          0 :         return test_snow3g_auth_cipher(
    7592                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7593                 :            :                         OUT_OF_PLACE, 0);
    7594                 :            : }
    7595                 :            : 
    7596                 :            : static int
    7597                 :          0 : test_snow3g_auth_cipher_test_case_3_sgl(void)
    7598                 :            : {
    7599                 :            :         /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
    7600         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    7601                 :            :                 return TEST_SKIPPED;
    7602                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7603                 :            :                 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
    7604                 :            : }
    7605                 :            : 
    7606                 :            : static int
    7607                 :          0 : test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
    7608                 :            : {
    7609                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7610                 :            :                 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
    7611                 :            : }
    7612                 :            : 
    7613                 :            : static int
    7614                 :          0 : test_snow3g_auth_cipher_part_digest_enc_sgl(void)
    7615                 :            : {
    7616                 :            :         /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
    7617         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    7618                 :            :                 return TEST_SKIPPED;
    7619                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7620                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7621                 :            :                         IN_PLACE, 0);
    7622                 :            : }
    7623                 :            : 
    7624                 :            : static int
    7625                 :          0 : test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
    7626                 :            : {
    7627                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7628                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7629                 :            :                         OUT_OF_PLACE, 0);
    7630                 :            : }
    7631                 :            : 
    7632                 :            : static int
    7633                 :          0 : test_snow3g_auth_cipher_total_digest_enc_1(void)
    7634                 :            : {
    7635                 :          0 :         return test_snow3g_auth_cipher(
    7636                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
    7637                 :            : }
    7638                 :            : 
    7639                 :            : static int
    7640                 :          0 : test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
    7641                 :            : {
    7642                 :          0 :         return test_snow3g_auth_cipher(
    7643                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
    7644                 :            : }
    7645                 :            : 
    7646                 :            : static int
    7647                 :          0 : test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
    7648                 :            : {
    7649                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7650                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
    7651                 :            : }
    7652                 :            : 
    7653                 :            : static int
    7654                 :          0 : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
    7655                 :            : {
    7656                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7657                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
    7658                 :            : }
    7659                 :            : 
    7660                 :            : static int
    7661                 :          0 : test_snow3g_auth_cipher_verify_test_case_1(void)
    7662                 :            : {
    7663                 :          0 :         return test_snow3g_auth_cipher(
    7664                 :            :                 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
    7665                 :            : }
    7666                 :            : 
    7667                 :            : static int
    7668                 :          0 : test_snow3g_auth_cipher_verify_test_case_2(void)
    7669                 :            : {
    7670                 :          0 :         return test_snow3g_auth_cipher(
    7671                 :            :                 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
    7672                 :            : }
    7673                 :            : 
    7674                 :            : static int
    7675                 :          0 : test_snow3g_auth_cipher_verify_test_case_2_oop(void)
    7676                 :            : {
    7677                 :          0 :         return test_snow3g_auth_cipher(
    7678                 :            :                 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
    7679                 :            : }
    7680                 :            : 
    7681                 :            : static int
    7682                 :          0 : test_snow3g_auth_cipher_verify_part_digest_enc(void)
    7683                 :            : {
    7684                 :          0 :         return test_snow3g_auth_cipher(
    7685                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7686                 :            :                         IN_PLACE, 1);
    7687                 :            : }
    7688                 :            : 
    7689                 :            : static int
    7690                 :          0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
    7691                 :            : {
    7692                 :          0 :         return test_snow3g_auth_cipher(
    7693                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7694                 :            :                         OUT_OF_PLACE, 1);
    7695                 :            : }
    7696                 :            : 
    7697                 :            : static int
    7698                 :          0 : test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
    7699                 :            : {
    7700                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7701                 :            :                 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
    7702                 :            : }
    7703                 :            : 
    7704                 :            : static int
    7705                 :          0 : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
    7706                 :            : {
    7707                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7708                 :            :                 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
    7709                 :            : }
    7710                 :            : 
    7711                 :            : static int
    7712                 :          0 : test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
    7713                 :            : {
    7714                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7715                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7716                 :            :                         IN_PLACE, 1);
    7717                 :            : }
    7718                 :            : 
    7719                 :            : static int
    7720                 :          0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
    7721                 :            : {
    7722                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7723                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7724                 :            :                         OUT_OF_PLACE, 1);
    7725                 :            : }
    7726                 :            : 
    7727                 :            : static int
    7728                 :          0 : test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
    7729                 :            : {
    7730                 :          0 :         return test_snow3g_auth_cipher(
    7731                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
    7732                 :            : }
    7733                 :            : 
    7734                 :            : static int
    7735                 :          0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
    7736                 :            : {
    7737                 :          0 :         return test_snow3g_auth_cipher(
    7738                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
    7739                 :            : }
    7740                 :            : 
    7741                 :            : static int
    7742                 :          0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
    7743                 :            : {
    7744                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7745                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
    7746                 :            : }
    7747                 :            : 
    7748                 :            : static int
    7749                 :          0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
    7750                 :            : {
    7751                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7752                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
    7753                 :            : }
    7754                 :            : 
    7755                 :            : static int
    7756                 :          0 : test_snow3g_auth_cipher_with_digest_test_case_1(void)
    7757                 :            : {
    7758                 :          0 :         return test_snow3g_auth_cipher(
    7759                 :            :                 &snow3g_test_case_7, IN_PLACE, 0);
    7760                 :            : }
    7761                 :            : 
    7762                 :            : static int
    7763                 :          0 : test_kasumi_auth_cipher_test_case_1(void)
    7764                 :            : {
    7765                 :          0 :         return test_kasumi_auth_cipher(
    7766                 :            :                 &kasumi_test_case_3, IN_PLACE, 0);
    7767                 :            : }
    7768                 :            : 
    7769                 :            : static int
    7770                 :          0 : test_kasumi_auth_cipher_test_case_2(void)
    7771                 :            : {
    7772                 :          0 :         return test_kasumi_auth_cipher(
    7773                 :            :                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
    7774                 :            : }
    7775                 :            : 
    7776                 :            : static int
    7777                 :          0 : test_kasumi_auth_cipher_test_case_2_oop(void)
    7778                 :            : {
    7779                 :          0 :         return test_kasumi_auth_cipher(
    7780                 :            :                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
    7781                 :            : }
    7782                 :            : 
    7783                 :            : static int
    7784                 :          0 : test_kasumi_auth_cipher_test_case_2_sgl(void)
    7785                 :            : {
    7786                 :          0 :         return test_kasumi_auth_cipher_sgl(
    7787                 :            :                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
    7788                 :            : }
    7789                 :            : 
    7790                 :            : static int
    7791                 :          0 : test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
    7792                 :            : {
    7793                 :          0 :         return test_kasumi_auth_cipher_sgl(
    7794                 :            :                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
    7795                 :            : }
    7796                 :            : 
    7797                 :            : static int
    7798                 :          0 : test_kasumi_auth_cipher_verify_test_case_1(void)
    7799                 :            : {
    7800                 :          0 :         return test_kasumi_auth_cipher(
    7801                 :            :                 &kasumi_test_case_3, IN_PLACE, 1);
    7802                 :            : }
    7803                 :            : 
    7804                 :            : static int
    7805                 :          0 : test_kasumi_auth_cipher_verify_test_case_2(void)
    7806                 :            : {
    7807                 :          0 :         return test_kasumi_auth_cipher(
    7808                 :            :                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
    7809                 :            : }
    7810                 :            : 
    7811                 :            : static int
    7812                 :          0 : test_kasumi_auth_cipher_verify_test_case_2_oop(void)
    7813                 :            : {
    7814                 :          0 :         return test_kasumi_auth_cipher(
    7815                 :            :                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
    7816                 :            : }
    7817                 :            : 
    7818                 :            : static int
    7819                 :          0 : test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
    7820                 :            : {
    7821                 :          0 :         return test_kasumi_auth_cipher_sgl(
    7822                 :            :                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
    7823                 :            : }
    7824                 :            : 
    7825                 :            : static int
    7826                 :          0 : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
    7827                 :            : {
    7828                 :          0 :         return test_kasumi_auth_cipher_sgl(
    7829                 :            :                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
    7830                 :            : }
    7831                 :            : 
    7832                 :            : static int
    7833                 :          0 : test_kasumi_cipher_auth_test_case_1(void)
    7834                 :            : {
    7835                 :          0 :         return test_kasumi_cipher_auth(&kasumi_test_case_6);
    7836                 :            : }
    7837                 :            : 
    7838                 :            : static int
    7839                 :          0 : test_zuc_encryption_test_case_1(void)
    7840                 :            : {
    7841                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_193b,
    7842                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    7843                 :            : }
    7844                 :            : 
    7845                 :            : static int
    7846                 :          0 : test_zuc_encryption_test_case_2(void)
    7847                 :            : {
    7848                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_800b,
    7849                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    7850                 :            : }
    7851                 :            : 
    7852                 :            : static int
    7853                 :          0 : test_zuc_encryption_test_case_3(void)
    7854                 :            : {
    7855                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_1570b,
    7856                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    7857                 :            : }
    7858                 :            : 
    7859                 :            : static int
    7860                 :          0 : test_zuc_encryption_test_case_4(void)
    7861                 :            : {
    7862                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_2798b,
    7863                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    7864                 :            : }
    7865                 :            : 
    7866                 :            : static int
    7867                 :          0 : test_zuc_encryption_test_case_5(void)
    7868                 :            : {
    7869                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_4019b,
    7870                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    7871                 :            : }
    7872                 :            : 
    7873                 :            : static int
    7874                 :          0 : test_zuc_encryption_test_case_6_sgl(void)
    7875                 :            : {
    7876                 :          0 :         return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
    7877                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    7878                 :            : }
    7879                 :            : 
    7880                 :            : static int
    7881                 :          0 : test_zuc_decryption_test_case_1(void)
    7882                 :            : {
    7883                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_193b,
    7884                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    7885                 :            : }
    7886                 :            : 
    7887                 :            : static int
    7888                 :          0 : test_zuc_decryption_test_case_2(void)
    7889                 :            : {
    7890                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_800b,
    7891                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    7892                 :            : }
    7893                 :            : 
    7894                 :            : static int
    7895                 :          0 : test_zuc_decryption_test_case_3(void)
    7896                 :            : {
    7897                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_1570b,
    7898                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    7899                 :            : }
    7900                 :            : 
    7901                 :            : static int
    7902                 :          0 : test_zuc_decryption_test_case_4(void)
    7903                 :            : {
    7904                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_2798b,
    7905                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    7906                 :            : }
    7907                 :            : 
    7908                 :            : static int
    7909                 :          0 : test_zuc_decryption_test_case_5(void)
    7910                 :            : {
    7911                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_4019b,
    7912                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    7913                 :            : }
    7914                 :            : 
    7915                 :            : static int
    7916                 :          0 : test_zuc_decryption_test_case_6_sgl(void)
    7917                 :            : {
    7918                 :          0 :         return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
    7919                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    7920                 :            : }
    7921                 :            : 
    7922                 :            : static int
    7923                 :          0 : test_zuc_hash_generate_test_case_1(void)
    7924                 :            : {
    7925                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_1b,
    7926                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7927                 :            : }
    7928                 :            : 
    7929                 :            : static int
    7930                 :          0 : test_zuc_hash_generate_test_case_2(void)
    7931                 :            : {
    7932                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_90b,
    7933                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7934                 :            : }
    7935                 :            : 
    7936                 :            : static int
    7937                 :          0 : test_zuc_hash_generate_test_case_3(void)
    7938                 :            : {
    7939                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_577b,
    7940                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7941                 :            : }
    7942                 :            : 
    7943                 :            : static int
    7944                 :          0 : test_zuc_hash_generate_test_case_4(void)
    7945                 :            : {
    7946                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_2079b,
    7947                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7948                 :            : }
    7949                 :            : 
    7950                 :            : static int
    7951                 :          0 : test_zuc_hash_generate_test_case_5(void)
    7952                 :            : {
    7953                 :          0 :         return test_zuc_authentication(&zuc_test_auth_5670b,
    7954                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7955                 :            : }
    7956                 :            : 
    7957                 :            : static int
    7958                 :          0 : test_zuc_hash_generate_test_case_6(void)
    7959                 :            : {
    7960                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_128b,
    7961                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7962                 :            : }
    7963                 :            : 
    7964                 :            : static int
    7965                 :          0 : test_zuc_hash_generate_test_case_7(void)
    7966                 :            : {
    7967                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_2080b,
    7968                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7969                 :            : }
    7970                 :            : 
    7971                 :            : static int
    7972                 :          0 : test_zuc_hash_generate_test_case_8(void)
    7973                 :            : {
    7974                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_584b,
    7975                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7976                 :            : }
    7977                 :            : 
    7978                 :            : static int
    7979                 :          0 : test_zuc_hash_verify_test_case_1(void)
    7980                 :            : {
    7981                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_1b,
    7982                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    7983                 :            : }
    7984                 :            : 
    7985                 :            : static int
    7986                 :          0 : test_zuc_hash_verify_test_case_2(void)
    7987                 :            : {
    7988                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_90b,
    7989                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    7990                 :            : }
    7991                 :            : 
    7992                 :            : static int
    7993                 :          0 : test_zuc_hash_verify_test_case_3(void)
    7994                 :            : {
    7995                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_577b,
    7996                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    7997                 :            : }
    7998                 :            : 
    7999                 :            : static int
    8000                 :          0 : test_zuc_hash_verify_test_case_4(void)
    8001                 :            : {
    8002                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_2079b,
    8003                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8004                 :            : }
    8005                 :            : 
    8006                 :            : static int
    8007                 :          0 : test_zuc_hash_verify_test_case_5(void)
    8008                 :            : {
    8009                 :          0 :         return test_zuc_authentication(&zuc_test_auth_5670b,
    8010                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8011                 :            : }
    8012                 :            : 
    8013                 :            : static int
    8014                 :          0 : test_zuc_hash_verify_test_case_6(void)
    8015                 :            : {
    8016                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_128b,
    8017                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8018                 :            : }
    8019                 :            : 
    8020                 :            : static int
    8021                 :          0 : test_zuc_hash_verify_test_case_7(void)
    8022                 :            : {
    8023                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_2080b,
    8024                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8025                 :            : }
    8026                 :            : 
    8027                 :            : static int
    8028                 :          0 : test_zuc_hash_verify_test_case_8(void)
    8029                 :            : {
    8030                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_584b,
    8031                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8032                 :            : }
    8033                 :            : 
    8034                 :            : static int
    8035                 :          0 : test_zuc_cipher_auth_test_case_1(void)
    8036                 :            : {
    8037                 :          0 :         return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
    8038                 :            : }
    8039                 :            : 
    8040                 :            : static int
    8041                 :          0 : test_zuc_cipher_auth_test_case_2(void)
    8042                 :            : {
    8043                 :          0 :         return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
    8044                 :            : }
    8045                 :            : 
    8046                 :            : static int
    8047                 :          0 : test_zuc_auth_cipher_test_case_1(void)
    8048                 :            : {
    8049                 :          0 :         return test_zuc_auth_cipher(
    8050                 :            :                 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
    8051                 :            : }
    8052                 :            : 
    8053                 :            : static int
    8054                 :          0 : test_zuc_auth_cipher_test_case_1_oop(void)
    8055                 :            : {
    8056                 :          0 :         return test_zuc_auth_cipher(
    8057                 :            :                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
    8058                 :            : }
    8059                 :            : 
    8060                 :            : static int
    8061                 :          0 : test_zuc_auth_cipher_test_case_1_sgl(void)
    8062                 :            : {
    8063                 :          0 :         return test_zuc_auth_cipher_sgl(
    8064                 :            :                 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
    8065                 :            : }
    8066                 :            : 
    8067                 :            : static int
    8068                 :          0 : test_zuc_auth_cipher_test_case_1_oop_sgl(void)
    8069                 :            : {
    8070                 :          0 :         return test_zuc_auth_cipher_sgl(
    8071                 :            :                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
    8072                 :            : }
    8073                 :            : 
    8074                 :            : static int
    8075                 :          0 : test_zuc_auth_cipher_test_case_2(void)
    8076                 :            : {
    8077                 :          0 :         return test_zuc_auth_cipher(
    8078                 :            :                 &zuc_auth_cipher_test_case_2, IN_PLACE, 0);
    8079                 :            : }
    8080                 :            : 
    8081                 :            : static int
    8082                 :          0 : test_zuc_auth_cipher_test_case_2_oop(void)
    8083                 :            : {
    8084                 :          0 :         return test_zuc_auth_cipher(
    8085                 :            :                 &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
    8086                 :            : }
    8087                 :            : 
    8088                 :            : static int
    8089                 :          0 : test_zuc_auth_cipher_verify_test_case_1(void)
    8090                 :            : {
    8091                 :          0 :         return test_zuc_auth_cipher(
    8092                 :            :                 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
    8093                 :            : }
    8094                 :            : 
    8095                 :            : static int
    8096                 :          0 : test_zuc_auth_cipher_verify_test_case_1_oop(void)
    8097                 :            : {
    8098                 :          0 :         return test_zuc_auth_cipher(
    8099                 :            :                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
    8100                 :            : }
    8101                 :            : 
    8102                 :            : static int
    8103                 :          0 : test_zuc_auth_cipher_verify_test_case_1_sgl(void)
    8104                 :            : {
    8105                 :          0 :         return test_zuc_auth_cipher_sgl(
    8106                 :            :                 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
    8107                 :            : }
    8108                 :            : 
    8109                 :            : static int
    8110                 :          0 : test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
    8111                 :            : {
    8112                 :          0 :         return test_zuc_auth_cipher_sgl(
    8113                 :            :                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
    8114                 :            : }
    8115                 :            : 
    8116                 :            : static int
    8117                 :          0 : test_zuc_auth_cipher_verify_test_case_2(void)
    8118                 :            : {
    8119                 :          0 :         return test_zuc_auth_cipher(
    8120                 :            :                 &zuc_auth_cipher_test_case_2, IN_PLACE, 1);
    8121                 :            : }
    8122                 :            : 
    8123                 :            : static int
    8124                 :          0 : test_zuc_auth_cipher_verify_test_case_2_oop(void)
    8125                 :            : {
    8126                 :          0 :         return test_zuc_auth_cipher(
    8127                 :            :                 &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
    8128                 :            : }
    8129                 :            : 
    8130                 :            : static int
    8131                 :          0 : test_zuc256_encryption_test_case_1(void)
    8132                 :            : {
    8133                 :          0 :         return test_zuc_cipher(&zuc256_test_case_cipher_1,
    8134                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    8135                 :            : }
    8136                 :            : 
    8137                 :            : static int
    8138                 :          0 : test_zuc256_encryption_test_case_2(void)
    8139                 :            : {
    8140                 :          0 :         return test_zuc_cipher(&zuc256_test_case_cipher_2,
    8141                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    8142                 :            : }
    8143                 :            : 
    8144                 :            : static int
    8145                 :          0 : test_zuc256_decryption_test_case_1(void)
    8146                 :            : {
    8147                 :          0 :         return test_zuc_cipher(&zuc256_test_case_cipher_1,
    8148                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    8149                 :            : }
    8150                 :            : 
    8151                 :            : static int
    8152                 :          0 : test_zuc256_decryption_test_case_2(void)
    8153                 :            : {
    8154                 :          0 :         return test_zuc_cipher(&zuc256_test_case_cipher_2,
    8155                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    8156                 :            : }
    8157                 :            : 
    8158                 :            : static int
    8159                 :          0 : test_zuc256_hash_generate_4b_tag_test_case_1(void)
    8160                 :            : {
    8161                 :          0 :         return test_zuc_authentication(&zuc256_test_case_auth_1,
    8162                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    8163                 :            : }
    8164                 :            : 
    8165                 :            : static int
    8166                 :          0 : test_zuc256_hash_generate_4b_tag_test_case_2(void)
    8167                 :            : {
    8168                 :          0 :         return test_zuc_authentication(&zuc256_test_case_auth_2,
    8169                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    8170                 :            : }
    8171                 :            : 
    8172                 :            : static int
    8173                 :          0 : test_zuc256_hash_generate_4b_tag_test_case_3(void)
    8174                 :            : {
    8175                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
    8176                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    8177                 :            : }
    8178                 :            : 
    8179                 :            : static int
    8180                 :          0 : test_zuc256_hash_generate_8b_tag_test_case_1(void)
    8181                 :            : {
    8182                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
    8183                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    8184                 :            : }
    8185                 :            : 
    8186                 :            : static int
    8187                 :          0 : test_zuc256_hash_generate_16b_tag_test_case_1(void)
    8188                 :            : {
    8189                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
    8190                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    8191                 :            : }
    8192                 :            : 
    8193                 :            : static int
    8194                 :          0 : test_zuc256_hash_verify_4b_tag_test_case_1(void)
    8195                 :            : {
    8196                 :          0 :         return test_zuc_authentication(&zuc256_test_case_auth_1,
    8197                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8198                 :            : }
    8199                 :            : 
    8200                 :            : static int
    8201                 :          0 : test_zuc256_hash_verify_4b_tag_test_case_2(void)
    8202                 :            : {
    8203                 :          0 :         return test_zuc_authentication(&zuc256_test_case_auth_2,
    8204                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8205                 :            : }
    8206                 :            : 
    8207                 :            : static int
    8208                 :          0 : test_zuc256_hash_verify_4b_tag_test_case_3(void)
    8209                 :            : {
    8210                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
    8211                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8212                 :            : }
    8213                 :            : 
    8214                 :            : static int
    8215                 :          0 : test_zuc256_hash_verify_8b_tag_test_case_1(void)
    8216                 :            : {
    8217                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
    8218                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8219                 :            : }
    8220                 :            : 
    8221                 :            : static int
    8222                 :          0 : test_zuc256_hash_verify_16b_tag_test_case_1(void)
    8223                 :            : {
    8224                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
    8225                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8226                 :            : }
    8227                 :            : 
    8228                 :            : static int
    8229                 :          0 : test_zuc256_cipher_auth_4b_tag_test_case_1(void)
    8230                 :            : {
    8231                 :          0 :         return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
    8232                 :            : }
    8233                 :            : 
    8234                 :            : static int
    8235                 :          0 : test_zuc256_cipher_auth_4b_tag_test_case_2(void)
    8236                 :            : {
    8237                 :          0 :         return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
    8238                 :            : }
    8239                 :            : 
    8240                 :            : static int
    8241                 :          0 : test_zuc256_cipher_auth_8b_tag_test_case_1(void)
    8242                 :            : {
    8243                 :          0 :         return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
    8244                 :            : }
    8245                 :            : 
    8246                 :            : static int
    8247                 :          0 : test_zuc256_cipher_auth_16b_tag_test_case_1(void)
    8248                 :            : {
    8249                 :          0 :         return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
    8250                 :            : }
    8251                 :            : 
    8252                 :            : static int
    8253                 :          0 : test_zuc256_auth_cipher_4b_tag_test_case_1(void)
    8254                 :            : {
    8255                 :          0 :         return test_zuc_auth_cipher(
    8256                 :            :                 &zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
    8257                 :            : }
    8258                 :            : 
    8259                 :            : static int
    8260                 :          0 : test_zuc256_auth_cipher_4b_tag_test_case_2(void)
    8261                 :            : {
    8262                 :          0 :         return test_zuc_auth_cipher(
    8263                 :            :                 &zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
    8264                 :            : }
    8265                 :            : 
    8266                 :            : static int
    8267                 :          0 : test_zuc256_auth_cipher_8b_tag_test_case_1(void)
    8268                 :            : {
    8269                 :          0 :         return test_zuc_auth_cipher(
    8270                 :            :                 &zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
    8271                 :            : }
    8272                 :            : 
    8273                 :            : static int
    8274                 :          0 : test_zuc256_auth_cipher_16b_tag_test_case_1(void)
    8275                 :            : {
    8276                 :          0 :         return test_zuc_auth_cipher(
    8277                 :            :                 &zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
    8278                 :            : }
    8279                 :            : 
    8280                 :            : static int
    8281                 :          0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
    8282                 :            : {
    8283                 :          0 :         return test_zuc_auth_cipher(
    8284                 :            :                 &zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
    8285                 :            : }
    8286                 :            : 
    8287                 :            : static int
    8288                 :          0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
    8289                 :            : {
    8290                 :          0 :         return test_zuc_auth_cipher(
    8291                 :            :                 &zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
    8292                 :            : }
    8293                 :            : 
    8294                 :            : static int
    8295                 :          0 : test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
    8296                 :            : {
    8297                 :          0 :         return test_zuc_auth_cipher(
    8298                 :            :                 &zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
    8299                 :            : }
    8300                 :            : 
    8301                 :            : static int
    8302                 :          0 : test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
    8303                 :            : {
    8304                 :          0 :         return test_zuc_auth_cipher(
    8305                 :            :                 &zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
    8306                 :            : }
    8307                 :            : 
    8308                 :            : static int
    8309                 :         50 : test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
    8310                 :            : {
    8311                 :         50 :         uint8_t dev_id = testsuite_params.valid_devs[0];
    8312                 :            : 
    8313                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    8314                 :            : 
    8315                 :            :         /* Check if device supports particular cipher algorithm */
    8316                 :         50 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    8317                 :         50 :         cap_idx.algo.cipher = tdata->cipher_algo;
    8318         [ +  + ]:         50 :         if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
    8319                 :            :                 return TEST_SKIPPED;
    8320                 :            : 
    8321                 :            :         /* Check if device supports particular hash algorithm */
    8322                 :         24 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    8323                 :         24 :         cap_idx.algo.auth = tdata->auth_algo;
    8324         [ +  + ]:         24 :         if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
    8325                 :         12 :                 return TEST_SKIPPED;
    8326                 :            : 
    8327                 :            :         return 0;
    8328                 :            : }
    8329                 :            : 
    8330                 :            : static int
    8331                 :         44 : test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
    8332                 :            :         uint8_t op_mode, uint8_t verify)
    8333                 :            : {
    8334                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    8335                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    8336                 :            : 
    8337                 :            :         int retval;
    8338                 :            : 
    8339                 :            :         uint8_t *plaintext = NULL, *ciphertext = NULL;
    8340                 :            :         unsigned int plaintext_pad_len;
    8341                 :            :         unsigned int plaintext_len;
    8342                 :            :         unsigned int ciphertext_pad_len;
    8343                 :            :         unsigned int ciphertext_len;
    8344                 :            :         unsigned int digest_offset;
    8345                 :            : 
    8346                 :            :         struct rte_cryptodev_info dev_info;
    8347                 :            :         struct rte_crypto_op *op;
    8348                 :            : 
    8349                 :            :         /* Check if device supports particular algorithms separately */
    8350         [ +  + ]:         44 :         if (test_mixed_check_if_unsupported(tdata))
    8351                 :            :                 return TEST_SKIPPED;
    8352         [ +  - ]:          8 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    8353                 :            :                 return TEST_SKIPPED;
    8354                 :            : 
    8355         [ +  - ]:          8 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    8356                 :            :                 return TEST_SKIPPED;
    8357                 :            : 
    8358                 :          8 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    8359                 :            : 
    8360                 :          8 :         uint64_t feat_flags = dev_info.feature_flags;
    8361                 :            : 
    8362         [ +  - ]:          8 :         if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    8363                 :            :                 printf("Device doesn't support digest encrypted.\n");
    8364                 :          8 :                 return TEST_SKIPPED;
    8365                 :            :         }
    8366                 :            : 
    8367                 :            :         /* Create the session */
    8368         [ #  # ]:          0 :         if (verify)
    8369                 :          0 :                 retval = create_wireless_algo_cipher_auth_session(
    8370                 :          0 :                                 ts_params->valid_devs[0],
    8371                 :            :                                 RTE_CRYPTO_CIPHER_OP_DECRYPT,
    8372                 :            :                                 RTE_CRYPTO_AUTH_OP_VERIFY,
    8373                 :          0 :                                 tdata->auth_algo,
    8374                 :          0 :                                 tdata->cipher_algo,
    8375                 :          0 :                                 tdata->auth_key.data, tdata->auth_key.len,
    8376                 :          0 :                                 tdata->cipher_key.data, tdata->cipher_key.len,
    8377                 :          0 :                                 tdata->auth_iv.len, tdata->digest_enc.len,
    8378                 :          0 :                                 tdata->cipher_iv.len);
    8379                 :            :         else
    8380                 :          0 :                 retval = create_wireless_algo_auth_cipher_session(
    8381                 :          0 :                                 ts_params->valid_devs[0],
    8382                 :            :                                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    8383                 :            :                                 RTE_CRYPTO_AUTH_OP_GENERATE,
    8384                 :          0 :                                 tdata->auth_algo,
    8385                 :          0 :                                 tdata->cipher_algo,
    8386                 :          0 :                                 tdata->auth_key.data, tdata->auth_key.len,
    8387                 :          0 :                                 tdata->cipher_key.data, tdata->cipher_key.len,
    8388                 :          0 :                                 tdata->auth_iv.len, tdata->digest_enc.len,
    8389                 :          0 :                                 tdata->cipher_iv.len);
    8390         [ #  # ]:          0 :         if (retval != 0)
    8391                 :            :                 return retval;
    8392                 :            : 
    8393                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    8394         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    8395                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    8396                 :            : 
    8397                 :            :         /* clear mbuf payload */
    8398         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    8399         [ #  # ]:          0 :                 rte_pktmbuf_tailroom(ut_params->ibuf));
    8400         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE) {
    8401                 :            : 
    8402                 :          0 :                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
    8403                 :          0 :                                 rte_pktmbuf_tailroom(ut_params->obuf));
    8404                 :            :         }
    8405                 :            : 
    8406         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
    8407         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
    8408                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    8409                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    8410                 :            : 
    8411         [ #  # ]:          0 :         if (verify) {
    8412                 :          0 :                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    8413                 :            :                                 ciphertext_pad_len);
    8414                 :          0 :                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    8415                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    8416                 :            :                                 ciphertext_len);
    8417                 :            :         } else {
    8418                 :            :                 /* make sure enough space to cover partial digest verify case */
    8419                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    8420                 :            :                                 ciphertext_pad_len);
    8421                 :          0 :                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    8422                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    8423                 :            :         }
    8424                 :            : 
    8425         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    8426                 :          0 :                 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
    8427                 :            : 
    8428                 :            :         /* Create the operation */
    8429                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    8430                 :          0 :                         tdata->digest_enc.data, tdata->digest_enc.len,
    8431                 :          0 :                         tdata->cipher_iv.data, tdata->cipher_iv.len,
    8432                 :          0 :                         tdata->auth_iv.data, tdata->auth_iv.len,
    8433                 :          0 :                         (tdata->digest_enc.offset == 0 ?
    8434                 :            :                                 plaintext_pad_len
    8435                 :            :                                 : tdata->digest_enc.offset),
    8436                 :          0 :                         tdata->validCipherLen.len_bits,
    8437                 :          0 :                         tdata->cipher.offset_bits,
    8438                 :          0 :                         tdata->validAuthLen.len_bits,
    8439         [ #  # ]:          0 :                         tdata->auth.offset_bits,
    8440                 :            :                         op_mode, 0, verify);
    8441                 :            : 
    8442         [ #  # ]:          0 :         if (retval < 0)
    8443                 :            :                 return retval;
    8444                 :            : 
    8445                 :          0 :         op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
    8446                 :            : 
    8447                 :            :         /* Check if the op failed because the device doesn't */
    8448                 :            :         /* support this particular combination of algorithms */
    8449   [ #  #  #  # ]:          0 :         if (op == NULL && ut_params->op->status ==
    8450                 :            :                         RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
    8451                 :            :                 printf("Device doesn't support this mixed combination. "
    8452                 :            :                                 "Test Skipped.\n");
    8453                 :          0 :                 return TEST_SKIPPED;
    8454                 :            :         }
    8455                 :          0 :         ut_params->op = op;
    8456                 :            : 
    8457         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    8458                 :            : 
    8459                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    8460         [ #  # ]:          0 :                         ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    8461                 :            : 
    8462         [ #  # ]:          0 :         if (verify) {
    8463         [ #  # ]:          0 :                 if (ut_params->obuf)
    8464                 :          0 :                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
    8465                 :            :                                                         uint8_t *);
    8466                 :            :                 else
    8467                 :          0 :                         plaintext = ciphertext +
    8468                 :          0 :                                         (tdata->cipher.offset_bits >> 3);
    8469                 :            : 
    8470                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    8471                 :          0 :                                 tdata->plaintext.len_bits >> 3);
    8472                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    8473                 :          0 :                                 tdata->plaintext.data,
    8474                 :          0 :                                 tdata->plaintext.len_bits >> 3);
    8475                 :            :         } else {
    8476         [ #  # ]:          0 :                 if (ut_params->obuf)
    8477                 :          0 :                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
    8478                 :            :                                         uint8_t *);
    8479                 :            :                 else
    8480                 :            :                         ciphertext = plaintext;
    8481                 :            : 
    8482                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    8483                 :            :                                 ciphertext_len);
    8484                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    8485                 :          0 :                                 tdata->ciphertext.data,
    8486                 :          0 :                                 tdata->ciphertext.len_bits >> 3);
    8487                 :            : 
    8488         [ #  # ]:          0 :                 if (tdata->digest_enc.offset == 0)
    8489                 :            :                         digest_offset = plaintext_pad_len;
    8490                 :            :                 else
    8491                 :            :                         digest_offset = tdata->digest_enc.offset;
    8492                 :            : 
    8493                 :          0 :                 ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    8494                 :            :                                             uint8_t *, digest_offset);
    8495                 :            : 
    8496                 :          0 :                 debug_hexdump(stdout, "digest:", ut_params->digest,
    8497                 :          0 :                                 tdata->digest_enc.len);
    8498                 :          0 :                 debug_hexdump(stdout, "digest expected:",
    8499                 :            :                                 tdata->digest_enc.data,
    8500                 :          0 :                                 tdata->digest_enc.len);
    8501                 :            :         }
    8502                 :            : 
    8503         [ #  # ]:          0 :         if (!verify) {
    8504         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    8505                 :            :                                 ut_params->digest,
    8506                 :            :                                 tdata->digest_enc.data,
    8507                 :            :                                 tdata->digest_enc.len,
    8508                 :            :                                 "Generated auth tag not as expected");
    8509                 :            :         }
    8510                 :            : 
    8511         [ #  # ]:          0 :         if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
    8512         [ #  # ]:          0 :                 if (verify) {
    8513   [ #  #  #  #  :          0 :                         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    8514                 :            :                                         plaintext,
    8515                 :            :                                         tdata->plaintext.data,
    8516                 :            :                                         tdata->plaintext.len_bits >> 3,
    8517                 :            :                                         "Plaintext data not as expected");
    8518                 :            :                 } else {
    8519   [ #  #  #  #  :          0 :                         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    8520                 :            :                                         ciphertext,
    8521                 :            :                                         tdata->ciphertext.data,
    8522                 :            :                                         tdata->validDataLen.len_bits,
    8523                 :            :                                         "Ciphertext data not as expected");
    8524                 :            :                 }
    8525                 :            :         }
    8526                 :            : 
    8527         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    8528                 :            :                         "crypto op processing failed");
    8529                 :            : 
    8530                 :            :         return 0;
    8531                 :            : }
    8532                 :            : 
    8533                 :            : static int
    8534                 :          6 : test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
    8535                 :            :         uint8_t op_mode, uint8_t verify)
    8536                 :            : {
    8537                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    8538                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    8539                 :            : 
    8540                 :            :         int retval;
    8541                 :            : 
    8542                 :            :         const uint8_t *plaintext = NULL;
    8543                 :            :         const uint8_t *ciphertext = NULL;
    8544                 :            :         const uint8_t *digest = NULL;
    8545                 :            :         unsigned int plaintext_pad_len;
    8546                 :            :         unsigned int plaintext_len;
    8547                 :            :         unsigned int ciphertext_pad_len;
    8548                 :            :         unsigned int ciphertext_len;
    8549                 :            :         uint8_t buffer[10000];
    8550                 :            :         uint8_t digest_buffer[10000];
    8551                 :            : 
    8552                 :            :         struct rte_cryptodev_info dev_info;
    8553                 :            :         struct rte_crypto_op *op;
    8554                 :            : 
    8555                 :            :         /* Check if device supports particular algorithms */
    8556         [ +  + ]:          6 :         if (test_mixed_check_if_unsupported(tdata))
    8557                 :            :                 return TEST_SKIPPED;
    8558         [ +  - ]:          4 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    8559                 :            :                 return TEST_SKIPPED;
    8560                 :            : 
    8561                 :          4 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    8562                 :            : 
    8563                 :          4 :         uint64_t feat_flags = dev_info.feature_flags;
    8564                 :            : 
    8565         [ +  + ]:          4 :         if (op_mode == IN_PLACE) {
    8566         [ -  + ]:          2 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    8567                 :            :                         printf("Device doesn't support in-place scatter-gather "
    8568                 :            :                                         "in both input and output mbufs.\n");
    8569                 :          0 :                         return TEST_SKIPPED;
    8570                 :            :                 }
    8571                 :            :         } else {
    8572         [ +  - ]:          2 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
    8573                 :            :                         printf("Device doesn't support out-of-place scatter-gather "
    8574                 :            :                                         "in both input and output mbufs.\n");
    8575                 :          2 :                         return TEST_SKIPPED;
    8576                 :            :                 }
    8577         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    8578                 :            :                         printf("Device doesn't support digest encrypted.\n");
    8579                 :          0 :                         return TEST_SKIPPED;
    8580                 :            :                 }
    8581                 :            :         }
    8582                 :            : 
    8583         [ +  - ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    8584                 :            :                 return TEST_SKIPPED;
    8585                 :            : 
    8586                 :            :         /* Create the session */
    8587         [ +  + ]:          2 :         if (verify)
    8588                 :          1 :                 retval = create_wireless_algo_cipher_auth_session(
    8589                 :          1 :                                 ts_params->valid_devs[0],
    8590                 :            :                                 RTE_CRYPTO_CIPHER_OP_DECRYPT,
    8591                 :            :                                 RTE_CRYPTO_AUTH_OP_VERIFY,
    8592                 :          1 :                                 tdata->auth_algo,
    8593                 :          1 :                                 tdata->cipher_algo,
    8594                 :          1 :                                 tdata->auth_key.data, tdata->auth_key.len,
    8595                 :          1 :                                 tdata->cipher_key.data, tdata->cipher_key.len,
    8596                 :          1 :                                 tdata->auth_iv.len, tdata->digest_enc.len,
    8597                 :          1 :                                 tdata->cipher_iv.len);
    8598                 :            :         else
    8599                 :          1 :                 retval = create_wireless_algo_auth_cipher_session(
    8600                 :          1 :                                 ts_params->valid_devs[0],
    8601                 :            :                                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    8602                 :            :                                 RTE_CRYPTO_AUTH_OP_GENERATE,
    8603                 :          1 :                                 tdata->auth_algo,
    8604                 :          1 :                                 tdata->cipher_algo,
    8605                 :          1 :                                 tdata->auth_key.data, tdata->auth_key.len,
    8606                 :          1 :                                 tdata->cipher_key.data, tdata->cipher_key.len,
    8607                 :          1 :                                 tdata->auth_iv.len, tdata->digest_enc.len,
    8608                 :          1 :                                 tdata->cipher_iv.len);
    8609         [ +  - ]:          2 :         if (retval != 0)
    8610                 :            :                 return retval;
    8611                 :            : 
    8612         [ -  + ]:          2 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
    8613         [ -  + ]:          2 :         plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
    8614                 :          2 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    8615                 :          2 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    8616                 :            : 
    8617                 :          2 :         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    8618                 :            :                         ciphertext_pad_len, 15, 0);
    8619         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    8620                 :            :                         "Failed to allocate input buffer in mempool");
    8621                 :            : 
    8622         [ -  + ]:          2 :         if (op_mode == OUT_OF_PLACE) {
    8623                 :          0 :                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
    8624                 :            :                                 plaintext_pad_len, 15, 0);
    8625         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
    8626                 :            :                                 "Failed to allocate output buffer in mempool");
    8627                 :            :         }
    8628                 :            : 
    8629         [ +  + ]:          2 :         if (verify) {
    8630                 :          1 :                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
    8631                 :          1 :                         tdata->ciphertext.data);
    8632         [ -  + ]:          1 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    8633                 :            :                                         ciphertext_len, buffer);
    8634                 :          1 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    8635                 :            :                         ciphertext_len);
    8636                 :            :         } else {
    8637                 :          1 :                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
    8638                 :          1 :                         tdata->plaintext.data);
    8639         [ -  + ]:          1 :                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    8640                 :            :                                         plaintext_len, buffer);
    8641                 :          1 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    8642                 :            :                         plaintext_len);
    8643                 :            :         }
    8644                 :            :         memset(buffer, 0, sizeof(buffer));
    8645                 :            : 
    8646                 :            :         /* Create the operation */
    8647                 :          4 :         retval = create_wireless_algo_auth_cipher_operation(
    8648                 :          2 :                         tdata->digest_enc.data, tdata->digest_enc.len,
    8649                 :          2 :                         tdata->cipher_iv.data, tdata->cipher_iv.len,
    8650                 :          2 :                         tdata->auth_iv.data, tdata->auth_iv.len,
    8651                 :          2 :                         (tdata->digest_enc.offset == 0 ?
    8652                 :            :                                 plaintext_pad_len
    8653                 :            :                                 : tdata->digest_enc.offset),
    8654                 :          2 :                         tdata->validCipherLen.len_bits,
    8655                 :          2 :                         tdata->cipher.offset_bits,
    8656                 :          2 :                         tdata->validAuthLen.len_bits,
    8657         [ +  - ]:          2 :                         tdata->auth.offset_bits,
    8658                 :            :                         op_mode, 1, verify);
    8659                 :            : 
    8660         [ +  - ]:          2 :         if (retval < 0)
    8661                 :            :                 return retval;
    8662                 :            : 
    8663                 :          2 :         op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
    8664                 :            : 
    8665                 :            :         /* Check if the op failed because the device doesn't */
    8666                 :            :         /* support this particular combination of algorithms */
    8667   [ -  +  -  - ]:          2 :         if (op == NULL && ut_params->op->status ==
    8668                 :            :                         RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
    8669                 :            :                 printf("Device doesn't support this mixed combination. "
    8670                 :            :                                 "Test Skipped.\n");
    8671                 :          0 :                 return TEST_SKIPPED;
    8672                 :            :         }
    8673                 :          2 :         ut_params->op = op;
    8674                 :            : 
    8675         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    8676                 :            : 
    8677                 :          2 :         ut_params->obuf = (op_mode == IN_PLACE ?
    8678         [ +  - ]:          2 :                         ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    8679                 :            : 
    8680         [ +  + ]:          2 :         if (verify) {
    8681         [ +  - ]:          1 :                 if (ut_params->obuf)
    8682                 :            :                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
    8683                 :            :                                         plaintext_len, buffer);
    8684                 :            :                 else
    8685         [ #  # ]:          0 :                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    8686                 :            :                                         plaintext_len, buffer);
    8687                 :            : 
    8688                 :          1 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    8689                 :          1 :                                 (tdata->plaintext.len_bits >> 3) -
    8690                 :          1 :                                 tdata->digest_enc.len);
    8691                 :          1 :                 debug_hexdump(stdout, "plaintext expected:",
    8692                 :          1 :                                 tdata->plaintext.data,
    8693                 :          1 :                                 (tdata->plaintext.len_bits >> 3) -
    8694                 :          1 :                                 tdata->digest_enc.len);
    8695                 :            :         } else {
    8696         [ +  - ]:          1 :                 if (ut_params->obuf)
    8697                 :            :                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    8698                 :            :                                         ciphertext_len, buffer);
    8699                 :            :                 else
    8700         [ #  # ]:          0 :                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    8701                 :            :                                         ciphertext_len, buffer);
    8702                 :            : 
    8703                 :          1 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    8704                 :            :                         ciphertext_len);
    8705                 :          1 :                 debug_hexdump(stdout, "ciphertext expected:",
    8706                 :          1 :                         tdata->ciphertext.data,
    8707                 :          1 :                         tdata->ciphertext.len_bits >> 3);
    8708                 :            : 
    8709         [ +  - ]:          1 :                 if (ut_params->obuf)
    8710                 :          1 :                         digest = rte_pktmbuf_read(ut_params->obuf,
    8711                 :          1 :                                         (tdata->digest_enc.offset == 0 ?
    8712                 :            :                                                 plaintext_pad_len :
    8713                 :            :                                                 tdata->digest_enc.offset),
    8714         [ +  - ]:          1 :                                         tdata->digest_enc.len, digest_buffer);
    8715                 :            :                 else
    8716         [ #  # ]:          0 :                         digest = rte_pktmbuf_read(ut_params->ibuf,
    8717                 :          0 :                                         (tdata->digest_enc.offset == 0 ?
    8718                 :            :                                                 plaintext_pad_len :
    8719                 :            :                                                 tdata->digest_enc.offset),
    8720         [ #  # ]:          0 :                                         tdata->digest_enc.len, digest_buffer);
    8721                 :            : 
    8722                 :          1 :                 debug_hexdump(stdout, "digest:", digest,
    8723                 :          1 :                                 tdata->digest_enc.len);
    8724                 :          1 :                 debug_hexdump(stdout, "digest expected:",
    8725                 :          1 :                                 tdata->digest_enc.data, tdata->digest_enc.len);
    8726                 :            :         }
    8727                 :            : 
    8728         [ +  + ]:          2 :         if (!verify) {
    8729         [ -  + ]:          1 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    8730                 :            :                                 digest,
    8731                 :            :                                 tdata->digest_enc.data,
    8732                 :            :                                 tdata->digest_enc.len,
    8733                 :            :                                 "Generated auth tag not as expected");
    8734                 :            :         }
    8735                 :            : 
    8736         [ +  - ]:          2 :         if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
    8737         [ +  + ]:          2 :                 if (verify) {
    8738   [ -  +  +  -  :          1 :                         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   -  + ]
    8739                 :            :                                         plaintext,
    8740                 :            :                                         tdata->plaintext.data,
    8741                 :            :                                         tdata->plaintext.len_bits >> 3,
    8742                 :            :                                         "Plaintext data not as expected");
    8743                 :            :                 } else {
    8744   [ -  +  -  +  :          1 :                         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   -  - ]
    8745                 :            :                                         ciphertext,
    8746                 :            :                                         tdata->ciphertext.data,
    8747                 :            :                                         tdata->validDataLen.len_bits,
    8748                 :            :                                         "Ciphertext data not as expected");
    8749                 :            :                 }
    8750                 :            :         }
    8751                 :            : 
    8752         [ -  + ]:          2 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    8753                 :            :                         "crypto op processing failed");
    8754                 :            : 
    8755                 :            :         return 0;
    8756                 :            : }
    8757                 :            : 
    8758                 :            : /** AUTH AES CMAC + CIPHER AES CTR */
    8759                 :            : 
    8760                 :            : static int
    8761                 :          1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
    8762                 :            : {
    8763                 :          1 :         return test_mixed_auth_cipher(
    8764                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
    8765                 :            : }
    8766                 :            : 
    8767                 :            : static int
    8768                 :          1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
    8769                 :            : {
    8770                 :          1 :         return test_mixed_auth_cipher(
    8771                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
    8772                 :            : }
    8773                 :            : 
    8774                 :            : static int
    8775                 :          1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
    8776                 :            : {
    8777                 :          1 :         return test_mixed_auth_cipher_sgl(
    8778                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
    8779                 :            : }
    8780                 :            : 
    8781                 :            : static int
    8782                 :          1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
    8783                 :            : {
    8784                 :          1 :         return test_mixed_auth_cipher_sgl(
    8785                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
    8786                 :            : }
    8787                 :            : 
    8788                 :            : static int
    8789                 :          1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
    8790                 :            : {
    8791                 :          1 :         return test_mixed_auth_cipher(
    8792                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
    8793                 :            : }
    8794                 :            : 
    8795                 :            : static int
    8796                 :          1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
    8797                 :            : {
    8798                 :          1 :         return test_mixed_auth_cipher(
    8799                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
    8800                 :            : }
    8801                 :            : 
    8802                 :            : static int
    8803                 :          1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
    8804                 :            : {
    8805                 :          1 :         return test_mixed_auth_cipher(
    8806                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
    8807                 :            : }
    8808                 :            : 
    8809                 :            : static int
    8810                 :          1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
    8811                 :            : {
    8812                 :          1 :         return test_mixed_auth_cipher(
    8813                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
    8814                 :            : }
    8815                 :            : 
    8816                 :            : static int
    8817                 :          1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
    8818                 :            : {
    8819                 :          1 :         return test_mixed_auth_cipher(
    8820                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
    8821                 :            : }
    8822                 :            : 
    8823                 :            : static int
    8824                 :          1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
    8825                 :            : {
    8826                 :          1 :         return test_mixed_auth_cipher_sgl(
    8827                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
    8828                 :            : }
    8829                 :            : 
    8830                 :            : static int
    8831                 :          1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
    8832                 :            : {
    8833                 :          1 :         return test_mixed_auth_cipher_sgl(
    8834                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
    8835                 :            : }
    8836                 :            : 
    8837                 :            : static int
    8838                 :          1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
    8839                 :            : {
    8840                 :          1 :         return test_mixed_auth_cipher(
    8841                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
    8842                 :            : }
    8843                 :            : 
    8844                 :            : /** MIXED AUTH + CIPHER */
    8845                 :            : 
    8846                 :            : static int
    8847                 :          1 : test_auth_zuc_cipher_snow_test_case_1(void)
    8848                 :            : {
    8849                 :          1 :         return test_mixed_auth_cipher(
    8850                 :            :                 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
    8851                 :            : }
    8852                 :            : 
    8853                 :            : static int
    8854                 :          1 : test_verify_auth_zuc_cipher_snow_test_case_1(void)
    8855                 :            : {
    8856                 :          1 :         return test_mixed_auth_cipher(
    8857                 :            :                 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
    8858                 :            : }
    8859                 :            : 
    8860                 :            : static int
    8861                 :          1 : test_auth_zuc_cipher_snow_test_case_1_inplace(void)
    8862                 :            : {
    8863                 :          1 :         return test_mixed_auth_cipher(
    8864                 :            :                 &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
    8865                 :            : }
    8866                 :            : 
    8867                 :            : static int
    8868                 :          1 : test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
    8869                 :            : {
    8870                 :          1 :         return test_mixed_auth_cipher(
    8871                 :            :                 &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
    8872                 :            : }
    8873                 :            : 
    8874                 :            : 
    8875                 :            : static int
    8876                 :          1 : test_auth_aes_cmac_cipher_snow_test_case_1(void)
    8877                 :            : {
    8878                 :          1 :         return test_mixed_auth_cipher(
    8879                 :            :                 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
    8880                 :            : }
    8881                 :            : 
    8882                 :            : static int
    8883                 :          1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
    8884                 :            : {
    8885                 :          1 :         return test_mixed_auth_cipher(
    8886                 :            :                 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
    8887                 :            : }
    8888                 :            : 
    8889                 :            : static int
    8890                 :          1 : test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
    8891                 :            : {
    8892                 :          1 :         return test_mixed_auth_cipher(
    8893                 :            :                 &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
    8894                 :            : }
    8895                 :            : 
    8896                 :            : static int
    8897                 :          1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
    8898                 :            : {
    8899                 :          1 :         return test_mixed_auth_cipher(
    8900                 :            :                 &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
    8901                 :            : }
    8902                 :            : 
    8903                 :            : static int
    8904                 :          1 : test_auth_zuc_cipher_aes_ctr_test_case_1(void)
    8905                 :            : {
    8906                 :          1 :         return test_mixed_auth_cipher(
    8907                 :            :                 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
    8908                 :            : }
    8909                 :            : 
    8910                 :            : static int
    8911                 :          1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
    8912                 :            : {
    8913                 :          1 :         return test_mixed_auth_cipher(
    8914                 :            :                 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
    8915                 :            : }
    8916                 :            : 
    8917                 :            : static int
    8918                 :          1 : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
    8919                 :            : {
    8920                 :          1 :         return test_mixed_auth_cipher(
    8921                 :            :                 &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
    8922                 :            : }
    8923                 :            : 
    8924                 :            : static int
    8925                 :          1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
    8926                 :            : {
    8927                 :          1 :         return test_mixed_auth_cipher(
    8928                 :            :                 &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
    8929                 :            : }
    8930                 :            : 
    8931                 :            : static int
    8932                 :          1 : test_auth_snow_cipher_aes_ctr_test_case_1(void)
    8933                 :            : {
    8934                 :          1 :         return test_mixed_auth_cipher(
    8935                 :            :                 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
    8936                 :            : }
    8937                 :            : 
    8938                 :            : static int
    8939                 :          1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
    8940                 :            : {
    8941                 :          1 :         return test_mixed_auth_cipher(
    8942                 :            :                 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
    8943                 :            : }
    8944                 :            : 
    8945                 :            : static int
    8946                 :          1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
    8947                 :            : {
    8948                 :          1 :         return test_mixed_auth_cipher_sgl(
    8949                 :            :                 &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
    8950                 :            : }
    8951                 :            : 
    8952                 :            : static int
    8953                 :          1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
    8954                 :            : {
    8955                 :          1 :         return test_mixed_auth_cipher(
    8956                 :            :                 &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
    8957                 :            : }
    8958                 :            : 
    8959                 :            : static int
    8960                 :          1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
    8961                 :            : {
    8962                 :          1 :         return test_mixed_auth_cipher_sgl(
    8963                 :            :                 &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
    8964                 :            : }
    8965                 :            : 
    8966                 :            : static int
    8967                 :          1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
    8968                 :            : {
    8969                 :          1 :         return test_mixed_auth_cipher(
    8970                 :            :                 &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
    8971                 :            : }
    8972                 :            : 
    8973                 :            : static int
    8974                 :          1 : test_auth_snow_cipher_zuc_test_case_1(void)
    8975                 :            : {
    8976                 :          1 :         return test_mixed_auth_cipher(
    8977                 :            :                 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
    8978                 :            : }
    8979                 :            : 
    8980                 :            : static int
    8981                 :          1 : test_verify_auth_snow_cipher_zuc_test_case_1(void)
    8982                 :            : {
    8983                 :          1 :         return test_mixed_auth_cipher(
    8984                 :            :                 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
    8985                 :            : }
    8986                 :            : 
    8987                 :            : static int
    8988                 :          1 : test_auth_snow_cipher_zuc_test_case_1_inplace(void)
    8989                 :            : {
    8990                 :          1 :         return test_mixed_auth_cipher(
    8991                 :            :                 &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
    8992                 :            : }
    8993                 :            : 
    8994                 :            : static int
    8995                 :          1 : test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
    8996                 :            : {
    8997                 :          1 :         return test_mixed_auth_cipher(
    8998                 :            :                 &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
    8999                 :            : }
    9000                 :            : 
    9001                 :            : static int
    9002                 :          1 : test_auth_aes_cmac_cipher_zuc_test_case_1(void)
    9003                 :            : {
    9004                 :          1 :         return test_mixed_auth_cipher(
    9005                 :            :                 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
    9006                 :            : }
    9007                 :            : 
    9008                 :            : static int
    9009                 :          1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
    9010                 :            : {
    9011                 :          1 :         return test_mixed_auth_cipher(
    9012                 :            :                 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
    9013                 :            : }
    9014                 :            : static int
    9015                 :          1 : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
    9016                 :            : {
    9017                 :          1 :         return test_mixed_auth_cipher(
    9018                 :            :                 &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
    9019                 :            : }
    9020                 :            : 
    9021                 :            : static int
    9022                 :          1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
    9023                 :            : {
    9024                 :          1 :         return test_mixed_auth_cipher(
    9025                 :            :                 &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
    9026                 :            : }
    9027                 :            : 
    9028                 :            : static int
    9029                 :          1 : test_auth_null_cipher_snow_test_case_1(void)
    9030                 :            : {
    9031                 :          1 :         return test_mixed_auth_cipher(
    9032                 :            :                 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
    9033                 :            : }
    9034                 :            : 
    9035                 :            : static int
    9036                 :          1 : test_verify_auth_null_cipher_snow_test_case_1(void)
    9037                 :            : {
    9038                 :          1 :         return test_mixed_auth_cipher(
    9039                 :            :                 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
    9040                 :            : }
    9041                 :            : 
    9042                 :            : static int
    9043                 :          1 : test_auth_null_cipher_zuc_test_case_1(void)
    9044                 :            : {
    9045                 :          1 :         return test_mixed_auth_cipher(
    9046                 :            :                 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
    9047                 :            : }
    9048                 :            : 
    9049                 :            : static int
    9050                 :          1 : test_verify_auth_null_cipher_zuc_test_case_1(void)
    9051                 :            : {
    9052                 :          1 :         return test_mixed_auth_cipher(
    9053                 :            :                 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
    9054                 :            : }
    9055                 :            : 
    9056                 :            : static int
    9057                 :          1 : test_auth_snow_cipher_null_test_case_1(void)
    9058                 :            : {
    9059                 :          1 :         return test_mixed_auth_cipher(
    9060                 :            :                 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
    9061                 :            : }
    9062                 :            : 
    9063                 :            : static int
    9064                 :          1 : test_verify_auth_snow_cipher_null_test_case_1(void)
    9065                 :            : {
    9066                 :          1 :         return test_mixed_auth_cipher(
    9067                 :            :                 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
    9068                 :            : }
    9069                 :            : 
    9070                 :            : static int
    9071                 :          1 : test_auth_zuc_cipher_null_test_case_1(void)
    9072                 :            : {
    9073                 :          1 :         return test_mixed_auth_cipher(
    9074                 :            :                 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
    9075                 :            : }
    9076                 :            : 
    9077                 :            : static int
    9078                 :          1 : test_verify_auth_zuc_cipher_null_test_case_1(void)
    9079                 :            : {
    9080                 :          1 :         return test_mixed_auth_cipher(
    9081                 :            :                 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
    9082                 :            : }
    9083                 :            : 
    9084                 :            : static int
    9085                 :          1 : test_auth_null_cipher_aes_ctr_test_case_1(void)
    9086                 :            : {
    9087                 :          1 :         return test_mixed_auth_cipher(
    9088                 :            :                 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
    9089                 :            : }
    9090                 :            : 
    9091                 :            : static int
    9092                 :          1 : test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
    9093                 :            : {
    9094                 :          1 :         return test_mixed_auth_cipher(
    9095                 :            :                 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
    9096                 :            : }
    9097                 :            : 
    9098                 :            : static int
    9099                 :          1 : test_auth_aes_cmac_cipher_null_test_case_1(void)
    9100                 :            : {
    9101                 :          1 :         return test_mixed_auth_cipher(
    9102                 :            :                 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
    9103                 :            : }
    9104                 :            : 
    9105                 :            : static int
    9106                 :          1 : test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
    9107                 :            : {
    9108                 :          1 :         return test_mixed_auth_cipher(
    9109                 :            :                 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
    9110                 :            : }
    9111                 :            : 
    9112                 :            : /* ***** AEAD algorithm Tests ***** */
    9113                 :            : 
    9114                 :            : static int
    9115                 :         87 : create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
    9116                 :            :                 enum rte_crypto_aead_operation op,
    9117                 :            :                 const uint8_t *key, const uint8_t key_len,
    9118                 :            :                 const uint16_t aad_len, const uint8_t auth_len,
    9119                 :            :                 uint8_t iv_len)
    9120                 :            : {
    9121                 :         87 :         uint8_t *aead_key = alloca(key_len);
    9122                 :            : 
    9123                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    9124                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    9125                 :            : 
    9126                 :            :         memcpy(aead_key, key, key_len);
    9127                 :            : 
    9128                 :            :         /* Setup AEAD Parameters */
    9129                 :         87 :         ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
    9130                 :         87 :         ut_params->aead_xform.next = NULL;
    9131                 :         87 :         ut_params->aead_xform.aead.algo = algo;
    9132                 :         87 :         ut_params->aead_xform.aead.op = op;
    9133                 :         87 :         ut_params->aead_xform.aead.key.data = aead_key;
    9134                 :         87 :         ut_params->aead_xform.aead.key.length = key_len;
    9135                 :         87 :         ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
    9136                 :         87 :         ut_params->aead_xform.aead.iv.length = iv_len;
    9137                 :         87 :         ut_params->aead_xform.aead.digest_length = auth_len;
    9138                 :         87 :         ut_params->aead_xform.aead.aad_length = aad_len;
    9139                 :            : 
    9140                 :         87 :         debug_hexdump(stdout, "key:", key, key_len);
    9141                 :            : 
    9142                 :            :         /* Create Crypto session*/
    9143                 :         87 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    9144                 :            :                         &ut_params->aead_xform, ts_params->session_mpool);
    9145   [ -  +  -  - ]:         87 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
    9146                 :            :                 return TEST_SKIPPED;
    9147         [ -  + ]:         87 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    9148                 :            :         return 0;
    9149                 :            : }
    9150                 :            : 
    9151                 :            : static int
    9152                 :          2 : create_aead_xform(struct rte_crypto_op *op,
    9153                 :            :                 enum rte_crypto_aead_algorithm algo,
    9154                 :            :                 enum rte_crypto_aead_operation aead_op,
    9155                 :            :                 uint8_t *key, const uint8_t key_len,
    9156                 :            :                 const uint8_t aad_len, const uint8_t auth_len,
    9157                 :            :                 uint8_t iv_len)
    9158                 :            : {
    9159         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
    9160                 :            :                         "failed to allocate space for crypto transform");
    9161                 :            : 
    9162                 :            :         struct rte_crypto_sym_op *sym_op = op->sym;
    9163                 :            : 
    9164                 :            :         /* Setup AEAD Parameters */
    9165                 :          2 :         sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
    9166                 :          2 :         sym_op->xform->next = NULL;
    9167                 :          2 :         sym_op->xform->aead.algo = algo;
    9168                 :          2 :         sym_op->xform->aead.op = aead_op;
    9169                 :          2 :         sym_op->xform->aead.key.data = key;
    9170                 :          2 :         sym_op->xform->aead.key.length = key_len;
    9171                 :          2 :         sym_op->xform->aead.iv.offset = IV_OFFSET;
    9172                 :          2 :         sym_op->xform->aead.iv.length = iv_len;
    9173                 :          2 :         sym_op->xform->aead.digest_length = auth_len;
    9174                 :          2 :         sym_op->xform->aead.aad_length = aad_len;
    9175                 :            : 
    9176                 :          2 :         debug_hexdump(stdout, "key:", key, key_len);
    9177                 :            : 
    9178                 :            :         return 0;
    9179                 :            : }
    9180                 :            : 
    9181                 :            : static int
    9182                 :         88 : create_aead_operation(enum rte_crypto_aead_operation op,
    9183                 :            :                 const struct aead_test_data *tdata)
    9184                 :            : {
    9185                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    9186                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    9187                 :            : 
    9188                 :            :         uint8_t *plaintext, *ciphertext;
    9189                 :            :         unsigned int aad_pad_len, plaintext_pad_len;
    9190                 :            : 
    9191                 :            :         /* Generate Crypto op data structure */
    9192                 :         88 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    9193                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    9194         [ -  + ]:         88 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    9195                 :            :                         "Failed to allocate symmetric crypto operation struct");
    9196                 :            : 
    9197                 :            :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    9198                 :            : 
    9199                 :            :         /* Append aad data */
    9200         [ +  + ]:         88 :         if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
    9201                 :         20 :                 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
    9202                 :         20 :                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    9203                 :            :                                 aad_pad_len);
    9204         [ -  + ]:         20 :                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
    9205                 :            :                                 "no room to append aad");
    9206                 :            : 
    9207                 :         20 :                 sym_op->aead.aad.phys_addr =
    9208                 :         20 :                                 rte_pktmbuf_iova(ut_params->ibuf);
    9209                 :            :                 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
    9210                 :         20 :                 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
    9211                 :         20 :                 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
    9212                 :         20 :                         tdata->aad.len);
    9213                 :            : 
    9214                 :            :                 /* Append IV at the end of the crypto operation*/
    9215                 :         20 :                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
    9216                 :            :                                 uint8_t *, IV_OFFSET);
    9217                 :            : 
    9218                 :            :                 /* Copy IV 1 byte after the IV pointer, according to the API */
    9219         [ -  + ]:         20 :                 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
    9220                 :         20 :                 debug_hexdump(stdout, "iv:", iv_ptr + 1,
    9221                 :         20 :                         tdata->iv.len);
    9222                 :            :         } else {
    9223                 :         68 :                 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
    9224                 :         68 :                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    9225                 :            :                                 aad_pad_len);
    9226         [ -  + ]:         68 :                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
    9227                 :            :                                 "no room to append aad");
    9228                 :            : 
    9229                 :         68 :                 sym_op->aead.aad.phys_addr =
    9230                 :         68 :                                 rte_pktmbuf_iova(ut_params->ibuf);
    9231                 :         68 :                 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
    9232                 :         68 :                 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
    9233                 :         68 :                         tdata->aad.len);
    9234                 :            : 
    9235                 :            :                 /* Append IV at the end of the crypto operation*/
    9236                 :         68 :                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
    9237                 :            :                                 uint8_t *, IV_OFFSET);
    9238                 :            : 
    9239         [ -  + ]:         68 :                 if (tdata->iv.len == 0) {
    9240         [ #  # ]:          0 :                         rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
    9241                 :          0 :                         debug_hexdump(stdout, "iv:", iv_ptr,
    9242                 :            :                                 AES_GCM_J0_LENGTH);
    9243                 :            :                 } else {
    9244         [ -  + ]:         68 :                         rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
    9245                 :         68 :                         debug_hexdump(stdout, "iv:", iv_ptr,
    9246                 :         68 :                                 tdata->iv.len);
    9247                 :            :                 }
    9248                 :            :         }
    9249                 :            : 
    9250                 :            :         /* Append plaintext/ciphertext */
    9251         [ +  + ]:         88 :         if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
    9252                 :         44 :                 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
    9253                 :         44 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    9254                 :            :                                 plaintext_pad_len);
    9255         [ -  + ]:         44 :                 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
    9256                 :            : 
    9257                 :         44 :                 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
    9258                 :         44 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    9259                 :         44 :                                 tdata->plaintext.len);
    9260                 :            : 
    9261         [ +  + ]:         44 :                 if (ut_params->obuf) {
    9262                 :            :                         ciphertext = (uint8_t *)rte_pktmbuf_append(
    9263                 :            :                                         ut_params->obuf,
    9264                 :          1 :                                         plaintext_pad_len + aad_pad_len);
    9265         [ -  + ]:          1 :                         TEST_ASSERT_NOT_NULL(ciphertext,
    9266                 :            :                                         "no room to append ciphertext");
    9267                 :            : 
    9268                 :          1 :                         memset(ciphertext + aad_pad_len, 0,
    9269                 :          1 :                                         tdata->ciphertext.len);
    9270                 :            :                 }
    9271                 :            :         } else {
    9272                 :         44 :                 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
    9273                 :         44 :                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    9274                 :            :                                 plaintext_pad_len);
    9275         [ -  + ]:         44 :                 TEST_ASSERT_NOT_NULL(ciphertext,
    9276                 :            :                                 "no room to append ciphertext");
    9277                 :            : 
    9278                 :         44 :                 memcpy(ciphertext, tdata->ciphertext.data,
    9279                 :         44 :                                 tdata->ciphertext.len);
    9280                 :         44 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    9281                 :         44 :                                 tdata->ciphertext.len);
    9282                 :            : 
    9283         [ +  + ]:         44 :                 if (ut_params->obuf) {
    9284                 :            :                         plaintext = (uint8_t *)rte_pktmbuf_append(
    9285                 :            :                                         ut_params->obuf,
    9286                 :          1 :                                         plaintext_pad_len + aad_pad_len);
    9287         [ -  + ]:          1 :                         TEST_ASSERT_NOT_NULL(plaintext,
    9288                 :            :                                         "no room to append plaintext");
    9289                 :            : 
    9290                 :          1 :                         memset(plaintext + aad_pad_len, 0,
    9291                 :          1 :                                         tdata->plaintext.len);
    9292                 :            :                 }
    9293                 :            :         }
    9294                 :            : 
    9295                 :            :         /* Append digest data */
    9296         [ +  + ]:         88 :         if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
    9297                 :         43 :                 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
    9298                 :         44 :                                 ut_params->obuf ? ut_params->obuf :
    9299                 :            :                                                 ut_params->ibuf,
    9300         [ +  + ]:         44 :                                                 tdata->auth_tag.len);
    9301         [ -  + ]:         44 :                 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
    9302                 :            :                                 "no room to append digest");
    9303         [ +  + ]:         44 :                 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
    9304         [ +  + ]:         44 :                 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
    9305                 :            :                                 ut_params->obuf ? ut_params->obuf :
    9306                 :            :                                                 ut_params->ibuf,
    9307                 :            :                                                 plaintext_pad_len +
    9308                 :            :                                                 aad_pad_len);
    9309                 :            :         } else {
    9310                 :         88 :                 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
    9311                 :         44 :                                 ut_params->ibuf, tdata->auth_tag.len);
    9312         [ -  + ]:         44 :                 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
    9313                 :            :                                 "no room to append digest");
    9314         [ -  + ]:         44 :                 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
    9315                 :            :                                 ut_params->ibuf,
    9316                 :            :                                 plaintext_pad_len + aad_pad_len);
    9317                 :            : 
    9318                 :         44 :                 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
    9319         [ -  + ]:         44 :                         tdata->auth_tag.len);
    9320                 :         44 :                 debug_hexdump(stdout, "digest:",
    9321                 :         44 :                         sym_op->aead.digest.data,
    9322                 :         44 :                         tdata->auth_tag.len);
    9323                 :            :         }
    9324                 :            : 
    9325                 :         88 :         sym_op->aead.data.length = tdata->plaintext.len;
    9326                 :         88 :         sym_op->aead.data.offset = aad_pad_len;
    9327                 :            : 
    9328                 :         88 :         return 0;
    9329                 :            : }
    9330                 :            : 
    9331                 :            : static int
    9332                 :         43 : test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
    9333                 :            : {
    9334                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    9335                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    9336                 :            : 
    9337                 :            :         int retval;
    9338                 :            :         uint8_t *ciphertext, *auth_tag;
    9339                 :            :         uint16_t plaintext_pad_len;
    9340                 :            :         uint32_t i;
    9341                 :            :         struct rte_cryptodev_info dev_info;
    9342                 :            : 
    9343                 :         43 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    9344                 :         43 :         uint64_t feat_flags = dev_info.feature_flags;
    9345                 :            : 
    9346         [ -  + ]:         43 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    9347         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    9348                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    9349                 :          0 :                 return TEST_SKIPPED;
    9350                 :            :         }
    9351                 :            : 
    9352                 :            :         /* Verify the capabilities */
    9353                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    9354                 :            :         const struct rte_cryptodev_symmetric_capability *capability;
    9355                 :         43 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
    9356                 :         43 :         cap_idx.algo.aead = tdata->algo;
    9357                 :         43 :         capability = rte_cryptodev_sym_capability_get(
    9358                 :         43 :                         ts_params->valid_devs[0], &cap_idx);
    9359         [ +  - ]:         43 :         if (capability == NULL)
    9360                 :            :                 return TEST_SKIPPED;
    9361         [ +  + ]:         43 :         if (rte_cryptodev_sym_capability_check_aead(
    9362                 :         43 :                         capability, tdata->key.len, tdata->auth_tag.len,
    9363                 :         43 :                         tdata->aad.len, tdata->iv.len))
    9364                 :            :                 return TEST_SKIPPED;
    9365                 :            : 
    9366                 :            :         /* Create AEAD session */
    9367                 :         42 :         retval = create_aead_session(ts_params->valid_devs[0],
    9368                 :         42 :                         tdata->algo,
    9369                 :            :                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
    9370                 :         42 :                         tdata->key.data, tdata->key.len,
    9371                 :         42 :                         tdata->aad.len, tdata->auth_tag.len,
    9372                 :         42 :                         tdata->iv.len);
    9373         [ +  - ]:         42 :         if (retval != TEST_SUCCESS)
    9374                 :            :                 return retval;
    9375                 :            : 
    9376         [ +  + ]:         42 :         if (tdata->aad.len > MBUF_SIZE) {
    9377         [ -  + ]:          2 :                 if (use_ext_mbuf) {
    9378                 :          0 :                         ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
    9379                 :            :                                                           AEAD_TEXT_MAX_LENGTH,
    9380                 :            :                                                           1 /* nb_segs */,
    9381                 :            :                                                           NULL);
    9382                 :            :                 } else {
    9383                 :          2 :                         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
    9384                 :            :                 }
    9385                 :            :                 /* Populate full size of add data */
    9386         [ +  + ]:       4088 :                 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
    9387                 :       4086 :                         memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
    9388                 :            :         } else {
    9389         [ +  + ]:         40 :                 if (use_ext_mbuf) {
    9390                 :          1 :                         ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
    9391                 :            :                                                           AEAD_TEXT_MAX_LENGTH,
    9392                 :            :                                                           1 /* nb_segs */,
    9393                 :            :                                                           NULL);
    9394                 :            :                 } else {
    9395                 :         39 :                         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9396                 :            :                 }
    9397                 :            :         }
    9398                 :            : 
    9399                 :            :         /* clear mbuf payload */
    9400                 :         42 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    9401                 :         42 :                         rte_pktmbuf_tailroom(ut_params->ibuf));
    9402                 :            : 
    9403                 :            :         /* Create AEAD operation */
    9404                 :         42 :         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
    9405         [ +  - ]:         42 :         if (retval < 0)
    9406                 :            :                 return retval;
    9407                 :            : 
    9408         [ +  - ]:         42 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    9409                 :            : 
    9410                 :         42 :         ut_params->op->sym->m_src = ut_params->ibuf;
    9411                 :            : 
    9412                 :            :         /* Process crypto operation */
    9413         [ -  + ]:         42 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    9414                 :          0 :                 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
    9415         [ -  + ]:         42 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    9416                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
    9417                 :            :                                                0);
    9418         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    9419                 :            :                         return retval;
    9420                 :            :         } else
    9421         [ -  + ]:         42 :                 TEST_ASSERT_NOT_NULL(
    9422                 :            :                         process_crypto_request(ts_params->valid_devs[0],
    9423                 :            :                         ut_params->op), "failed to process sym crypto op");
    9424                 :            : 
    9425         [ -  + ]:         42 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    9426                 :            :                         "crypto op processing failed");
    9427                 :            : 
    9428                 :         42 :         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
    9429                 :            : 
    9430         [ -  + ]:         42 :         if (ut_params->op->sym->m_dst) {
    9431                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
    9432                 :            :                                 uint8_t *);
    9433                 :          0 :                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
    9434                 :            :                                 uint8_t *, plaintext_pad_len);
    9435                 :            :         } else {
    9436                 :         42 :                 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
    9437                 :            :                                 uint8_t *,
    9438                 :            :                                 ut_params->op->sym->cipher.data.offset);
    9439                 :         42 :                 auth_tag = ciphertext + plaintext_pad_len;
    9440                 :            :         }
    9441                 :            : 
    9442                 :         42 :         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
    9443                 :         42 :         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
    9444                 :            : 
    9445                 :            :         /* Validate obuf */
    9446         [ +  + ]:         45 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    9447                 :            :                         ciphertext,
    9448                 :            :                         tdata->ciphertext.data,
    9449                 :            :                         tdata->ciphertext.len,
    9450                 :            :                         "Ciphertext data not as expected");
    9451                 :            : 
    9452         [ +  + ]:         42 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    9453                 :            :                         auth_tag,
    9454                 :            :                         tdata->auth_tag.data,
    9455                 :            :                         tdata->auth_tag.len,
    9456                 :            :                         "Generated auth tag not as expected");
    9457                 :            : 
    9458                 :            :         return 0;
    9459                 :            : 
    9460                 :            : }
    9461                 :            : 
    9462                 :            : static int
    9463                 :            : test_authenticated_encryption(const struct aead_test_data *tdata)
    9464                 :            : {
    9465                 :         42 :         return test_authenticated_encryption_helper(tdata, false);
    9466                 :            : }
    9467                 :            : 
    9468                 :            : #ifdef RTE_LIB_SECURITY
    9469                 :            : static int
    9470                 :          0 : security_proto_supported(enum rte_security_session_action_type action,
    9471                 :            :         enum rte_security_session_protocol proto)
    9472                 :            : {
    9473                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    9474                 :            : 
    9475                 :            :         const struct rte_security_capability *capabilities;
    9476                 :            :         const struct rte_security_capability *capability;
    9477                 :            :         uint16_t i = 0;
    9478                 :            : 
    9479                 :          0 :         void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
    9480                 :            : 
    9481                 :            : 
    9482                 :          0 :         capabilities = rte_security_capabilities_get(ctx);
    9483                 :            : 
    9484         [ #  # ]:          0 :         if (capabilities == NULL)
    9485                 :            :                 return -ENOTSUP;
    9486                 :            : 
    9487         [ #  # ]:          0 :         while ((capability = &capabilities[i++])->action !=
    9488                 :            :                         RTE_SECURITY_ACTION_TYPE_NONE) {
    9489         [ #  # ]:          0 :                 if (capability->action == action &&
    9490         [ #  # ]:          0 :                                 capability->protocol == proto)
    9491                 :            :                         return 0;
    9492                 :            :         }
    9493                 :            : 
    9494                 :            :         return -ENOTSUP;
    9495                 :            : }
    9496                 :            : 
    9497                 :            : /* Basic algorithm run function for async inplace mode.
    9498                 :            :  * Creates a session from input parameters and runs one operation
    9499                 :            :  * on input_vec. Checks the output of the crypto operation against
    9500                 :            :  * output_vec.
    9501                 :            :  */
    9502                 :          0 : static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
    9503                 :            :                            enum rte_crypto_auth_operation opa,
    9504                 :            :                            const uint8_t *input_vec, unsigned int input_vec_len,
    9505                 :            :                            const uint8_t *output_vec,
    9506                 :            :                            unsigned int output_vec_len,
    9507                 :            :                            enum rte_crypto_cipher_algorithm cipher_alg,
    9508                 :            :                            const uint8_t *cipher_key, uint32_t cipher_key_len,
    9509                 :            :                            enum rte_crypto_auth_algorithm auth_alg,
    9510                 :            :                            const uint8_t *auth_key, uint32_t auth_key_len,
    9511                 :            :                            uint8_t bearer, enum rte_security_pdcp_domain domain,
    9512                 :            :                            uint8_t packet_direction, uint8_t sn_size,
    9513                 :            :                            uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
    9514                 :            : {
    9515                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    9516                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    9517                 :            :         uint8_t *plaintext;
    9518                 :            :         int ret = TEST_SUCCESS;
    9519                 :          0 :         void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
    9520                 :            :         struct rte_cryptodev_info dev_info;
    9521                 :            :         uint64_t feat_flags;
    9522                 :            : 
    9523                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    9524                 :          0 :         feat_flags = dev_info.feature_flags;
    9525                 :            : 
    9526                 :            :         /* Verify the capabilities */
    9527                 :            :         struct rte_security_capability_idx sec_cap_idx;
    9528                 :            : 
    9529                 :          0 :         sec_cap_idx.action = ut_params->type;
    9530                 :          0 :         sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
    9531                 :          0 :         sec_cap_idx.pdcp.domain = domain;
    9532         [ #  # ]:          0 :         if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
    9533                 :            :                 return TEST_SKIPPED;
    9534                 :            : 
    9535                 :            :         /* Generate test mbuf data */
    9536                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9537                 :            : 
    9538                 :            :         /* clear mbuf payload */
    9539                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    9540                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
    9541                 :            : 
    9542                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    9543                 :            :                                                   input_vec_len);
    9544         [ #  # ]:          0 :         memcpy(plaintext, input_vec, input_vec_len);
    9545                 :            : 
    9546         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    9547         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    9548                 :            :                 printf("Device does not support RAW data-path APIs.\n");
    9549                 :          0 :                 return TEST_SKIPPED;
    9550                 :            :         }
    9551                 :            :         /* Out of place support */
    9552         [ #  # ]:          0 :         if (oop) {
    9553                 :            :                 /*
    9554                 :            :                  * For out-of-place we need to alloc another mbuf
    9555                 :            :                  */
    9556                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9557                 :          0 :                 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
    9558                 :            :         }
    9559                 :            : 
    9560                 :            :         /* Setup Cipher Parameters */
    9561                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    9562                 :          0 :         ut_params->cipher_xform.cipher.algo = cipher_alg;
    9563                 :          0 :         ut_params->cipher_xform.cipher.op = opc;
    9564                 :          0 :         ut_params->cipher_xform.cipher.key.data = cipher_key;
    9565                 :          0 :         ut_params->cipher_xform.cipher.key.length = cipher_key_len;
    9566         [ #  # ]:          0 :         ut_params->cipher_xform.cipher.iv.length =
    9567                 :            :                                 packet_direction ? 4 : 0;
    9568                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    9569                 :            : 
    9570                 :            :         /* Setup HMAC Parameters if ICV header is required */
    9571         [ #  # ]:          0 :         if (auth_alg != 0) {
    9572                 :          0 :                 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    9573                 :          0 :                 ut_params->auth_xform.next = NULL;
    9574                 :          0 :                 ut_params->auth_xform.auth.algo = auth_alg;
    9575                 :          0 :                 ut_params->auth_xform.auth.op = opa;
    9576                 :          0 :                 ut_params->auth_xform.auth.key.data = auth_key;
    9577                 :          0 :                 ut_params->auth_xform.auth.key.length = auth_key_len;
    9578                 :            : 
    9579                 :          0 :                 ut_params->cipher_xform.next = &ut_params->auth_xform;
    9580                 :            :         } else {
    9581                 :          0 :                 ut_params->cipher_xform.next = NULL;
    9582                 :            :         }
    9583                 :            : 
    9584                 :          0 :         struct rte_security_session_conf sess_conf = {
    9585                 :          0 :                 .action_type = ut_params->type,
    9586                 :            :                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
    9587                 :            :                 {.pdcp = {
    9588                 :            :                         .bearer = bearer,
    9589                 :            :                         .domain = domain,
    9590                 :            :                         .pkt_dir = packet_direction,
    9591                 :            :                         .sn_size = sn_size,
    9592         [ #  # ]:          0 :                         .hfn = packet_direction ? 0 : hfn,
    9593                 :            :                         /**
    9594                 :            :                          * hfn can be set as pdcp_test_hfn[i]
    9595                 :            :                          * if hfn_ovrd is not set. Here, PDCP
    9596                 :            :                          * packet direction is just used to
    9597                 :            :                          * run half of the cases with session
    9598                 :            :                          * HFN and other half with per packet
    9599                 :            :                          * HFN.
    9600                 :            :                          */
    9601                 :            :                         .hfn_threshold = hfn_threshold,
    9602                 :          0 :                         .hfn_ovrd = packet_direction ? 1 : 0,
    9603                 :            :                         .sdap_enabled = sdap,
    9604                 :            :                 } },
    9605                 :            :                 .crypto_xform = &ut_params->cipher_xform
    9606                 :            :         };
    9607                 :            : 
    9608                 :            :         /* Create security session */
    9609                 :          0 :         ut_params->sec_session = rte_security_session_create(ctx,
    9610                 :            :                                 &sess_conf, ts_params->session_mpool);
    9611                 :            : 
    9612         [ #  # ]:          0 :         if (!ut_params->sec_session) {
    9613                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9614                 :            :                         __func__, i, __LINE__, "Failed to allocate session");
    9615                 :            :                 ret = TEST_FAILED;
    9616                 :          0 :                 goto on_err;
    9617                 :            :         }
    9618                 :            : 
    9619                 :            :         /* Generate crypto op data structure */
    9620                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    9621                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    9622         [ #  # ]:          0 :         if (!ut_params->op) {
    9623                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9624                 :            :                         __func__, i, __LINE__,
    9625                 :            :                         "Failed to allocate symmetric crypto operation struct");
    9626                 :            :                 ret = TEST_FAILED;
    9627                 :          0 :                 goto on_err;
    9628                 :            :         }
    9629                 :            : 
    9630                 :            :         uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
    9631                 :            :                                         uint32_t *, IV_OFFSET);
    9632         [ #  # ]:          0 :         *per_pkt_hfn = packet_direction ? hfn : 0;
    9633                 :            : 
    9634         [ #  # ]:          0 :         rte_security_attach_session(ut_params->op, ut_params->sec_session);
    9635                 :            : 
    9636                 :            :         /* set crypto operation source mbuf */
    9637                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
    9638         [ #  # ]:          0 :         if (oop)
    9639                 :          0 :                 ut_params->op->sym->m_dst = ut_params->obuf;
    9640                 :            : 
    9641                 :            :         /* Process crypto operation */
    9642         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    9643                 :            :                 /* filling lengths */
    9644                 :          0 :                 ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
    9645                 :          0 :                 ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
    9646                 :            : 
    9647                 :          0 :                 ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
    9648         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
    9649                 :            :                         return ret;
    9650                 :            :         } else {
    9651                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
    9652                 :            :         }
    9653         [ #  # ]:          0 :         if (ut_params->op == NULL) {
    9654                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9655                 :            :                         __func__, i, __LINE__,
    9656                 :            :                         "failed to process sym crypto op");
    9657                 :            :                 ret = TEST_FAILED;
    9658                 :          0 :                 goto on_err;
    9659                 :            :         }
    9660                 :            : 
    9661         [ #  # ]:          0 :         if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    9662                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9663                 :            :                         __func__, i, __LINE__, "crypto op processing failed");
    9664                 :            :                 ret = TEST_FAILED;
    9665                 :          0 :                 goto on_err;
    9666                 :            :         }
    9667                 :            : 
    9668                 :            :         /* Validate obuf */
    9669                 :          0 :         uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
    9670                 :            :                         uint8_t *);
    9671         [ #  # ]:          0 :         if (oop) {
    9672                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
    9673                 :            :                                 uint8_t *);
    9674                 :            :         }
    9675                 :            : 
    9676         [ #  # ]:          0 :         if (memcmp(ciphertext, output_vec, output_vec_len)) {
    9677                 :            :                 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
    9678                 :          0 :                 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
    9679                 :          0 :                 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
    9680                 :            :                 ret = TEST_FAILED;
    9681                 :          0 :                 goto on_err;
    9682                 :            :         }
    9683                 :            : 
    9684                 :          0 : on_err:
    9685                 :          0 :         rte_crypto_op_free(ut_params->op);
    9686                 :          0 :         ut_params->op = NULL;
    9687                 :            : 
    9688         [ #  # ]:          0 :         if (ut_params->sec_session)
    9689                 :          0 :                 rte_security_session_destroy(ctx, ut_params->sec_session);
    9690                 :          0 :         ut_params->sec_session = NULL;
    9691                 :            : 
    9692                 :          0 :         rte_pktmbuf_free(ut_params->ibuf);
    9693                 :          0 :         ut_params->ibuf = NULL;
    9694         [ #  # ]:          0 :         if (oop) {
    9695                 :          0 :                 rte_pktmbuf_free(ut_params->obuf);
    9696                 :          0 :                 ut_params->obuf = NULL;
    9697                 :            :         }
    9698                 :            : 
    9699                 :            :         return ret;
    9700                 :            : }
    9701                 :            : 
    9702                 :            : static int
    9703                 :          0 : test_pdcp_proto_SGL(int i, int oop,
    9704                 :            :         enum rte_crypto_cipher_operation opc,
    9705                 :            :         enum rte_crypto_auth_operation opa,
    9706                 :            :         uint8_t *input_vec,
    9707                 :            :         unsigned int input_vec_len,
    9708                 :            :         uint8_t *output_vec,
    9709                 :            :         unsigned int output_vec_len,
    9710                 :            :         uint32_t fragsz,
    9711                 :            :         uint32_t fragsz_oop)
    9712                 :            : {
    9713                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    9714                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    9715                 :            :         uint8_t *plaintext;
    9716                 :            :         struct rte_mbuf *buf, *buf_oop = NULL;
    9717                 :            :         int ret = TEST_SUCCESS;
    9718                 :            :         int to_trn = 0;
    9719                 :            :         int to_trn_tbl[16];
    9720                 :            :         unsigned int trn_data = 0;
    9721                 :            :         struct rte_cryptodev_info dev_info;
    9722                 :            :         uint64_t feat_flags;
    9723                 :          0 :         void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
    9724                 :            :         struct rte_mbuf *temp_mbuf;
    9725                 :            : 
    9726                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    9727                 :          0 :         feat_flags = dev_info.feature_flags;
    9728                 :            : 
    9729         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    9730         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    9731                 :            :                 printf("Device does not support RAW data-path APIs.\n");
    9732                 :          0 :                 return -ENOTSUP;
    9733                 :            :         }
    9734                 :            :         /* Verify the capabilities */
    9735                 :            :         struct rte_security_capability_idx sec_cap_idx;
    9736                 :            : 
    9737                 :          0 :         sec_cap_idx.action = ut_params->type;
    9738                 :          0 :         sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
    9739                 :          0 :         sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
    9740         [ #  # ]:          0 :         if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
    9741                 :            :                 return TEST_SKIPPED;
    9742                 :            : 
    9743                 :            :         if (fragsz > input_vec_len)
    9744                 :            :                 fragsz = input_vec_len;
    9745                 :            : 
    9746                 :          0 :         uint16_t plaintext_len = fragsz;
    9747         [ #  # ]:          0 :         uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
    9748                 :            : 
    9749         [ #  # ]:          0 :         if (fragsz_oop > output_vec_len)
    9750                 :          0 :                 frag_size_oop = output_vec_len;
    9751                 :            : 
    9752                 :            :         int ecx = 0;
    9753         [ #  # ]:          0 :         if (input_vec_len % fragsz != 0) {
    9754         [ #  # ]:          0 :                 if (input_vec_len / fragsz + 1 > 16)
    9755                 :            :                         return 1;
    9756         [ #  # ]:          0 :         } else if (input_vec_len / fragsz > 16)
    9757                 :            :                 return 1;
    9758                 :            : 
    9759                 :            :         /* Out of place support */
    9760         [ #  # ]:          0 :         if (oop) {
    9761                 :            :                 /*
    9762                 :            :                  * For out-of-place we need to alloc another mbuf
    9763                 :            :                  */
    9764                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9765                 :            :                 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
    9766                 :          0 :                 buf_oop = ut_params->obuf;
    9767                 :            :         }
    9768                 :            : 
    9769                 :            :         /* Generate test mbuf data */
    9770                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9771                 :            : 
    9772                 :            :         /* clear mbuf payload */
    9773                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    9774                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
    9775                 :            : 
    9776                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    9777                 :            :                                                   plaintext_len);
    9778                 :          0 :         memcpy(plaintext, input_vec, plaintext_len);
    9779                 :            :         trn_data += plaintext_len;
    9780                 :            : 
    9781                 :          0 :         buf = ut_params->ibuf;
    9782                 :            : 
    9783                 :            :         /*
    9784                 :            :          * Loop until no more fragments
    9785                 :            :          */
    9786                 :            : 
    9787         [ #  # ]:          0 :         while (trn_data < input_vec_len) {
    9788                 :          0 :                 to_trn = (input_vec_len - trn_data < fragsz) ?
    9789                 :          0 :                                 (input_vec_len - trn_data) : fragsz;
    9790                 :            : 
    9791                 :          0 :                 to_trn_tbl[ecx++] = to_trn;
    9792                 :            : 
    9793                 :          0 :                 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9794                 :            :                 buf = buf->next;
    9795         [ #  # ]:          0 :                 ut_params->ibuf->nb_segs++;
    9796                 :            : 
    9797         [ #  # ]:          0 :                 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
    9798                 :            :                                 rte_pktmbuf_tailroom(buf));
    9799                 :            : 
    9800                 :            :                 /* OOP */
    9801         [ #  # ]:          0 :                 if (oop && !fragsz_oop) {
    9802                 :          0 :                         buf_oop->next =
    9803                 :          0 :                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9804                 :            :                         buf_oop = buf_oop->next;
    9805         [ #  # ]:          0 :                         ut_params->obuf->nb_segs++;
    9806         [ #  # ]:          0 :                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
    9807                 :            :                                         0, rte_pktmbuf_tailroom(buf_oop));
    9808         [ #  # ]:          0 :                         TEST_ASSERT_NOT_NULL(ut_params->obuf, "Output buffer not initialized");
    9809         [ #  # ]:          0 :                         TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
    9810                 :            :                 }
    9811                 :            : 
    9812                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    9813                 :            :                                 to_trn);
    9814         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(plaintext, "Failed to append plaintext");
    9815                 :            : 
    9816                 :          0 :                 memcpy(plaintext, input_vec + trn_data, to_trn);
    9817                 :          0 :                 trn_data += to_trn;
    9818                 :            :         }
    9819                 :            : 
    9820         [ #  # ]:          0 :         if (fragsz_oop && oop) {
    9821                 :            :                 to_trn = 0;
    9822                 :            :                 ecx = 0;
    9823                 :            : 
    9824                 :          0 :                 trn_data = frag_size_oop;
    9825         [ #  # ]:          0 :                 while (trn_data < output_vec_len) {
    9826                 :          0 :                         to_trn =
    9827                 :          0 :                                 (output_vec_len - trn_data <
    9828                 :            :                                                 frag_size_oop) ?
    9829                 :          0 :                                 (output_vec_len - trn_data) :
    9830                 :            :                                                 frag_size_oop;
    9831                 :            : 
    9832                 :          0 :                         to_trn_tbl[ecx++] = to_trn;
    9833                 :            : 
    9834                 :          0 :                         buf_oop->next =
    9835                 :          0 :                                 rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9836                 :            :                         buf_oop = buf_oop->next;
    9837                 :          0 :                         ut_params->obuf->nb_segs++;
    9838                 :          0 :                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
    9839                 :            :                                         0, rte_pktmbuf_tailroom(buf_oop));
    9840         [ #  # ]:          0 :                         TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
    9841                 :            : 
    9842                 :          0 :                         trn_data += to_trn;
    9843                 :            :                 }
    9844                 :            :         }
    9845                 :            : 
    9846                 :            :         /* Setup Cipher Parameters */
    9847                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    9848                 :          0 :         ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
    9849                 :          0 :         ut_params->cipher_xform.cipher.op = opc;
    9850                 :          0 :         ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
    9851                 :          0 :         ut_params->cipher_xform.cipher.key.length =
    9852                 :          0 :                                         pdcp_test_params[i].cipher_key_len;
    9853                 :          0 :         ut_params->cipher_xform.cipher.iv.length = 0;
    9854                 :            : 
    9855                 :            :         /* Setup HMAC Parameters if ICV header is required */
    9856         [ #  # ]:          0 :         if (pdcp_test_params[i].auth_alg != 0) {
    9857                 :          0 :                 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    9858                 :          0 :                 ut_params->auth_xform.next = NULL;
    9859                 :          0 :                 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
    9860                 :          0 :                 ut_params->auth_xform.auth.op = opa;
    9861                 :          0 :                 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
    9862                 :          0 :                 ut_params->auth_xform.auth.key.length =
    9863                 :          0 :                                         pdcp_test_params[i].auth_key_len;
    9864                 :            : 
    9865                 :          0 :                 ut_params->cipher_xform.next = &ut_params->auth_xform;
    9866                 :            :         } else {
    9867                 :          0 :                 ut_params->cipher_xform.next = NULL;
    9868                 :            :         }
    9869                 :            : 
    9870                 :          0 :         struct rte_security_session_conf sess_conf = {
    9871                 :          0 :                 .action_type = ut_params->type,
    9872                 :            :                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
    9873                 :            :                 {.pdcp = {
    9874                 :          0 :                         .bearer = pdcp_test_bearer[i],
    9875                 :          0 :                         .domain = pdcp_test_params[i].domain,
    9876                 :          0 :                         .pkt_dir = pdcp_test_packet_direction[i],
    9877                 :          0 :                         .sn_size = pdcp_test_data_sn_size[i],
    9878                 :          0 :                         .hfn = pdcp_test_hfn[i],
    9879                 :          0 :                         .hfn_threshold = pdcp_test_hfn_threshold[i],
    9880                 :            :                         .hfn_ovrd = 0,
    9881                 :            :                 } },
    9882                 :            :                 .crypto_xform = &ut_params->cipher_xform
    9883                 :            :         };
    9884                 :            : 
    9885                 :            :         /* Create security session */
    9886                 :          0 :         ut_params->sec_session = rte_security_session_create(ctx,
    9887                 :            :                                 &sess_conf, ts_params->session_mpool);
    9888                 :            : 
    9889         [ #  # ]:          0 :         if (!ut_params->sec_session) {
    9890                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9891                 :            :                         __func__, i, __LINE__, "Failed to allocate session");
    9892                 :            :                 ret = TEST_FAILED;
    9893                 :          0 :                 goto on_err;
    9894                 :            :         }
    9895                 :            : 
    9896                 :            :         /* Generate crypto op data structure */
    9897                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    9898                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    9899         [ #  # ]:          0 :         if (!ut_params->op) {
    9900                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9901                 :            :                         __func__, i, __LINE__,
    9902                 :            :                         "Failed to allocate symmetric crypto operation struct");
    9903                 :            :                 ret = TEST_FAILED;
    9904                 :          0 :                 goto on_err;
    9905                 :            :         }
    9906                 :            : 
    9907         [ #  # ]:          0 :         rte_security_attach_session(ut_params->op, ut_params->sec_session);
    9908                 :            : 
    9909                 :            :         /* set crypto operation source mbuf */
    9910                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
    9911         [ #  # ]:          0 :         if (oop)
    9912                 :          0 :                 ut_params->op->sym->m_dst = ut_params->obuf;
    9913                 :            : 
    9914                 :            :         /* Process crypto operation */
    9915                 :          0 :         temp_mbuf = ut_params->op->sym->m_src;
    9916         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    9917                 :            :                 /* filling lengths */
    9918         [ #  # ]:          0 :                 while (temp_mbuf) {
    9919                 :          0 :                         ut_params->op->sym->cipher.data.length
    9920                 :          0 :                                 += temp_mbuf->pkt_len;
    9921                 :          0 :                         ut_params->op->sym->auth.data.length
    9922                 :          0 :                                 += temp_mbuf->pkt_len;
    9923                 :          0 :                         temp_mbuf = temp_mbuf->next;
    9924                 :            :                 }
    9925                 :            : 
    9926                 :          0 :                 ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
    9927         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
    9928                 :            :                         return ret;
    9929                 :            :         } else {
    9930                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    9931                 :            :                                                         ut_params->op);
    9932                 :            :         }
    9933         [ #  # ]:          0 :         if (ut_params->op == NULL) {
    9934                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9935                 :            :                         __func__, i, __LINE__,
    9936                 :            :                         "failed to process sym crypto op");
    9937                 :            :                 ret = TEST_FAILED;
    9938                 :          0 :                 goto on_err;
    9939                 :            :         }
    9940                 :            : 
    9941         [ #  # ]:          0 :         if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    9942                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9943                 :            :                         __func__, i, __LINE__, "crypto op processing failed");
    9944                 :            :                 ret = TEST_FAILED;
    9945                 :          0 :                 goto on_err;
    9946                 :            :         }
    9947                 :            : 
    9948                 :            :         /* Validate obuf */
    9949                 :          0 :         uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
    9950                 :            :                         uint8_t *);
    9951         [ #  # ]:          0 :         if (oop) {
    9952                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
    9953                 :            :                                 uint8_t *);
    9954                 :            :         }
    9955         [ #  # ]:          0 :         if (fragsz_oop)
    9956                 :          0 :                 fragsz = frag_size_oop;
    9957         [ #  # ]:          0 :         if (memcmp(ciphertext, output_vec, fragsz)) {
    9958                 :            :                 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
    9959                 :          0 :                 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
    9960                 :          0 :                 rte_hexdump(stdout, "reference", output_vec, fragsz);
    9961                 :            :                 ret = TEST_FAILED;
    9962                 :          0 :                 goto on_err;
    9963                 :            :         }
    9964                 :            : 
    9965                 :          0 :         buf = ut_params->op->sym->m_src->next;
    9966         [ #  # ]:          0 :         if (oop)
    9967                 :          0 :                 buf = ut_params->op->sym->m_dst->next;
    9968                 :            : 
    9969                 :            :         unsigned int off = fragsz;
    9970                 :            : 
    9971                 :            :         ecx = 0;
    9972         [ #  # ]:          0 :         while (buf) {
    9973                 :          0 :                 ciphertext = rte_pktmbuf_mtod(buf,
    9974                 :            :                                 uint8_t *);
    9975         [ #  # ]:          0 :                 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
    9976                 :            :                         printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
    9977                 :          0 :                         rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
    9978                 :          0 :                         rte_hexdump(stdout, "reference", output_vec + off,
    9979                 :            :                                         to_trn_tbl[ecx]);
    9980                 :            :                         ret = TEST_FAILED;
    9981                 :          0 :                         goto on_err;
    9982                 :            :                 }
    9983                 :          0 :                 off += to_trn_tbl[ecx++];
    9984                 :          0 :                 buf = buf->next;
    9985                 :            :         }
    9986                 :          0 : on_err:
    9987                 :          0 :         rte_crypto_op_free(ut_params->op);
    9988                 :          0 :         ut_params->op = NULL;
    9989                 :            : 
    9990         [ #  # ]:          0 :         if (ut_params->sec_session)
    9991                 :          0 :                 rte_security_session_destroy(ctx, ut_params->sec_session);
    9992                 :          0 :         ut_params->sec_session = NULL;
    9993                 :            : 
    9994                 :          0 :         rte_pktmbuf_free(ut_params->ibuf);
    9995                 :          0 :         ut_params->ibuf = NULL;
    9996         [ #  # ]:          0 :         if (oop) {
    9997                 :          0 :                 rte_pktmbuf_free(ut_params->obuf);
    9998                 :          0 :                 ut_params->obuf = NULL;
    9999                 :            :         }
   10000                 :            : 
   10001                 :            :         return ret;
   10002                 :            : }
   10003                 :            : 
   10004                 :            : int
   10005                 :          0 : test_pdcp_proto_cplane_encap(int i)
   10006                 :            : {
   10007                 :          0 :         return test_pdcp_proto(
   10008                 :            :                 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
   10009                 :          0 :                 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
   10010                 :          0 :                 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
   10011                 :          0 :                 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
   10012                 :          0 :                 pdcp_test_params[i].cipher_key_len,
   10013                 :          0 :                 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
   10014                 :          0 :                 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
   10015                 :          0 :                 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
   10016                 :          0 :                 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
   10017                 :            :                 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
   10018                 :            : }
   10019                 :            : 
   10020                 :            : int
   10021                 :          0 : test_pdcp_proto_uplane_encap(int i)
   10022                 :            : {
   10023                 :          0 :         return test_pdcp_proto(
   10024                 :            :                 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
   10025                 :          0 :                 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
   10026                 :          0 :                 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
   10027                 :          0 :                 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
   10028                 :          0 :                 pdcp_test_params[i].cipher_key_len,
   10029                 :          0 :                 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
   10030                 :          0 :                 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
   10031                 :          0 :                 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
   10032                 :          0 :                 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
   10033                 :            :                 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
   10034                 :            : }
   10035                 :            : 
   10036                 :            : int
   10037                 :          0 : test_pdcp_proto_uplane_encap_with_int(int i)
   10038                 :            : {
   10039                 :          0 :         return test_pdcp_proto(
   10040                 :            :                 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
   10041                 :          0 :                 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
   10042                 :          0 :                 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
   10043                 :          0 :                 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
   10044                 :          0 :                 pdcp_test_params[i].cipher_key_len,
   10045                 :          0 :                 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
   10046                 :          0 :                 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
   10047                 :          0 :                 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
   10048                 :          0 :                 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
   10049                 :            :                 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
   10050                 :            : }
   10051                 :            : 
   10052                 :            : int
   10053                 :          0 : test_pdcp_proto_cplane_decap(int i)
   10054                 :            : {
   10055                 :          0 :         return test_pdcp_proto(
   10056                 :            :                 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
   10057                 :          0 :                 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
   10058                 :          0 :                 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
   10059                 :          0 :                 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
   10060                 :          0 :                 pdcp_test_params[i].cipher_key_len,
   10061                 :          0 :                 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
   10062                 :          0 :                 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
   10063                 :          0 :                 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
   10064                 :          0 :                 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
   10065                 :            :                 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
   10066                 :            : }
   10067                 :            : 
   10068                 :            : int
   10069                 :          0 : test_pdcp_proto_uplane_decap(int i)
   10070                 :            : {
   10071                 :          0 :         return test_pdcp_proto(
   10072                 :            :                 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
   10073                 :          0 :                 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
   10074                 :          0 :                 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
   10075                 :          0 :                 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
   10076                 :          0 :                 pdcp_test_params[i].cipher_key_len,
   10077                 :          0 :                 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
   10078                 :          0 :                 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
   10079                 :          0 :                 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
   10080                 :          0 :                 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
   10081                 :            :                 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
   10082                 :            : }
   10083                 :            : 
   10084                 :            : int
   10085                 :          0 : test_pdcp_proto_uplane_decap_with_int(int i)
   10086                 :            : {
   10087                 :          0 :         return test_pdcp_proto(
   10088                 :            :                 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
   10089                 :          0 :                 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
   10090                 :          0 :                 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
   10091                 :          0 :                 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
   10092                 :          0 :                 pdcp_test_params[i].cipher_key_len,
   10093                 :          0 :                 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
   10094                 :          0 :                 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
   10095                 :          0 :                 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
   10096                 :          0 :                 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
   10097                 :            :                 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
   10098                 :            : }
   10099                 :            : 
   10100                 :            : static int
   10101                 :          0 : test_PDCP_PROTO_SGL_in_place_32B(void)
   10102                 :            : {
   10103                 :            :         /* i can be used for running any PDCP case
   10104                 :            :          * In this case it is uplane 12-bit AES-SNOW DL encap
   10105                 :            :          */
   10106                 :            :         int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
   10107                 :          0 :         return test_pdcp_proto_SGL(i, IN_PLACE,
   10108                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
   10109                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
   10110                 :            :                         pdcp_test_data_in[i],
   10111                 :            :                         pdcp_test_data_in_len[i],
   10112                 :            :                         pdcp_test_data_out[i],
   10113                 :          0 :                         pdcp_test_data_in_len[i]+4,
   10114                 :            :                         32, 0);
   10115                 :            : }
   10116                 :            : static int
   10117                 :          0 : test_PDCP_PROTO_SGL_oop_32B_128B(void)
   10118                 :            : {
   10119                 :            :         /* i can be used for running any PDCP case
   10120                 :            :          * In this case it is uplane 18-bit NULL-NULL DL encap
   10121                 :            :          */
   10122                 :            :         int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
   10123                 :          0 :         return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
   10124                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
   10125                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
   10126                 :            :                         pdcp_test_data_in[i],
   10127                 :            :                         pdcp_test_data_in_len[i],
   10128                 :            :                         pdcp_test_data_out[i],
   10129                 :          0 :                         pdcp_test_data_in_len[i]+4,
   10130                 :            :                         32, 128);
   10131                 :            : }
   10132                 :            : static int
   10133                 :          0 : test_PDCP_PROTO_SGL_oop_32B_40B(void)
   10134                 :            : {
   10135                 :            :         /* i can be used for running any PDCP case
   10136                 :            :          * In this case it is uplane 18-bit AES DL encap
   10137                 :            :          */
   10138                 :            :         int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
   10139                 :            :                         + DOWNLINK;
   10140                 :          0 :         return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
   10141                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
   10142                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
   10143                 :            :                         pdcp_test_data_in[i],
   10144                 :            :                         pdcp_test_data_in_len[i],
   10145                 :            :                         pdcp_test_data_out[i],
   10146                 :            :                         pdcp_test_data_in_len[i],
   10147                 :            :                         32, 40);
   10148                 :            : }
   10149                 :            : static int
   10150                 :          0 : test_PDCP_PROTO_SGL_oop_128B_32B(void)
   10151                 :            : {
   10152                 :            :         /* i can be used for running any PDCP case
   10153                 :            :          * In this case it is cplane 12-bit AES-ZUC DL encap
   10154                 :            :          */
   10155                 :            :         int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
   10156                 :          0 :         return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
   10157                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
   10158                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
   10159                 :            :                         pdcp_test_data_in[i],
   10160                 :            :                         pdcp_test_data_in_len[i],
   10161                 :            :                         pdcp_test_data_out[i],
   10162                 :          0 :                         pdcp_test_data_in_len[i]+4,
   10163                 :            :                         128, 32);
   10164                 :            : }
   10165                 :            : 
   10166                 :            : static int
   10167                 :          0 : test_PDCP_SDAP_PROTO_encap_all(void)
   10168                 :            : {
   10169                 :            :         int i = 0, size = 0;
   10170                 :            :         int err, all_err = TEST_SUCCESS;
   10171                 :            :         const struct pdcp_sdap_test *cur_test;
   10172                 :            : 
   10173                 :            :         size = RTE_DIM(list_pdcp_sdap_tests);
   10174                 :            : 
   10175         [ #  # ]:          0 :         for (i = 0; i < size; i++) {
   10176                 :            :                 cur_test = &list_pdcp_sdap_tests[i];
   10177                 :          0 :                 err = test_pdcp_proto(
   10178                 :            :                         i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
   10179                 :          0 :                         RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
   10180                 :          0 :                         cur_test->in_len, cur_test->data_out,
   10181                 :          0 :                         cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
   10182                 :          0 :                         cur_test->param.cipher_alg, cur_test->cipher_key,
   10183                 :          0 :                         cur_test->param.cipher_key_len,
   10184                 :          0 :                         cur_test->param.auth_alg,
   10185                 :          0 :                         cur_test->auth_key, cur_test->param.auth_key_len,
   10186                 :          0 :                         cur_test->bearer, cur_test->param.domain,
   10187                 :          0 :                         cur_test->packet_direction, cur_test->sn_size,
   10188                 :          0 :                         cur_test->hfn,
   10189         [ #  # ]:          0 :                         cur_test->hfn_threshold, SDAP_ENABLED);
   10190         [ #  # ]:          0 :                 if (err) {
   10191                 :            :                         printf("\t%d) %s: Encapsulation failed\n",
   10192                 :          0 :                                         cur_test->test_idx,
   10193                 :          0 :                                         cur_test->param.name);
   10194                 :            :                         err = TEST_FAILED;
   10195                 :            :                 } else {
   10196                 :          0 :                         printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
   10197                 :          0 :                                         cur_test->param.name);
   10198                 :            :                         err = TEST_SUCCESS;
   10199                 :            :                 }
   10200                 :          0 :                 all_err += err;
   10201                 :            :         }
   10202                 :            : 
   10203                 :          0 :         printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
   10204                 :            : 
   10205         [ #  # ]:          0 :         return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
   10206                 :            : }
   10207                 :            : 
   10208                 :            : static int
   10209                 :          0 : test_PDCP_PROTO_short_mac(void)
   10210                 :            : {
   10211                 :            :         int i = 0, size = 0;
   10212                 :            :         int err, all_err = TEST_SUCCESS;
   10213                 :            :         const struct pdcp_short_mac_test *cur_test;
   10214                 :            : 
   10215                 :            :         size = RTE_DIM(list_pdcp_smac_tests);
   10216                 :            : 
   10217         [ #  # ]:          0 :         for (i = 0; i < size; i++) {
   10218                 :            :                 cur_test = &list_pdcp_smac_tests[i];
   10219                 :          0 :                 err = test_pdcp_proto(
   10220                 :            :                         i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
   10221                 :          0 :                         RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
   10222                 :          0 :                         cur_test->in_len, cur_test->data_out,
   10223                 :          0 :                         cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
   10224                 :            :                         RTE_CRYPTO_CIPHER_NULL, NULL,
   10225                 :          0 :                         0, cur_test->param.auth_alg,
   10226                 :          0 :                         cur_test->auth_key, cur_test->param.auth_key_len,
   10227         [ #  # ]:          0 :                         0, cur_test->param.domain, 0, 0,
   10228                 :            :                         0, 0, 0);
   10229         [ #  # ]:          0 :                 if (err) {
   10230                 :            :                         printf("\t%d) %s: Short MAC test failed\n",
   10231                 :          0 :                                         cur_test->test_idx,
   10232                 :          0 :                                         cur_test->param.name);
   10233                 :            :                         err = TEST_FAILED;
   10234                 :            :                 } else {
   10235                 :            :                         printf("\t%d) %s: Short MAC test PASS\n",
   10236                 :          0 :                                         cur_test->test_idx,
   10237                 :          0 :                                         cur_test->param.name);
   10238                 :          0 :                         rte_hexdump(stdout, "MAC I",
   10239                 :          0 :                                     cur_test->data_out + cur_test->in_len + 2,
   10240                 :            :                                     2);
   10241                 :            :                         err = TEST_SUCCESS;
   10242                 :            :                 }
   10243                 :          0 :                 all_err += err;
   10244                 :            :         }
   10245                 :            : 
   10246                 :          0 :         printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
   10247                 :            : 
   10248         [ #  # ]:          0 :         return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
   10249                 :            : 
   10250                 :            : }
   10251                 :            : 
   10252                 :            : static int
   10253                 :          0 : test_PDCP_SDAP_PROTO_decap_all(void)
   10254                 :            : {
   10255                 :            :         int i = 0, size = 0;
   10256                 :            :         int err, all_err = TEST_SUCCESS;
   10257                 :            :         const struct pdcp_sdap_test *cur_test;
   10258                 :            : 
   10259                 :            :         size = RTE_DIM(list_pdcp_sdap_tests);
   10260                 :            : 
   10261         [ #  # ]:          0 :         for (i = 0; i < size; i++) {
   10262                 :            :                 cur_test = &list_pdcp_sdap_tests[i];
   10263                 :          0 :                 err = test_pdcp_proto(
   10264                 :            :                         i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
   10265                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY,
   10266                 :          0 :                         cur_test->data_out,
   10267                 :          0 :                         cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
   10268                 :          0 :                         cur_test->data_in, cur_test->in_len,
   10269                 :          0 :                         cur_test->param.cipher_alg,
   10270                 :          0 :                         cur_test->cipher_key, cur_test->param.cipher_key_len,
   10271                 :          0 :                         cur_test->param.auth_alg, cur_test->auth_key,
   10272                 :          0 :                         cur_test->param.auth_key_len, cur_test->bearer,
   10273                 :          0 :                         cur_test->param.domain, cur_test->packet_direction,
   10274                 :          0 :                         cur_test->sn_size, cur_test->hfn,
   10275         [ #  # ]:          0 :                         cur_test->hfn_threshold, SDAP_ENABLED);
   10276         [ #  # ]:          0 :                 if (err) {
   10277                 :            :                         printf("\t%d) %s: Decapsulation failed\n",
   10278                 :          0 :                                         cur_test->test_idx,
   10279                 :          0 :                                         cur_test->param.name);
   10280                 :            :                         err = TEST_FAILED;
   10281                 :            :                 } else {
   10282                 :          0 :                         printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
   10283                 :          0 :                                         cur_test->param.name);
   10284                 :            :                         err = TEST_SUCCESS;
   10285                 :            :                 }
   10286                 :          0 :                 all_err += err;
   10287                 :            :         }
   10288                 :            : 
   10289                 :          0 :         printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
   10290                 :            : 
   10291         [ #  # ]:          0 :         return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
   10292                 :            : }
   10293                 :            : 
   10294                 :            : static int
   10295                 :          0 : test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
   10296                 :            :                                struct crypto_unittest_params *ut_params,
   10297                 :            :                                struct rte_security_ipsec_xform *ipsec_xform,
   10298                 :            :                                const struct ipsec_test_data *td,
   10299                 :            :                                const struct ipsec_test_flags *flags,
   10300                 :            :                                int pkt_num)
   10301                 :            : {
   10302                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
   10303                 :            :         enum rte_security_ipsec_sa_direction dir;
   10304                 :            :         int ret;
   10305                 :            : 
   10306                 :          0 :         dir = ipsec_xform->direction;
   10307                 :            : 
   10308                 :            :         /* Generate crypto op data structure */
   10309                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   10310                 :            :                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   10311         [ #  # ]:          0 :         if (!ut_params->op) {
   10312                 :            :                 printf("Could not allocate crypto op");
   10313                 :          0 :                 return TEST_FAILED;
   10314                 :            :         }
   10315                 :            : 
   10316                 :            :         /* Attach session to operation */
   10317         [ #  # ]:          0 :         rte_security_attach_session(ut_params->op, ut_params->sec_session);
   10318                 :            : 
   10319                 :            :         /* Set crypto operation mbufs */
   10320                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
   10321                 :          0 :         ut_params->op->sym->m_dst = NULL;
   10322                 :            : 
   10323                 :            :         /* Copy IV in crypto operation when IV generation is disabled */
   10324         [ #  # ]:          0 :         if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
   10325         [ #  # ]:          0 :             ipsec_xform->options.iv_gen_disable == 1) {
   10326                 :          0 :                 uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
   10327                 :            :                                                         uint8_t *,
   10328                 :            :                                                         IV_OFFSET);
   10329                 :            :                 int len;
   10330                 :            : 
   10331         [ #  # ]:          0 :                 if (td->aead)
   10332                 :          0 :                         len = td->xform.aead.aead.iv.length;
   10333         [ #  # ]:          0 :                 else if (td->aes_gmac)
   10334                 :          0 :                         len = td->xform.chain.auth.auth.iv.length;
   10335                 :            :                 else
   10336                 :          0 :                         len = td->xform.chain.cipher.cipher.iv.length;
   10337                 :            : 
   10338                 :          0 :                 memcpy(iv, td->iv.data, len);
   10339                 :            :         }
   10340                 :            : 
   10341                 :            :         /* Process crypto operation */
   10342                 :          0 :         process_crypto_request(dev_id, ut_params->op);
   10343                 :            : 
   10344                 :          0 :         ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
   10345                 :            : 
   10346                 :          0 :         rte_crypto_op_free(ut_params->op);
   10347                 :          0 :         ut_params->op = NULL;
   10348                 :            : 
   10349                 :          0 :         return ret;
   10350                 :            : }
   10351                 :            : 
   10352                 :            : static int
   10353                 :          0 : test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
   10354                 :            :                           struct crypto_unittest_params *ut_params,
   10355                 :            :                           void *ctx)
   10356                 :            : {
   10357                 :            :         uint64_t timeout, userdata;
   10358                 :            :         struct rte_ether_hdr *hdr;
   10359                 :            :         struct rte_mbuf *m;
   10360                 :            :         void **sec_sess;
   10361                 :            :         int ret;
   10362                 :            : 
   10363                 :            :         RTE_SET_USED(ts_params);
   10364                 :            : 
   10365         [ #  # ]:          0 :         hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
   10366                 :          0 :         hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
   10367                 :            : 
   10368                 :          0 :         ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
   10369                 :          0 :         ut_params->ibuf->port = 0;
   10370                 :            : 
   10371                 :          0 :         sec_sess = &ut_params->sec_session;
   10372                 :          0 :         ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
   10373                 :            : 
   10374         [ #  # ]:          0 :         if (ret != 1)
   10375                 :            :                 return TEST_FAILED;
   10376                 :            : 
   10377                 :          0 :         ut_params->ibuf = NULL;
   10378                 :            : 
   10379                 :            :         /* Add a timeout for 1 s */
   10380                 :          0 :         timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
   10381                 :            : 
   10382                 :            :         do {
   10383                 :            :                 /* Get packet from port 0, queue 0 */
   10384                 :          0 :                 ret = rte_eth_rx_burst(0, 0, &m, 1);
   10385   [ #  #  #  # ]:          0 :         } while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
   10386                 :            : 
   10387         [ #  # ]:          0 :         if (ret == 0) {
   10388                 :            :                 printf("Could not receive packets from ethdev\n");
   10389                 :          0 :                 return TEST_FAILED;
   10390                 :            :         }
   10391                 :            : 
   10392         [ #  # ]:          0 :         if (m == NULL) {
   10393                 :            :                 printf("Received mbuf is NULL\n");
   10394                 :          0 :                 return TEST_FAILED;
   10395                 :            :         }
   10396                 :            : 
   10397                 :          0 :         ut_params->ibuf = m;
   10398                 :            : 
   10399         [ #  # ]:          0 :         if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
   10400                 :            :                 printf("Received packet is not Rx security processed\n");
   10401                 :          0 :                 return TEST_FAILED;
   10402                 :            :         }
   10403                 :            : 
   10404         [ #  # ]:          0 :         if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
   10405                 :            :                 printf("Received packet has failed Rx security processing\n");
   10406                 :          0 :                 return TEST_FAILED;
   10407                 :            :         }
   10408                 :            : 
   10409                 :            :         /*
   10410                 :            :          * 'ut_params' is set as userdata. Verify that the field is returned
   10411                 :            :          * correctly.
   10412                 :            :          */
   10413                 :          0 :         userdata = *(uint64_t *)rte_security_dynfield(m);
   10414         [ #  # ]:          0 :         if (userdata != (uint64_t)ut_params) {
   10415                 :            :                 printf("Userdata retrieved not matching expected\n");
   10416                 :          0 :                 return TEST_FAILED;
   10417                 :            :         }
   10418                 :            : 
   10419                 :            :         /* Trim L2 header */
   10420                 :            :         rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
   10421                 :            : 
   10422                 :            :         return TEST_SUCCESS;
   10423                 :            : }
   10424                 :            : 
   10425                 :            : static int
   10426                 :          0 : test_ipsec_proto_process(const struct ipsec_test_data td[],
   10427                 :            :                          struct ipsec_test_data res_d[],
   10428                 :            :                          int nb_td,
   10429                 :            :                          bool silent,
   10430                 :            :                          const struct ipsec_test_flags *flags)
   10431                 :            : {
   10432                 :            :         uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
   10433                 :            :                                 0x0000, 0x001a};
   10434                 :            :         uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
   10435                 :            :                                 0xe82c, 0x4887};
   10436                 :            :         const struct rte_ipv4_hdr *ipv4 =
   10437                 :            :                         (const struct rte_ipv4_hdr *)td[0].output_text.data;
   10438         [ #  # ]:          0 :         int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
   10439                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   10440                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   10441                 :            :         struct rte_security_capability_idx sec_cap_idx;
   10442                 :            :         const struct rte_security_capability *sec_cap;
   10443                 :            :         struct rte_security_ipsec_xform ipsec_xform;
   10444                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
   10445                 :            :         enum rte_security_ipsec_sa_direction dir;
   10446                 :            :         struct ipsec_test_data *res_d_tmp = NULL;
   10447                 :            :         uint8_t input_text[IPSEC_TEXT_MAX_LEN];
   10448                 :            :         int salt_len, i, ret = TEST_SUCCESS;
   10449                 :            :         void *ctx;
   10450                 :            :         uint32_t src, dst;
   10451                 :            :         uint32_t verify;
   10452                 :            : 
   10453                 :          0 :         ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
   10454                 :          0 :         gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
   10455                 :            : 
   10456                 :            :         /* Use first test data to create session */
   10457                 :            : 
   10458                 :            :         /* Copy IPsec xform */
   10459         [ #  # ]:          0 :         memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
   10460                 :            : 
   10461                 :          0 :         dir = ipsec_xform.direction;
   10462                 :          0 :         verify = flags->tunnel_hdr_verify;
   10463                 :            : 
   10464                 :            :         memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
   10465                 :            :         memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
   10466                 :            : 
   10467         [ #  # ]:          0 :         if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
   10468         [ #  # ]:          0 :                 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
   10469                 :          0 :                         src += 1;
   10470         [ #  # ]:          0 :                 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
   10471                 :          0 :                         dst += 1;
   10472                 :            :         }
   10473                 :            : 
   10474         [ #  # ]:          0 :         if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
   10475         [ #  # ]:          0 :                 if (td->ipsec_xform.tunnel.type ==
   10476                 :            :                                 RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
   10477                 :            :                         memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
   10478                 :            :                                sizeof(src));
   10479                 :            :                         memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
   10480                 :            :                                sizeof(dst));
   10481                 :            : 
   10482         [ #  # ]:          0 :                         if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
   10483                 :          0 :                                 ipsec_xform.tunnel.ipv4.df = 0;
   10484                 :            : 
   10485         [ #  # ]:          0 :                         if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
   10486                 :          0 :                                 ipsec_xform.tunnel.ipv4.df = 1;
   10487                 :            : 
   10488         [ #  # ]:          0 :                         if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
   10489                 :          0 :                                 ipsec_xform.tunnel.ipv4.dscp = 0;
   10490                 :            : 
   10491         [ #  # ]:          0 :                         if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
   10492                 :          0 :                                 ipsec_xform.tunnel.ipv4.dscp =
   10493                 :            :                                                 TEST_IPSEC_DSCP_VAL;
   10494                 :            : 
   10495                 :            :                 } else {
   10496         [ #  # ]:          0 :                         if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
   10497                 :          0 :                                 ipsec_xform.tunnel.ipv6.dscp = 0;
   10498                 :            : 
   10499         [ #  # ]:          0 :                         if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
   10500                 :          0 :                                 ipsec_xform.tunnel.ipv6.dscp =
   10501                 :            :                                                 TEST_IPSEC_DSCP_VAL;
   10502                 :            : 
   10503                 :            :                         memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
   10504                 :            :                                sizeof(v6_src));
   10505                 :            :                         memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
   10506                 :            :                                sizeof(v6_dst));
   10507                 :            :                 }
   10508                 :            :         }
   10509                 :            : 
   10510                 :          0 :         ctx = rte_cryptodev_get_sec_ctx(dev_id);
   10511                 :            : 
   10512                 :          0 :         sec_cap_idx.action = ut_params->type;
   10513                 :          0 :         sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
   10514                 :          0 :         sec_cap_idx.ipsec.proto = ipsec_xform.proto;
   10515                 :          0 :         sec_cap_idx.ipsec.mode = ipsec_xform.mode;
   10516                 :          0 :         sec_cap_idx.ipsec.direction = ipsec_xform.direction;
   10517                 :            : 
   10518         [ #  # ]:          0 :         if (flags->udp_encap)
   10519                 :          0 :                 ipsec_xform.options.udp_encap = 1;
   10520                 :            : 
   10521                 :          0 :         sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
   10522         [ #  # ]:          0 :         if (sec_cap == NULL)
   10523                 :            :                 return TEST_SKIPPED;
   10524                 :            : 
   10525                 :            :         /* Copy cipher session parameters */
   10526         [ #  # ]:          0 :         if (td[0].aead) {
   10527                 :          0 :                 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
   10528                 :            :                        sizeof(ut_params->aead_xform));
   10529                 :          0 :                 ut_params->aead_xform.aead.key.data = td[0].key.data;
   10530                 :          0 :                 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
   10531                 :            : 
   10532                 :            :                 /* Verify crypto capabilities */
   10533         [ #  # ]:          0 :                 if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
   10534         [ #  # ]:          0 :                         if (!silent)
   10535                 :          0 :                                 RTE_LOG(INFO, USER1,
   10536                 :            :                                         "Crypto capabilities not supported\n");
   10537                 :          0 :                         return TEST_SKIPPED;
   10538                 :            :                 }
   10539         [ #  # ]:          0 :         } else if (td[0].auth_only) {
   10540                 :          0 :                 memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
   10541                 :            :                        sizeof(ut_params->auth_xform));
   10542                 :          0 :                 ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
   10543                 :            : 
   10544         [ #  # ]:          0 :                 if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
   10545         [ #  # ]:          0 :                         if (!silent)
   10546                 :          0 :                                 RTE_LOG(INFO, USER1,
   10547                 :            :                                         "Auth crypto capabilities not supported\n");
   10548                 :          0 :                         return TEST_SKIPPED;
   10549                 :            :                 }
   10550                 :            :         } else {
   10551                 :          0 :                 memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
   10552                 :            :                        sizeof(ut_params->cipher_xform));
   10553                 :          0 :                 memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
   10554                 :            :                        sizeof(ut_params->auth_xform));
   10555                 :          0 :                 ut_params->cipher_xform.cipher.key.data = td[0].key.data;
   10556                 :          0 :                 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   10557                 :          0 :                 ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
   10558                 :            : 
   10559                 :            :                 /* Verify crypto capabilities */
   10560                 :            : 
   10561         [ #  # ]:          0 :                 if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
   10562         [ #  # ]:          0 :                         if (!silent)
   10563                 :          0 :                                 RTE_LOG(INFO, USER1,
   10564                 :            :                                         "Cipher crypto capabilities not supported\n");
   10565                 :          0 :                         return TEST_SKIPPED;
   10566                 :            :                 }
   10567                 :            : 
   10568         [ #  # ]:          0 :                 if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
   10569         [ #  # ]:          0 :                         if (!silent)
   10570                 :          0 :                                 RTE_LOG(INFO, USER1,
   10571                 :            :                                         "Auth crypto capabilities not supported\n");
   10572                 :          0 :                         return TEST_SKIPPED;
   10573                 :            :                 }
   10574                 :            :         }
   10575                 :            : 
   10576         [ #  # ]:          0 :         if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
   10577                 :            :                 return TEST_SKIPPED;
   10578                 :            : 
   10579                 :          0 :         struct rte_security_session_conf sess_conf = {
   10580                 :          0 :                 .action_type = ut_params->type,
   10581                 :            :                 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
   10582                 :            :         };
   10583                 :            : 
   10584         [ #  # ]:          0 :         if (td[0].aead || td[0].aes_gmac ||
   10585         [ #  # ]:          0 :                        (td[0].xform.chain.cipher.cipher.algo == RTE_CRYPTO_CIPHER_AES_CTR)) {
   10586                 :          0 :                 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
   10587                 :          0 :                 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
   10588                 :            :         }
   10589                 :            : 
   10590         [ #  # ]:          0 :         if (td[0].aead) {
   10591                 :          0 :                 sess_conf.ipsec = ipsec_xform;
   10592                 :          0 :                 sess_conf.crypto_xform = &ut_params->aead_xform;
   10593         [ #  # ]:          0 :         } else if (td[0].auth_only) {
   10594                 :          0 :                 sess_conf.ipsec = ipsec_xform;
   10595                 :          0 :                 sess_conf.crypto_xform = &ut_params->auth_xform;
   10596                 :            :         } else {
   10597                 :          0 :                 sess_conf.ipsec = ipsec_xform;
   10598         [ #  # ]:          0 :                 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
   10599                 :          0 :                         sess_conf.crypto_xform = &ut_params->cipher_xform;
   10600                 :          0 :                         ut_params->cipher_xform.next = &ut_params->auth_xform;
   10601                 :            :                 } else {
   10602                 :          0 :                         sess_conf.crypto_xform = &ut_params->auth_xform;
   10603                 :          0 :                         ut_params->auth_xform.next = &ut_params->cipher_xform;
   10604                 :            :                 }
   10605                 :            :         }
   10606                 :            : 
   10607   [ #  #  #  # ]:          0 :         if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
   10608                 :          0 :                 sess_conf.userdata = ut_params;
   10609                 :            : 
   10610                 :            :         /* Create security session */
   10611                 :          0 :         ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
   10612                 :            :                                         ts_params->session_mpool);
   10613                 :            : 
   10614         [ #  # ]:          0 :         if (ut_params->sec_session == NULL)
   10615                 :            :                 return TEST_SKIPPED;
   10616                 :            : 
   10617         [ #  # ]:          0 :         for (i = 0; i < nb_td; i++) {
   10618   [ #  #  #  # ]:          0 :                 if (flags->antireplay &&
   10619                 :            :                     (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
   10620                 :          0 :                         sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
   10621                 :          0 :                         ret = rte_security_session_update(ctx,
   10622                 :            :                                 ut_params->sec_session, &sess_conf);
   10623         [ #  # ]:          0 :                         if (ret) {
   10624                 :            :                                 printf("Could not update sequence number in "
   10625                 :            :                                        "session\n");
   10626                 :          0 :                                 return TEST_SKIPPED;
   10627                 :            :                         }
   10628                 :            :                 }
   10629                 :            : 
   10630                 :            :                 /* Copy test data before modification */
   10631                 :          0 :                 memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
   10632         [ #  # ]:          0 :                 if (test_ipsec_pkt_update(input_text, flags)) {
   10633                 :            :                         ret = TEST_FAILED;
   10634                 :          0 :                         goto mbuf_free;
   10635                 :            :                 }
   10636                 :            : 
   10637                 :            :                 /* Setup source mbuf payload */
   10638         [ #  # ]:          0 :                 if (flags->use_ext_mbuf) {
   10639                 :          0 :                         ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
   10640                 :          0 :                                         td[i].input_text.len, nb_segs, input_text);
   10641                 :            :                 } else {
   10642                 :          0 :                         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
   10643                 :          0 :                                         td[i].input_text.len, nb_segs, 0);
   10644                 :          0 :                         pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
   10645                 :            :                 }
   10646                 :            : 
   10647   [ #  #  #  # ]:          0 :                 if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
   10648                 :          0 :                         ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
   10649                 :            :                                                         ctx);
   10650                 :            :                 else
   10651                 :          0 :                         ret = test_ipsec_proto_crypto_op_enq(ts_params,
   10652                 :            :                                                              ut_params,
   10653                 :            :                                                              &ipsec_xform,
   10654                 :            :                                                              &td[i], flags,
   10655                 :            :                                                              i + 1);
   10656                 :            : 
   10657         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
   10658                 :          0 :                         goto mbuf_free;
   10659                 :            : 
   10660         [ #  # ]:          0 :                 if (res_d != NULL)
   10661                 :          0 :                         res_d_tmp = &res_d[i];
   10662                 :            : 
   10663                 :          0 :                 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
   10664                 :            :                                               res_d_tmp, silent, flags);
   10665         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
   10666                 :          0 :                         goto mbuf_free;
   10667                 :            : 
   10668                 :          0 :                 ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
   10669                 :            :                                               flags, dir);
   10670         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
   10671                 :          0 :                         goto mbuf_free;
   10672                 :            : 
   10673                 :          0 :                 rte_pktmbuf_free(ut_params->ibuf);
   10674                 :          0 :                 ut_params->ibuf = NULL;
   10675                 :            :         }
   10676                 :            : 
   10677                 :          0 : mbuf_free:
   10678         [ #  # ]:          0 :         if (flags->use_ext_mbuf)
   10679                 :          0 :                 ext_mbuf_memzone_free(nb_segs);
   10680                 :            : 
   10681                 :          0 :         rte_pktmbuf_free(ut_params->ibuf);
   10682                 :          0 :         ut_params->ibuf = NULL;
   10683                 :            : 
   10684         [ #  # ]:          0 :         if (ut_params->sec_session)
   10685                 :          0 :                 rte_security_session_destroy(ctx, ut_params->sec_session);
   10686                 :          0 :         ut_params->sec_session = NULL;
   10687                 :            : 
   10688                 :          0 :         return ret;
   10689                 :            : }
   10690                 :            : 
   10691                 :            : static int
   10692         [ #  # ]:          0 : test_ipsec_proto_known_vec(const void *test_data)
   10693                 :            : {
   10694                 :            :         struct ipsec_test_data td_outb;
   10695                 :            :         struct ipsec_test_flags flags;
   10696                 :            : 
   10697                 :            :         memset(&flags, 0, sizeof(flags));
   10698                 :            : 
   10699                 :            :         memcpy(&td_outb, test_data, sizeof(td_outb));
   10700                 :            : 
   10701         [ #  # ]:          0 :         if (td_outb.aes_gmac || td_outb.aead ||
   10702         [ #  # ]:          0 :             ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
   10703         [ #  # ]:          0 :              (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
   10704                 :            :                 /* Disable IV gen to be able to test with known vectors */
   10705                 :          0 :                 td_outb.ipsec_xform.options.iv_gen_disable = 1;
   10706                 :            :         }
   10707                 :            : 
   10708                 :          0 :         return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
   10709                 :            : }
   10710                 :            : 
   10711                 :            : static int
   10712         [ #  # ]:          0 : test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
   10713                 :            : {
   10714                 :            :         struct ipsec_test_data td_outb;
   10715                 :            :         struct ipsec_test_flags flags;
   10716                 :            : 
   10717                 :            :         memset(&flags, 0, sizeof(flags));
   10718         [ #  # ]:          0 :         flags.use_ext_mbuf = true;
   10719                 :            : 
   10720                 :            :         memcpy(&td_outb, test_data, sizeof(td_outb));
   10721                 :            : 
   10722         [ #  # ]:          0 :         if (td_outb.aes_gmac || td_outb.aead ||
   10723         [ #  # ]:          0 :             ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
   10724         [ #  # ]:          0 :              (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
   10725                 :            :                 /* Disable IV gen to be able to test with known vectors */
   10726                 :          0 :                 td_outb.ipsec_xform.options.iv_gen_disable = 1;
   10727                 :            :         }
   10728                 :            : 
   10729                 :          0 :         return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
   10730                 :            : }
   10731                 :            : 
   10732                 :            : static int
   10733         [ #  # ]:          0 : test_ipsec_proto_known_vec_inb(const void *test_data)
   10734                 :            : {
   10735                 :            :         const struct ipsec_test_data *td = test_data;
   10736                 :            :         struct ipsec_test_flags flags;
   10737                 :            :         struct ipsec_test_data td_inb;
   10738                 :            : 
   10739                 :            :         memset(&flags, 0, sizeof(flags));
   10740                 :            : 
   10741         [ #  # ]:          0 :         if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
   10742                 :          0 :                 test_ipsec_td_in_from_out(td, &td_inb);
   10743                 :            :         else
   10744                 :            :                 memcpy(&td_inb, td, sizeof(td_inb));
   10745                 :            : 
   10746                 :          0 :         return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
   10747                 :            : }
   10748                 :            : 
   10749                 :            : static int
   10750                 :          0 : test_ipsec_proto_known_vec_fragmented(const void *test_data)
   10751                 :            : {
   10752                 :            :         struct ipsec_test_data td_outb;
   10753                 :            :         struct ipsec_test_flags flags;
   10754                 :            : 
   10755                 :            :         memset(&flags, 0, sizeof(flags));
   10756                 :          0 :         flags.fragment = true;
   10757                 :            : 
   10758                 :            :         memcpy(&td_outb, test_data, sizeof(td_outb));
   10759                 :            : 
   10760                 :            :         /* Disable IV gen to be able to test with known vectors */
   10761                 :          0 :         td_outb.ipsec_xform.options.iv_gen_disable = 1;
   10762                 :            : 
   10763                 :          0 :         return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
   10764                 :            : }
   10765                 :            : 
   10766                 :            : static int
   10767         [ #  # ]:          0 : test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
   10768                 :            : {
   10769                 :            :         const struct ipsec_test_data *td = test_data;
   10770                 :            :         struct ipsec_test_flags flags;
   10771                 :            :         struct ipsec_test_data td_inb;
   10772                 :            : 
   10773                 :            :         memset(&flags, 0, sizeof(flags));
   10774                 :          0 :         flags.rx_inject = true;
   10775                 :            : 
   10776         [ #  # ]:          0 :         if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
   10777                 :          0 :                 test_ipsec_td_in_from_out(td, &td_inb);
   10778                 :            :         else
   10779                 :            :                 memcpy(&td_inb, td, sizeof(td_inb));
   10780                 :            : 
   10781                 :          0 :         return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
   10782                 :            : }
   10783                 :            : 
   10784                 :            : static int
   10785                 :          0 : test_ipsec_proto_all(const struct ipsec_test_flags *flags)
   10786                 :            : {
   10787                 :            :         struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
   10788                 :            :         struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
   10789                 :            :         unsigned int i, nb_pkts = 1, pass_cnt = 0;
   10790                 :            :         int ret;
   10791                 :            : 
   10792         [ #  # ]:          0 :         if (flags->iv_gen ||
   10793         [ #  # ]:          0 :             flags->sa_expiry_pkts_soft ||
   10794                 :            :             flags->sa_expiry_pkts_hard)
   10795                 :            :                 nb_pkts = TEST_SEC_PKTS_MAX;
   10796                 :            : 
   10797         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
   10798                 :          0 :                 test_ipsec_td_prepare(sec_alg_list[i].param1,
   10799                 :            :                                       sec_alg_list[i].param2,
   10800                 :            :                                       flags,
   10801                 :            :                                       td_outb,
   10802                 :            :                                       nb_pkts);
   10803                 :            : 
   10804         [ #  # ]:          0 :                 if (!td_outb->aead) {
   10805                 :            :                         enum rte_crypto_cipher_algorithm cipher_alg;
   10806                 :            :                         enum rte_crypto_auth_algorithm auth_alg;
   10807                 :            : 
   10808                 :          0 :                         cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
   10809                 :          0 :                         auth_alg = td_outb->xform.chain.auth.auth.algo;
   10810                 :            : 
   10811   [ #  #  #  # ]:          0 :                         if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
   10812                 :          0 :                                 continue;
   10813                 :            : 
   10814                 :            :                         /* ICV is not applicable for NULL auth */
   10815   [ #  #  #  # ]:          0 :                         if (flags->icv_corrupt &&
   10816                 :            :                             auth_alg == RTE_CRYPTO_AUTH_NULL)
   10817                 :          0 :                                 continue;
   10818                 :            : 
   10819                 :            :                         /* IV is not applicable for NULL cipher */
   10820   [ #  #  #  # ]:          0 :                         if (flags->iv_gen &&
   10821                 :            :                             cipher_alg == RTE_CRYPTO_CIPHER_NULL)
   10822                 :          0 :                                 continue;
   10823                 :            :                 }
   10824                 :            : 
   10825                 :          0 :                 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
   10826                 :            :                                                flags);
   10827         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   10828                 :          0 :                         continue;
   10829                 :            : 
   10830         [ #  # ]:          0 :                 if (ret == TEST_FAILED)
   10831                 :            :                         return TEST_FAILED;
   10832                 :            : 
   10833                 :          0 :                 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
   10834                 :            : 
   10835                 :          0 :                 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
   10836                 :            :                                                flags);
   10837         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   10838                 :          0 :                         continue;
   10839                 :            : 
   10840         [ #  # ]:          0 :                 if (ret == TEST_FAILED)
   10841                 :            :                         return TEST_FAILED;
   10842                 :            : 
   10843         [ #  # ]:          0 :                 if (flags->display_alg)
   10844                 :          0 :                         test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
   10845                 :            : 
   10846                 :          0 :                 pass_cnt++;
   10847                 :            :         }
   10848                 :            : 
   10849         [ #  # ]:          0 :         if (pass_cnt > 0)
   10850                 :            :                 return TEST_SUCCESS;
   10851                 :            :         else
   10852                 :          0 :                 return TEST_SKIPPED;
   10853                 :            : }
   10854                 :            : 
   10855                 :            : static int
   10856                 :          0 : test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
   10857                 :            : {
   10858                 :            :         struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
   10859                 :            :         struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
   10860                 :            :         unsigned int i, nb_pkts = 1, pass_cnt = 0;
   10861                 :            :         int ret;
   10862                 :            : 
   10863         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
   10864                 :          0 :                 test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
   10865                 :            :                                       sec_auth_only_alg_list[i].param2,
   10866                 :            :                                       flags,
   10867                 :            :                                       td_outb,
   10868                 :            :                                       nb_pkts);
   10869                 :            : 
   10870                 :          0 :                 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
   10871                 :            :                                                flags);
   10872         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   10873                 :          0 :                         continue;
   10874                 :            : 
   10875         [ #  # ]:          0 :                 if (ret == TEST_FAILED)
   10876                 :            :                         return TEST_FAILED;
   10877                 :            : 
   10878                 :          0 :                 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
   10879                 :            : 
   10880                 :          0 :                 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
   10881                 :            :                                                flags);
   10882         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   10883                 :          0 :                         continue;
   10884                 :            : 
   10885         [ #  # ]:          0 :                 if (ret == TEST_FAILED)
   10886                 :            :                         return TEST_FAILED;
   10887                 :            : 
   10888         [ #  # ]:          0 :                 if (flags->display_alg)
   10889                 :          0 :                         test_sec_alg_display(sec_auth_only_alg_list[i].param1,
   10890                 :            :                                              sec_auth_only_alg_list[i].param2);
   10891                 :            : 
   10892                 :          0 :                 pass_cnt++;
   10893                 :            :         }
   10894                 :            : 
   10895         [ #  # ]:          0 :         if (pass_cnt > 0)
   10896                 :            :                 return TEST_SUCCESS;
   10897                 :            :         else
   10898                 :          0 :                 return TEST_SKIPPED;
   10899                 :            : }
   10900                 :            : 
   10901                 :            : static int
   10902                 :          0 : test_ipsec_proto_display_list(void)
   10903                 :            : {
   10904                 :            :         struct ipsec_test_flags flags;
   10905                 :            : 
   10906                 :            :         memset(&flags, 0, sizeof(flags));
   10907                 :            : 
   10908                 :          0 :         flags.display_alg = true;
   10909                 :            : 
   10910                 :          0 :         return test_ipsec_proto_all(&flags);
   10911                 :            : }
   10912                 :            : 
   10913                 :            : static int
   10914                 :          0 : test_ipsec_proto_ah_tunnel_ipv4(void)
   10915                 :            : {
   10916                 :            :         struct ipsec_test_flags flags;
   10917                 :            : 
   10918                 :            :         memset(&flags, 0, sizeof(flags));
   10919                 :            : 
   10920                 :          0 :         flags.ah = true;
   10921                 :          0 :         flags.display_alg = true;
   10922                 :            : 
   10923                 :          0 :         return test_ipsec_ah_proto_all(&flags);
   10924                 :            : }
   10925                 :            : 
   10926                 :            : static int
   10927                 :          0 : test_ipsec_proto_ah_transport_ipv4(void)
   10928                 :            : {
   10929                 :            :         struct ipsec_test_flags flags;
   10930                 :            : 
   10931                 :            :         memset(&flags, 0, sizeof(flags));
   10932                 :            : 
   10933                 :          0 :         flags.ah = true;
   10934                 :          0 :         flags.transport = true;
   10935                 :            : 
   10936                 :          0 :         return test_ipsec_ah_proto_all(&flags);
   10937                 :            : }
   10938                 :            : 
   10939                 :            : static int
   10940                 :          0 : test_ipsec_proto_iv_gen(void)
   10941                 :            : {
   10942                 :            :         struct ipsec_test_flags flags;
   10943                 :            : 
   10944                 :            :         memset(&flags, 0, sizeof(flags));
   10945                 :            : 
   10946                 :          0 :         flags.iv_gen = true;
   10947                 :            : 
   10948                 :          0 :         return test_ipsec_proto_all(&flags);
   10949                 :            : }
   10950                 :            : 
   10951                 :            : static int
   10952                 :          0 : test_ipsec_proto_sa_exp_pkts_soft(void)
   10953                 :            : {
   10954                 :            :         struct ipsec_test_flags flags;
   10955                 :            : 
   10956                 :            :         memset(&flags, 0, sizeof(flags));
   10957                 :            : 
   10958                 :          0 :         flags.sa_expiry_pkts_soft = true;
   10959                 :            : 
   10960                 :          0 :         return test_ipsec_proto_all(&flags);
   10961                 :            : }
   10962                 :            : 
   10963                 :            : static int
   10964                 :          0 : test_ipsec_proto_sa_exp_pkts_hard(void)
   10965                 :            : {
   10966                 :            :         struct ipsec_test_flags flags;
   10967                 :            : 
   10968                 :            :         memset(&flags, 0, sizeof(flags));
   10969                 :            : 
   10970                 :          0 :         flags.sa_expiry_pkts_hard = true;
   10971                 :            : 
   10972                 :          0 :         return test_ipsec_proto_all(&flags);
   10973                 :            : }
   10974                 :            : 
   10975                 :            : static int
   10976                 :          0 : test_ipsec_proto_err_icv_corrupt(void)
   10977                 :            : {
   10978                 :            :         struct ipsec_test_flags flags;
   10979                 :            : 
   10980                 :            :         memset(&flags, 0, sizeof(flags));
   10981                 :            : 
   10982                 :          0 :         flags.icv_corrupt = true;
   10983                 :            : 
   10984                 :          0 :         return test_ipsec_proto_all(&flags);
   10985                 :            : }
   10986                 :            : 
   10987                 :            : static int
   10988                 :          0 : test_ipsec_proto_udp_encap_custom_ports(void)
   10989                 :            : {
   10990                 :            :         struct ipsec_test_flags flags;
   10991                 :            : 
   10992         [ #  # ]:          0 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   10993                 :            :                         RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
   10994                 :            :                 return TEST_SKIPPED;
   10995                 :            : 
   10996                 :            :         memset(&flags, 0, sizeof(flags));
   10997                 :            : 
   10998                 :          0 :         flags.udp_encap = true;
   10999                 :          0 :         flags.udp_encap_custom_ports = true;
   11000                 :            : 
   11001                 :          0 :         return test_ipsec_proto_all(&flags);
   11002                 :            : }
   11003                 :            : 
   11004                 :            : static int
   11005                 :          0 : test_ipsec_proto_udp_encap(void)
   11006                 :            : {
   11007                 :            :         struct ipsec_test_flags flags;
   11008                 :            : 
   11009                 :            :         memset(&flags, 0, sizeof(flags));
   11010                 :            : 
   11011                 :          0 :         flags.udp_encap = true;
   11012                 :            : 
   11013                 :          0 :         return test_ipsec_proto_all(&flags);
   11014                 :            : }
   11015                 :            : 
   11016                 :            : static int
   11017                 :          0 : test_ipsec_proto_tunnel_src_dst_addr_verify(void)
   11018                 :            : {
   11019                 :            :         struct ipsec_test_flags flags;
   11020                 :            : 
   11021                 :            :         memset(&flags, 0, sizeof(flags));
   11022                 :            : 
   11023                 :          0 :         flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
   11024                 :            : 
   11025                 :          0 :         return test_ipsec_proto_all(&flags);
   11026                 :            : }
   11027                 :            : 
   11028                 :            : static int
   11029                 :          0 : test_ipsec_proto_tunnel_dst_addr_verify(void)
   11030                 :            : {
   11031                 :            :         struct ipsec_test_flags flags;
   11032                 :            : 
   11033                 :            :         memset(&flags, 0, sizeof(flags));
   11034                 :            : 
   11035                 :          0 :         flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
   11036                 :            : 
   11037                 :          0 :         return test_ipsec_proto_all(&flags);
   11038                 :            : }
   11039                 :            : 
   11040                 :            : static int
   11041                 :          0 : test_ipsec_proto_udp_ports_verify(void)
   11042                 :            : {
   11043                 :            :         struct ipsec_test_flags flags;
   11044                 :            : 
   11045                 :            :         memset(&flags, 0, sizeof(flags));
   11046                 :            : 
   11047                 :          0 :         flags.udp_encap = true;
   11048                 :          0 :         flags.udp_ports_verify = true;
   11049                 :            : 
   11050                 :          0 :         return test_ipsec_proto_all(&flags);
   11051                 :            : }
   11052                 :            : 
   11053                 :            : static int
   11054                 :          0 : test_ipsec_proto_inner_ip_csum(void)
   11055                 :            : {
   11056                 :            :         struct ipsec_test_flags flags;
   11057                 :            : 
   11058                 :            :         memset(&flags, 0, sizeof(flags));
   11059                 :            : 
   11060                 :          0 :         flags.ip_csum = true;
   11061                 :            : 
   11062                 :          0 :         return test_ipsec_proto_all(&flags);
   11063                 :            : }
   11064                 :            : 
   11065                 :            : static int
   11066                 :          0 : test_ipsec_proto_inner_l4_csum(void)
   11067                 :            : {
   11068                 :            :         struct ipsec_test_flags flags;
   11069                 :            : 
   11070                 :            :         memset(&flags, 0, sizeof(flags));
   11071                 :            : 
   11072                 :          0 :         flags.l4_csum = true;
   11073                 :            : 
   11074                 :          0 :         return test_ipsec_proto_all(&flags);
   11075                 :            : }
   11076                 :            : 
   11077                 :            : static int
   11078                 :          0 : test_ipsec_proto_tunnel_v4_in_v4(void)
   11079                 :            : {
   11080                 :            :         struct ipsec_test_flags flags;
   11081                 :            : 
   11082                 :            :         memset(&flags, 0, sizeof(flags));
   11083                 :            : 
   11084                 :            :         flags.ipv6 = false;
   11085                 :            :         flags.tunnel_ipv6 = false;
   11086                 :            : 
   11087                 :          0 :         return test_ipsec_proto_all(&flags);
   11088                 :            : }
   11089                 :            : 
   11090                 :            : static int
   11091                 :          0 : test_ipsec_proto_tunnel_v6_in_v6(void)
   11092                 :            : {
   11093                 :            :         struct ipsec_test_flags flags;
   11094                 :            : 
   11095                 :            :         memset(&flags, 0, sizeof(flags));
   11096                 :            : 
   11097                 :          0 :         flags.ipv6 = true;
   11098                 :          0 :         flags.tunnel_ipv6 = true;
   11099                 :            : 
   11100                 :          0 :         return test_ipsec_proto_all(&flags);
   11101                 :            : }
   11102                 :            : 
   11103                 :            : static int
   11104                 :          0 : test_ipsec_proto_tunnel_v4_in_v6(void)
   11105                 :            : {
   11106                 :            :         struct ipsec_test_flags flags;
   11107                 :            : 
   11108                 :            :         memset(&flags, 0, sizeof(flags));
   11109                 :            : 
   11110                 :            :         flags.ipv6 = false;
   11111                 :          0 :         flags.tunnel_ipv6 = true;
   11112                 :            : 
   11113                 :          0 :         return test_ipsec_proto_all(&flags);
   11114                 :            : }
   11115                 :            : 
   11116                 :            : static int
   11117                 :          0 : test_ipsec_proto_tunnel_v6_in_v4(void)
   11118                 :            : {
   11119                 :            :         struct ipsec_test_flags flags;
   11120                 :            : 
   11121                 :            :         memset(&flags, 0, sizeof(flags));
   11122                 :            : 
   11123                 :          0 :         flags.ipv6 = true;
   11124                 :            :         flags.tunnel_ipv6 = false;
   11125                 :            : 
   11126                 :          0 :         return test_ipsec_proto_all(&flags);
   11127                 :            : }
   11128                 :            : 
   11129                 :            : static int
   11130                 :          0 : test_ipsec_proto_transport_v4(void)
   11131                 :            : {
   11132                 :            :         struct ipsec_test_flags flags;
   11133                 :            : 
   11134                 :            :         memset(&flags, 0, sizeof(flags));
   11135                 :            : 
   11136                 :            :         flags.ipv6 = false;
   11137                 :          0 :         flags.transport = true;
   11138                 :            : 
   11139                 :          0 :         return test_ipsec_proto_all(&flags);
   11140                 :            : }
   11141                 :            : 
   11142                 :            : static int
   11143                 :          0 : test_ipsec_proto_transport_l4_csum(void)
   11144                 :            : {
   11145                 :          0 :         struct ipsec_test_flags flags = {
   11146                 :            :                 .l4_csum = true,
   11147                 :            :                 .transport = true,
   11148                 :            :         };
   11149                 :            : 
   11150                 :          0 :         return test_ipsec_proto_all(&flags);
   11151                 :            : }
   11152                 :            : 
   11153                 :            : static int
   11154                 :          0 : test_ipsec_proto_stats(void)
   11155                 :            : {
   11156                 :            :         struct ipsec_test_flags flags;
   11157                 :            : 
   11158                 :            :         memset(&flags, 0, sizeof(flags));
   11159                 :            : 
   11160                 :          0 :         flags.stats_success = true;
   11161                 :            : 
   11162                 :          0 :         return test_ipsec_proto_all(&flags);
   11163                 :            : }
   11164                 :            : 
   11165                 :            : static int
   11166                 :          0 : test_ipsec_proto_pkt_fragment(void)
   11167                 :            : {
   11168                 :            :         struct ipsec_test_flags flags;
   11169                 :            : 
   11170                 :            :         memset(&flags, 0, sizeof(flags));
   11171                 :            : 
   11172                 :          0 :         flags.fragment = true;
   11173                 :            : 
   11174                 :          0 :         return test_ipsec_proto_all(&flags);
   11175                 :            : 
   11176                 :            : }
   11177                 :            : 
   11178                 :            : static int
   11179                 :          0 : test_ipsec_proto_copy_df_inner_0(void)
   11180                 :            : {
   11181                 :            :         struct ipsec_test_flags flags;
   11182                 :            : 
   11183                 :            :         memset(&flags, 0, sizeof(flags));
   11184                 :            : 
   11185                 :          0 :         flags.df = TEST_IPSEC_COPY_DF_INNER_0;
   11186                 :            : 
   11187                 :          0 :         return test_ipsec_proto_all(&flags);
   11188                 :            : }
   11189                 :            : 
   11190                 :            : static int
   11191                 :          0 : test_ipsec_proto_copy_df_inner_1(void)
   11192                 :            : {
   11193                 :            :         struct ipsec_test_flags flags;
   11194                 :            : 
   11195                 :            :         memset(&flags, 0, sizeof(flags));
   11196                 :            : 
   11197                 :          0 :         flags.df = TEST_IPSEC_COPY_DF_INNER_1;
   11198                 :            : 
   11199                 :          0 :         return test_ipsec_proto_all(&flags);
   11200                 :            : }
   11201                 :            : 
   11202                 :            : static int
   11203                 :          0 : test_ipsec_proto_set_df_0_inner_1(void)
   11204                 :            : {
   11205                 :            :         struct ipsec_test_flags flags;
   11206                 :            : 
   11207                 :            :         memset(&flags, 0, sizeof(flags));
   11208                 :            : 
   11209                 :          0 :         flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
   11210                 :            : 
   11211                 :          0 :         return test_ipsec_proto_all(&flags);
   11212                 :            : }
   11213                 :            : 
   11214                 :            : static int
   11215                 :          0 : test_ipsec_proto_set_df_1_inner_0(void)
   11216                 :            : {
   11217                 :            :         struct ipsec_test_flags flags;
   11218                 :            : 
   11219                 :            :         memset(&flags, 0, sizeof(flags));
   11220                 :            : 
   11221                 :          0 :         flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
   11222                 :            : 
   11223                 :          0 :         return test_ipsec_proto_all(&flags);
   11224                 :            : }
   11225                 :            : 
   11226                 :            : static int
   11227                 :          0 : test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
   11228                 :            : {
   11229                 :            :         struct ipsec_test_flags flags;
   11230                 :            : 
   11231                 :            :         memset(&flags, 0, sizeof(flags));
   11232                 :            : 
   11233                 :          0 :         flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
   11234                 :            : 
   11235                 :          0 :         return test_ipsec_proto_all(&flags);
   11236                 :            : }
   11237                 :            : 
   11238                 :            : static int
   11239                 :          0 : test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
   11240                 :            : {
   11241                 :            :         struct ipsec_test_flags flags;
   11242                 :            : 
   11243                 :            :         memset(&flags, 0, sizeof(flags));
   11244                 :            : 
   11245                 :          0 :         flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
   11246                 :            : 
   11247                 :          0 :         return test_ipsec_proto_all(&flags);
   11248                 :            : }
   11249                 :            : 
   11250                 :            : static int
   11251                 :          0 : test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
   11252                 :            : {
   11253                 :            :         struct ipsec_test_flags flags;
   11254                 :            : 
   11255         [ #  # ]:          0 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   11256                 :            :                         RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
   11257                 :            :                 return TEST_SKIPPED;
   11258                 :            : 
   11259                 :            :         memset(&flags, 0, sizeof(flags));
   11260                 :            : 
   11261                 :          0 :         flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
   11262                 :            : 
   11263                 :          0 :         return test_ipsec_proto_all(&flags);
   11264                 :            : }
   11265                 :            : 
   11266                 :            : static int
   11267                 :          0 : test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
   11268                 :            : {
   11269                 :            :         struct ipsec_test_flags flags;
   11270                 :            : 
   11271         [ #  # ]:          0 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   11272                 :            :                         RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
   11273                 :            :                 return TEST_SKIPPED;
   11274                 :            : 
   11275                 :            :         memset(&flags, 0, sizeof(flags));
   11276                 :            : 
   11277                 :          0 :         flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
   11278                 :            : 
   11279                 :          0 :         return test_ipsec_proto_all(&flags);
   11280                 :            : }
   11281                 :            : 
   11282                 :            : static int
   11283                 :          0 : test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
   11284                 :            : {
   11285                 :            :         struct ipsec_test_flags flags;
   11286                 :            : 
   11287                 :            :         memset(&flags, 0, sizeof(flags));
   11288                 :            : 
   11289                 :          0 :         flags.ipv6 = true;
   11290                 :          0 :         flags.tunnel_ipv6 = true;
   11291                 :          0 :         flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
   11292                 :            : 
   11293                 :          0 :         return test_ipsec_proto_all(&flags);
   11294                 :            : }
   11295                 :            : 
   11296                 :            : static int
   11297                 :          0 : test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
   11298                 :            : {
   11299                 :            :         struct ipsec_test_flags flags;
   11300                 :            : 
   11301                 :            :         memset(&flags, 0, sizeof(flags));
   11302                 :            : 
   11303                 :          0 :         flags.ipv6 = true;
   11304                 :          0 :         flags.tunnel_ipv6 = true;
   11305                 :          0 :         flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
   11306                 :            : 
   11307                 :          0 :         return test_ipsec_proto_all(&flags);
   11308                 :            : }
   11309                 :            : 
   11310                 :            : static int
   11311                 :          0 : test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
   11312                 :            : {
   11313                 :            :         struct ipsec_test_flags flags;
   11314                 :            : 
   11315         [ #  # ]:          0 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   11316                 :            :                         RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
   11317                 :            :                 return TEST_SKIPPED;
   11318                 :            : 
   11319                 :            :         memset(&flags, 0, sizeof(flags));
   11320                 :            : 
   11321                 :          0 :         flags.ipv6 = true;
   11322                 :          0 :         flags.tunnel_ipv6 = true;
   11323                 :          0 :         flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
   11324                 :            : 
   11325                 :          0 :         return test_ipsec_proto_all(&flags);
   11326                 :            : }
   11327                 :            : 
   11328                 :            : static int
   11329                 :          0 : test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
   11330                 :            : {
   11331                 :            :         struct ipsec_test_flags flags;
   11332                 :            : 
   11333         [ #  # ]:          0 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   11334                 :            :                         RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
   11335                 :            :                 return TEST_SKIPPED;
   11336                 :            : 
   11337                 :            :         memset(&flags, 0, sizeof(flags));
   11338                 :            : 
   11339                 :          0 :         flags.ipv6 = true;
   11340                 :          0 :         flags.tunnel_ipv6 = true;
   11341                 :          0 :         flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
   11342                 :            : 
   11343                 :          0 :         return test_ipsec_proto_all(&flags);
   11344                 :            : }
   11345                 :            : 
   11346                 :            : static int
   11347                 :          0 : test_ipsec_proto_sgl(void)
   11348                 :            : {
   11349                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   11350                 :            :         struct rte_cryptodev_info dev_info;
   11351                 :            : 
   11352                 :          0 :         struct ipsec_test_flags flags = {
   11353                 :            :                 .nb_segs_in_mbuf = 5
   11354                 :            :         };
   11355                 :            : 
   11356                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   11357         [ #  # ]:          0 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
   11358                 :            :                 printf("Device doesn't support in-place scatter-gather. "
   11359                 :            :                                 "Test Skipped.\n");
   11360                 :          0 :                 return TEST_SKIPPED;
   11361                 :            :         }
   11362                 :            : 
   11363                 :          0 :         return test_ipsec_proto_all(&flags);
   11364                 :            : }
   11365                 :            : 
   11366                 :            : static int
   11367                 :          0 : test_ipsec_proto_sgl_ext_mbuf(void)
   11368                 :            : {
   11369                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   11370                 :            :         struct rte_cryptodev_info dev_info;
   11371                 :            : 
   11372                 :          0 :         struct ipsec_test_flags flags = {
   11373                 :            :                 .nb_segs_in_mbuf = 5,
   11374                 :            :                 .use_ext_mbuf = 1
   11375                 :            :         };
   11376                 :            : 
   11377                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   11378         [ #  # ]:          0 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
   11379                 :            :                 printf("Device doesn't support in-place scatter-gather. "
   11380                 :            :                                 "Test Skipped.\n");
   11381                 :          0 :                 return TEST_SKIPPED;
   11382                 :            :         }
   11383                 :            : 
   11384                 :          0 :         return test_ipsec_proto_all(&flags);
   11385                 :            : }
   11386                 :            : 
   11387                 :            : static int
   11388                 :          0 : test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
   11389                 :            :                       bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
   11390                 :            :                       uint64_t winsz)
   11391                 :            : {
   11392                 :            :         struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
   11393                 :            :         struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
   11394                 :            :         struct ipsec_test_flags flags;
   11395                 :            :         uint32_t i = 0, ret = 0;
   11396                 :            : 
   11397         [ #  # ]:          0 :         if (nb_pkts == 0)
   11398                 :            :                 return TEST_FAILED;
   11399                 :            : 
   11400                 :            :         memset(&flags, 0, sizeof(flags));
   11401                 :          0 :         flags.antireplay = true;
   11402                 :            : 
   11403         [ #  # ]:          0 :         for (i = 0; i < nb_pkts; i++) {
   11404                 :          0 :                 memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
   11405                 :          0 :                 td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
   11406                 :          0 :                 td_outb[i].ipsec_xform.replay_win_sz = winsz;
   11407                 :          0 :                 td_outb[i].ipsec_xform.options.esn = esn_en;
   11408                 :            :         }
   11409                 :            : 
   11410         [ #  # ]:          0 :         for (i = 0; i < nb_pkts; i++)
   11411                 :          0 :                 td_outb[i].ipsec_xform.esn.value = esn[i];
   11412                 :            : 
   11413                 :          0 :         ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
   11414                 :            :                                        &flags);
   11415         [ #  # ]:          0 :         if (ret != TEST_SUCCESS)
   11416                 :            :                 return ret;
   11417                 :            : 
   11418                 :          0 :         test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
   11419                 :            : 
   11420         [ #  # ]:          0 :         for (i = 0; i < nb_pkts; i++) {
   11421                 :          0 :                 td_inb[i].ipsec_xform.options.esn = esn_en;
   11422                 :            :                 /* Set antireplay flag for packets to be dropped */
   11423                 :          0 :                 td_inb[i].ar_packet = replayed_pkt[i];
   11424                 :            :         }
   11425                 :            : 
   11426                 :          0 :         ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
   11427                 :            :                                        &flags);
   11428                 :            : 
   11429                 :          0 :         return ret;
   11430                 :            : }
   11431                 :            : 
   11432                 :            : static int
   11433                 :          0 : test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
   11434                 :            : {
   11435                 :            : 
   11436                 :            :         uint32_t nb_pkts = 5;
   11437                 :            :         bool replayed_pkt[5];
   11438                 :            :         uint64_t esn[5];
   11439                 :            : 
   11440                 :            :         /* 1. Advance the TOP of the window to WS * 2 */
   11441                 :          0 :         esn[0] = winsz * 2;
   11442                 :            :         /* 2. Test sequence number within the new window(WS + 1) */
   11443                 :          0 :         esn[1] = winsz + 1;
   11444                 :            :         /* 3. Test sequence number less than the window BOTTOM */
   11445                 :          0 :         esn[2] = winsz;
   11446                 :            :         /* 4. Test sequence number in the middle of the window */
   11447                 :          0 :         esn[3] = winsz + (winsz / 2);
   11448                 :            :         /* 5. Test replay of the packet in the middle of the window */
   11449                 :          0 :         esn[4] = winsz + (winsz / 2);
   11450                 :            : 
   11451                 :          0 :         replayed_pkt[0] = false;
   11452                 :          0 :         replayed_pkt[1] = false;
   11453                 :          0 :         replayed_pkt[2] = true;
   11454                 :          0 :         replayed_pkt[3] = false;
   11455                 :          0 :         replayed_pkt[4] = true;
   11456                 :            : 
   11457                 :          0 :         return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
   11458                 :            :                                      false, winsz);
   11459                 :            : }
   11460                 :            : 
   11461                 :            : static int
   11462                 :          0 : test_ipsec_proto_pkt_antireplay1024(const void *test_data)
   11463                 :            : {
   11464                 :          0 :         return test_ipsec_proto_pkt_antireplay(test_data, 1024);
   11465                 :            : }
   11466                 :            : 
   11467                 :            : static int
   11468                 :          0 : test_ipsec_proto_pkt_antireplay2048(const void *test_data)
   11469                 :            : {
   11470                 :          0 :         return test_ipsec_proto_pkt_antireplay(test_data, 2048);
   11471                 :            : }
   11472                 :            : 
   11473                 :            : static int
   11474                 :          0 : test_ipsec_proto_pkt_antireplay4096(const void *test_data)
   11475                 :            : {
   11476                 :          0 :         return test_ipsec_proto_pkt_antireplay(test_data, 4096);
   11477                 :            : }
   11478                 :            : 
   11479                 :            : static int
   11480                 :          0 : test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
   11481                 :            : {
   11482                 :            : 
   11483                 :            :         uint32_t nb_pkts = 7;
   11484                 :            :         bool replayed_pkt[7];
   11485                 :            :         uint64_t esn[7];
   11486                 :            : 
   11487                 :            :         /* Set the initial sequence number */
   11488                 :          0 :         esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
   11489                 :            :         /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
   11490                 :          0 :         esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
   11491                 :            :         /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
   11492                 :          0 :         esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
   11493                 :            :         /* 3. Test with sequence number within window (1<<32 - 1) */
   11494                 :          0 :         esn[3] = (uint64_t)((1ULL << 32) - 1);
   11495                 :            :         /* 4. Test with sequence number within window (1<<32 - 1) */
   11496                 :          0 :         esn[4] = (uint64_t)(1ULL << 32);
   11497                 :            :         /* 5. Test with duplicate sequence number within
   11498                 :            :          * new window (1<<32 - 1)
   11499                 :            :          */
   11500                 :          0 :         esn[5] = (uint64_t)((1ULL << 32) - 1);
   11501                 :            :         /* 6. Test with duplicate sequence number within new window (1<<32) */
   11502                 :          0 :         esn[6] = (uint64_t)(1ULL << 32);
   11503                 :            : 
   11504                 :          0 :         replayed_pkt[0] = false;
   11505                 :          0 :         replayed_pkt[1] = false;
   11506                 :          0 :         replayed_pkt[2] = false;
   11507                 :          0 :         replayed_pkt[3] = false;
   11508                 :          0 :         replayed_pkt[4] = false;
   11509                 :          0 :         replayed_pkt[5] = true;
   11510                 :          0 :         replayed_pkt[6] = true;
   11511                 :            : 
   11512                 :          0 :         return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
   11513                 :            :                                      true, winsz);
   11514                 :            : }
   11515                 :            : 
   11516                 :            : static int
   11517                 :          0 : test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
   11518                 :            : {
   11519                 :          0 :         return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
   11520                 :            : }
   11521                 :            : 
   11522                 :            : static int
   11523                 :          0 : test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
   11524                 :            : {
   11525                 :          0 :         return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
   11526                 :            : }
   11527                 :            : 
   11528                 :            : static int
   11529                 :          0 : test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
   11530                 :            : {
   11531                 :          0 :         return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
   11532                 :            : }
   11533                 :            : 
   11534                 :            : static int
   11535                 :          0 : test_PDCP_PROTO_all(void)
   11536                 :            : {
   11537                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   11538                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   11539                 :            :         struct rte_cryptodev_info dev_info;
   11540                 :            :         int status;
   11541                 :            : 
   11542                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   11543                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
   11544                 :            : 
   11545         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
   11546                 :            :                 return TEST_SKIPPED;
   11547                 :            : 
   11548                 :            :         /* Set action type */
   11549                 :          0 :         ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
   11550         [ #  # ]:          0 :                 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
   11551                 :            :                 gbl_action_type;
   11552                 :            : 
   11553         [ #  # ]:          0 :         if (security_proto_supported(ut_params->type,
   11554                 :            :                         RTE_SECURITY_PROTOCOL_PDCP) < 0)
   11555                 :            :                 return TEST_SKIPPED;
   11556                 :            : 
   11557                 :          0 :         status = test_PDCP_PROTO_cplane_encap_all();
   11558                 :          0 :         status += test_PDCP_PROTO_cplane_decap_all();
   11559                 :          0 :         status += test_PDCP_PROTO_uplane_encap_all();
   11560                 :          0 :         status += test_PDCP_PROTO_uplane_decap_all();
   11561                 :          0 :         status += test_PDCP_PROTO_SGL_in_place_32B();
   11562                 :          0 :         status += test_PDCP_PROTO_SGL_oop_32B_128B();
   11563                 :          0 :         status += test_PDCP_PROTO_SGL_oop_32B_40B();
   11564                 :          0 :         status += test_PDCP_PROTO_SGL_oop_128B_32B();
   11565                 :          0 :         status += test_PDCP_SDAP_PROTO_encap_all();
   11566                 :          0 :         status += test_PDCP_SDAP_PROTO_decap_all();
   11567                 :          0 :         status += test_PDCP_PROTO_short_mac();
   11568                 :            : 
   11569         [ #  # ]:          0 :         if (status)
   11570                 :            :                 return TEST_FAILED;
   11571                 :            :         else
   11572                 :          0 :                 return TEST_SUCCESS;
   11573                 :            : }
   11574                 :            : 
   11575                 :            : static int
   11576                 :          0 : test_ipsec_proto_ipv4_ttl_decrement(void)
   11577                 :            : {
   11578                 :          0 :         struct ipsec_test_flags flags = {
   11579                 :            :                 .dec_ttl_or_hop_limit = true
   11580                 :            :         };
   11581                 :            : 
   11582                 :          0 :         return test_ipsec_proto_all(&flags);
   11583                 :            : }
   11584                 :            : 
   11585                 :            : static int
   11586                 :          0 : test_ipsec_proto_ipv6_hop_limit_decrement(void)
   11587                 :            : {
   11588                 :          0 :         struct ipsec_test_flags flags = {
   11589                 :            :                 .ipv6 = true,
   11590                 :            :                 .dec_ttl_or_hop_limit = true
   11591                 :            :         };
   11592                 :            : 
   11593                 :          0 :         return test_ipsec_proto_all(&flags);
   11594                 :            : }
   11595                 :            : 
   11596                 :            : static int
   11597                 :          0 : test_docsis_proto_uplink(const void *data)
   11598                 :            : {
   11599                 :            :         const struct docsis_test_data *d_td = data;
   11600                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   11601                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   11602                 :            :         uint8_t *plaintext = NULL;
   11603                 :            :         uint8_t *ciphertext = NULL;
   11604                 :            :         uint8_t *iv_ptr;
   11605                 :            :         int32_t cipher_len, crc_len;
   11606                 :            :         uint32_t crc_data_len;
   11607                 :            :         int ret = TEST_SUCCESS;
   11608                 :            : 
   11609                 :          0 :         void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
   11610                 :            : 
   11611                 :            :         /* Verify the capabilities */
   11612                 :            :         struct rte_security_capability_idx sec_cap_idx;
   11613                 :            :         const struct rte_security_capability *sec_cap;
   11614                 :            :         const struct rte_cryptodev_capabilities *crypto_cap;
   11615                 :            :         const struct rte_cryptodev_symmetric_capability *sym_cap;
   11616                 :            :         int j = 0;
   11617                 :            : 
   11618                 :            :         /* Set action type */
   11619                 :          0 :         ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
   11620         [ #  # ]:          0 :                 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
   11621                 :            :                 gbl_action_type;
   11622                 :            : 
   11623         [ #  # ]:          0 :         if (security_proto_supported(ut_params->type,
   11624                 :            :                         RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
   11625                 :            :                 return TEST_SKIPPED;
   11626                 :            : 
   11627                 :          0 :         sec_cap_idx.action = ut_params->type;
   11628                 :          0 :         sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
   11629                 :          0 :         sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
   11630                 :            : 
   11631                 :          0 :         sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
   11632         [ #  # ]:          0 :         if (sec_cap == NULL)
   11633                 :            :                 return TEST_SKIPPED;
   11634                 :            : 
   11635         [ #  # ]:          0 :         while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
   11636                 :            :                         RTE_CRYPTO_OP_TYPE_UNDEFINED) {
   11637         [ #  # ]:          0 :                 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
   11638                 :            :                                 crypto_cap->sym.xform_type ==
   11639         [ #  # ]:          0 :                                         RTE_CRYPTO_SYM_XFORM_CIPHER &&
   11640                 :            :                                 crypto_cap->sym.cipher.algo ==
   11641                 :            :                                         RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
   11642                 :          0 :                         sym_cap = &crypto_cap->sym;
   11643         [ #  # ]:          0 :                         if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
   11644                 :          0 :                                                 d_td->key.len,
   11645                 :          0 :                                                 d_td->iv.len) == 0)
   11646                 :            :                                 break;
   11647                 :            :                 }
   11648                 :            :         }
   11649                 :            : 
   11650         [ #  # ]:          0 :         if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
   11651                 :            :                 return TEST_SKIPPED;
   11652                 :            : 
   11653                 :            :         /* Setup source mbuf payload */
   11654                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   11655                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   11656                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   11657                 :            : 
   11658                 :          0 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   11659                 :          0 :                         d_td->ciphertext.len);
   11660                 :            : 
   11661                 :          0 :         memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
   11662                 :            : 
   11663                 :            :         /* Setup cipher session parameters */
   11664                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   11665                 :          0 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
   11666                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
   11667                 :          0 :         ut_params->cipher_xform.cipher.key.data = d_td->key.data;
   11668                 :          0 :         ut_params->cipher_xform.cipher.key.length = d_td->key.len;
   11669                 :          0 :         ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
   11670                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   11671                 :          0 :         ut_params->cipher_xform.next = NULL;
   11672                 :            : 
   11673                 :            :         /* Setup DOCSIS session parameters */
   11674                 :          0 :         ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
   11675                 :            : 
   11676                 :          0 :         struct rte_security_session_conf sess_conf = {
   11677                 :          0 :                 .action_type = ut_params->type,
   11678                 :            :                 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
   11679                 :            :                 .docsis = ut_params->docsis_xform,
   11680                 :            :                 .crypto_xform = &ut_params->cipher_xform,
   11681                 :            :         };
   11682                 :            : 
   11683                 :            :         /* Create security session */
   11684                 :          0 :         ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
   11685                 :            :                                         ts_params->session_mpool);
   11686                 :            : 
   11687         [ #  # ]:          0 :         if (!ut_params->sec_session) {
   11688                 :            :                 printf("Test function %s line %u: failed to allocate session\n",
   11689                 :            :                         __func__, __LINE__);
   11690                 :            :                 ret = TEST_FAILED;
   11691                 :          0 :                 goto on_err;
   11692                 :            :         }
   11693                 :            : 
   11694                 :            :         /* Generate crypto op data structure */
   11695                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   11696                 :            :                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   11697         [ #  # ]:          0 :         if (!ut_params->op) {
   11698                 :            :                 printf("Test function %s line %u: failed to allocate symmetric "
   11699                 :            :                         "crypto operation\n", __func__, __LINE__);
   11700                 :            :                 ret = TEST_FAILED;
   11701                 :          0 :                 goto on_err;
   11702                 :            :         }
   11703                 :            : 
   11704                 :            :         /* Setup CRC operation parameters */
   11705                 :          0 :         crc_len = d_td->ciphertext.no_crc == false ?
   11706                 :          0 :                         (d_td->ciphertext.len -
   11707                 :          0 :                                 d_td->ciphertext.crc_offset -
   11708         [ #  # ]:          0 :                                 RTE_ETHER_CRC_LEN) :
   11709                 :            :                         0;
   11710                 :          0 :         crc_len = crc_len > 0 ? crc_len : 0;
   11711         [ #  # ]:          0 :         crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
   11712                 :          0 :         ut_params->op->sym->auth.data.length = crc_len;
   11713                 :          0 :         ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
   11714                 :            : 
   11715                 :            :         /* Setup cipher operation parameters */
   11716                 :          0 :         cipher_len = d_td->ciphertext.no_cipher == false ?
   11717                 :          0 :                         (d_td->ciphertext.len -
   11718         [ #  # ]:          0 :                                 d_td->ciphertext.cipher_offset) :
   11719                 :            :                         0;
   11720                 :          0 :         cipher_len = cipher_len > 0 ? cipher_len : 0;
   11721                 :          0 :         ut_params->op->sym->cipher.data.length = cipher_len;
   11722                 :          0 :         ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
   11723                 :            : 
   11724                 :            :         /* Setup cipher IV */
   11725                 :          0 :         iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
   11726         [ #  # ]:          0 :         rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
   11727                 :            : 
   11728                 :            :         /* Attach session to operation */
   11729         [ #  # ]:          0 :         rte_security_attach_session(ut_params->op, ut_params->sec_session);
   11730                 :            : 
   11731                 :            :         /* Set crypto operation mbufs */
   11732                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
   11733                 :          0 :         ut_params->op->sym->m_dst = NULL;
   11734                 :            : 
   11735                 :            :         /* Process crypto operation */
   11736         [ #  # ]:          0 :         if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
   11737                 :            :                         NULL) {
   11738                 :            :                 printf("Test function %s line %u: failed to process security "
   11739                 :            :                         "crypto op\n", __func__, __LINE__);
   11740                 :            :                 ret = TEST_FAILED;
   11741                 :          0 :                 goto on_err;
   11742                 :            :         }
   11743                 :            : 
   11744         [ #  # ]:          0 :         if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
   11745                 :            :                 printf("Test function %s line %u: failed to process crypto op\n",
   11746                 :            :                         __func__, __LINE__);
   11747                 :            :                 ret = TEST_FAILED;
   11748                 :          0 :                 goto on_err;
   11749                 :            :         }
   11750                 :            : 
   11751                 :            :         /* Validate plaintext */
   11752                 :            :         plaintext = ciphertext;
   11753                 :            : 
   11754                 :          0 :         if (memcmp(plaintext, d_td->plaintext.data,
   11755         [ #  # ]:          0 :                         d_td->plaintext.len - crc_data_len)) {
   11756                 :            :                 printf("Test function %s line %u: plaintext not as expected\n",
   11757                 :            :                         __func__, __LINE__);
   11758                 :          0 :                 rte_hexdump(stdout, "expected", d_td->plaintext.data,
   11759                 :          0 :                                 d_td->plaintext.len);
   11760                 :          0 :                 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
   11761                 :            :                 ret = TEST_FAILED;
   11762                 :          0 :                 goto on_err;
   11763                 :            :         }
   11764                 :            : 
   11765                 :          0 : on_err:
   11766                 :          0 :         rte_crypto_op_free(ut_params->op);
   11767                 :          0 :         ut_params->op = NULL;
   11768                 :            : 
   11769         [ #  # ]:          0 :         if (ut_params->sec_session)
   11770                 :          0 :                 rte_security_session_destroy(ctx, ut_params->sec_session);
   11771                 :          0 :         ut_params->sec_session = NULL;
   11772                 :            : 
   11773                 :          0 :         rte_pktmbuf_free(ut_params->ibuf);
   11774                 :          0 :         ut_params->ibuf = NULL;
   11775                 :            : 
   11776                 :          0 :         return ret;
   11777                 :            : }
   11778                 :            : 
   11779                 :            : static int
   11780                 :          0 : test_docsis_proto_downlink(const void *data)
   11781                 :            : {
   11782                 :            :         const struct docsis_test_data *d_td = data;
   11783                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   11784                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   11785                 :            :         uint8_t *plaintext = NULL;
   11786                 :            :         uint8_t *ciphertext = NULL;
   11787                 :            :         uint8_t *iv_ptr;
   11788                 :            :         int32_t cipher_len, crc_len;
   11789                 :            :         int ret = TEST_SUCCESS;
   11790                 :            : 
   11791                 :          0 :         void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
   11792                 :            : 
   11793                 :            :         /* Verify the capabilities */
   11794                 :            :         struct rte_security_capability_idx sec_cap_idx;
   11795                 :            :         const struct rte_security_capability *sec_cap;
   11796                 :            :         const struct rte_cryptodev_capabilities *crypto_cap;
   11797                 :            :         const struct rte_cryptodev_symmetric_capability *sym_cap;
   11798                 :            :         int j = 0;
   11799                 :            : 
   11800                 :            :         /* Set action type */
   11801                 :          0 :         ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
   11802         [ #  # ]:          0 :                 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
   11803                 :            :                 gbl_action_type;
   11804                 :            : 
   11805         [ #  # ]:          0 :         if (security_proto_supported(ut_params->type,
   11806                 :            :                         RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
   11807                 :            :                 return TEST_SKIPPED;
   11808                 :            : 
   11809                 :          0 :         sec_cap_idx.action = ut_params->type;
   11810                 :          0 :         sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
   11811                 :          0 :         sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
   11812                 :            : 
   11813                 :          0 :         sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
   11814         [ #  # ]:          0 :         if (sec_cap == NULL)
   11815                 :            :                 return TEST_SKIPPED;
   11816                 :            : 
   11817         [ #  # ]:          0 :         while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
   11818                 :            :                         RTE_CRYPTO_OP_TYPE_UNDEFINED) {
   11819         [ #  # ]:          0 :                 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
   11820                 :            :                                 crypto_cap->sym.xform_type ==
   11821         [ #  # ]:          0 :                                         RTE_CRYPTO_SYM_XFORM_CIPHER &&
   11822                 :            :                                 crypto_cap->sym.cipher.algo ==
   11823                 :            :                                         RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
   11824                 :          0 :                         sym_cap = &crypto_cap->sym;
   11825         [ #  # ]:          0 :                         if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
   11826                 :          0 :                                                 d_td->key.len,
   11827                 :          0 :                                                 d_td->iv.len) == 0)
   11828                 :            :                                 break;
   11829                 :            :                 }
   11830                 :            :         }
   11831                 :            : 
   11832         [ #  # ]:          0 :         if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
   11833                 :            :                 return TEST_SKIPPED;
   11834                 :            : 
   11835                 :            :         /* Setup source mbuf payload */
   11836                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   11837                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   11838                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   11839                 :            : 
   11840                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   11841                 :          0 :                         d_td->plaintext.len);
   11842                 :            : 
   11843                 :          0 :         memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
   11844                 :            : 
   11845                 :            :         /* Setup cipher session parameters */
   11846                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   11847                 :          0 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
   11848                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
   11849                 :          0 :         ut_params->cipher_xform.cipher.key.data = d_td->key.data;
   11850                 :          0 :         ut_params->cipher_xform.cipher.key.length = d_td->key.len;
   11851                 :          0 :         ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
   11852                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   11853                 :          0 :         ut_params->cipher_xform.next = NULL;
   11854                 :            : 
   11855                 :            :         /* Setup DOCSIS session parameters */
   11856                 :          0 :         ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
   11857                 :            : 
   11858                 :          0 :         struct rte_security_session_conf sess_conf = {
   11859                 :          0 :                 .action_type = ut_params->type,
   11860                 :            :                 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
   11861                 :            :                 .docsis = ut_params->docsis_xform,
   11862                 :            :                 .crypto_xform = &ut_params->cipher_xform,
   11863                 :            :         };
   11864                 :            : 
   11865                 :            :         /* Create security session */
   11866                 :          0 :         ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
   11867                 :            :                                         ts_params->session_mpool);
   11868                 :            : 
   11869         [ #  # ]:          0 :         if (!ut_params->sec_session) {
   11870                 :            :                 printf("Test function %s line %u: failed to allocate session\n",
   11871                 :            :                         __func__, __LINE__);
   11872                 :            :                 ret = TEST_FAILED;
   11873                 :          0 :                 goto on_err;
   11874                 :            :         }
   11875                 :            : 
   11876                 :            :         /* Generate crypto op data structure */
   11877                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   11878                 :            :                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   11879         [ #  # ]:          0 :         if (!ut_params->op) {
   11880                 :            :                 printf("Test function %s line %u: failed to allocate symmetric "
   11881                 :            :                         "crypto operation\n", __func__, __LINE__);
   11882                 :            :                 ret = TEST_FAILED;
   11883                 :          0 :                 goto on_err;
   11884                 :            :         }
   11885                 :            : 
   11886                 :            :         /* Setup CRC operation parameters */
   11887                 :          0 :         crc_len = d_td->plaintext.no_crc == false ?
   11888                 :          0 :                         (d_td->plaintext.len -
   11889                 :          0 :                                 d_td->plaintext.crc_offset -
   11890         [ #  # ]:          0 :                                 RTE_ETHER_CRC_LEN) :
   11891                 :            :                         0;
   11892                 :          0 :         crc_len = crc_len > 0 ? crc_len : 0;
   11893                 :          0 :         ut_params->op->sym->auth.data.length = crc_len;
   11894                 :          0 :         ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
   11895                 :            : 
   11896                 :            :         /* Setup cipher operation parameters */
   11897                 :          0 :         cipher_len = d_td->plaintext.no_cipher == false ?
   11898                 :          0 :                         (d_td->plaintext.len -
   11899         [ #  # ]:          0 :                                 d_td->plaintext.cipher_offset) :
   11900                 :            :                         0;
   11901                 :          0 :         cipher_len = cipher_len > 0 ? cipher_len : 0;
   11902                 :          0 :         ut_params->op->sym->cipher.data.length = cipher_len;
   11903                 :          0 :         ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
   11904                 :            : 
   11905                 :            :         /* Setup cipher IV */
   11906                 :          0 :         iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
   11907         [ #  # ]:          0 :         rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
   11908                 :            : 
   11909                 :            :         /* Attach session to operation */
   11910         [ #  # ]:          0 :         rte_security_attach_session(ut_params->op, ut_params->sec_session);
   11911                 :            : 
   11912                 :            :         /* Set crypto operation mbufs */
   11913                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
   11914                 :          0 :         ut_params->op->sym->m_dst = NULL;
   11915                 :            : 
   11916                 :            :         /* Process crypto operation */
   11917         [ #  # ]:          0 :         if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
   11918                 :            :                         NULL) {
   11919                 :            :                 printf("Test function %s line %u: failed to process crypto op\n",
   11920                 :            :                         __func__, __LINE__);
   11921                 :            :                 ret = TEST_FAILED;
   11922                 :          0 :                 goto on_err;
   11923                 :            :         }
   11924                 :            : 
   11925         [ #  # ]:          0 :         if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
   11926                 :            :                 printf("Test function %s line %u: crypto op processing failed\n",
   11927                 :            :                         __func__, __LINE__);
   11928                 :            :                 ret = TEST_FAILED;
   11929                 :          0 :                 goto on_err;
   11930                 :            :         }
   11931                 :            : 
   11932                 :            :         /* Validate ciphertext */
   11933                 :            :         ciphertext = plaintext;
   11934                 :            : 
   11935         [ #  # ]:          0 :         if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
   11936                 :            :                 printf("Test function %s line %u: plaintext not as expected\n",
   11937                 :            :                         __func__, __LINE__);
   11938                 :          0 :                 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
   11939                 :          0 :                                 d_td->ciphertext.len);
   11940                 :          0 :                 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
   11941                 :            :                 ret = TEST_FAILED;
   11942                 :          0 :                 goto on_err;
   11943                 :            :         }
   11944                 :            : 
   11945                 :          0 : on_err:
   11946                 :          0 :         rte_crypto_op_free(ut_params->op);
   11947                 :          0 :         ut_params->op = NULL;
   11948                 :            : 
   11949         [ #  # ]:          0 :         if (ut_params->sec_session)
   11950                 :          0 :                 rte_security_session_destroy(ctx, ut_params->sec_session);
   11951                 :          0 :         ut_params->sec_session = NULL;
   11952                 :            : 
   11953                 :          0 :         rte_pktmbuf_free(ut_params->ibuf);
   11954                 :          0 :         ut_params->ibuf = NULL;
   11955                 :            : 
   11956                 :          0 :         return ret;
   11957                 :            : }
   11958                 :            : 
   11959                 :            : static void
   11960                 :          0 : test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
   11961                 :            :                                  struct rte_security_tls_record_xform *tls_record_xform)
   11962                 :            : {
   11963                 :            :         unsigned int imp_nonce_len;
   11964                 :            :         uint8_t *imp_nonce;
   11965                 :            : 
   11966   [ #  #  #  # ]:          0 :         switch (tls_record_xform->ver) {
   11967                 :          0 :         case RTE_SECURITY_VERSION_TLS_1_2:
   11968                 :            :                 imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
   11969                 :          0 :                 imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
   11970                 :          0 :                 break;
   11971                 :          0 :         case RTE_SECURITY_VERSION_DTLS_1_2:
   11972                 :            :                 imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
   11973                 :          0 :                 imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
   11974                 :          0 :                 break;
   11975                 :          0 :         case RTE_SECURITY_VERSION_TLS_1_3:
   11976                 :            :                 imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
   11977                 :          0 :                 imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
   11978                 :          0 :                 break;
   11979                 :            :         default:
   11980                 :            :                 return;
   11981                 :            :         }
   11982                 :            : 
   11983                 :          0 :         imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
   11984                 :          0 :         memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
   11985                 :            : }
   11986                 :            : 
   11987                 :            : static int
   11988                 :          0 : test_tls_record_proto_process(const struct tls_record_test_data td[],
   11989                 :            :                               struct tls_record_test_data res_d[], int nb_td, bool silent,
   11990                 :            :                               const struct tls_record_test_flags *flags)
   11991                 :            : {
   11992                 :          0 :         int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
   11993                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   11994                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   11995                 :            :         struct rte_security_tls_record_xform tls_record_xform;
   11996                 :            :         struct rte_security_capability_idx sec_cap_idx;
   11997                 :            :         const struct rte_security_capability *sec_cap;
   11998                 :            :         struct tls_record_test_data *res_d_tmp = NULL;
   11999                 :            :         enum rte_security_tls_sess_type sess_type;
   12000                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
   12001                 :            :         struct rte_security_ctx *ctx;
   12002                 :            :         int i, ret = TEST_SUCCESS;
   12003                 :            : 
   12004                 :          0 :         ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
   12005                 :          0 :         gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
   12006                 :            : 
   12007                 :            :         /* Use first test data to create session */
   12008                 :            : 
   12009                 :            :         /* Copy TLS record xform */
   12010                 :          0 :         memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
   12011                 :            : 
   12012                 :          0 :         sess_type = tls_record_xform.type;
   12013                 :            : 
   12014                 :          0 :         ctx = rte_cryptodev_get_sec_ctx(dev_id);
   12015                 :            : 
   12016                 :          0 :         sec_cap_idx.action = ut_params->type;
   12017                 :          0 :         sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
   12018                 :          0 :         sec_cap_idx.tls_record.type = tls_record_xform.type;
   12019                 :          0 :         sec_cap_idx.tls_record.ver = tls_record_xform.ver;
   12020                 :            : 
   12021                 :          0 :         sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
   12022         [ #  # ]:          0 :         if (sec_cap == NULL)
   12023                 :            :                 return TEST_SKIPPED;
   12024                 :            : 
   12025                 :            :         /* Copy cipher session parameters */
   12026         [ #  # ]:          0 :         if (td[0].aead) {
   12027                 :          0 :                 memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
   12028                 :          0 :                 ut_params->aead_xform.aead.key.data = td[0].key.data;
   12029                 :          0 :                 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
   12030                 :            : 
   12031                 :            :                 /* Verify crypto capabilities */
   12032         [ #  # ]:          0 :                 if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
   12033         [ #  # ]:          0 :                         if (!silent)
   12034                 :          0 :                                 RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
   12035                 :          0 :                         return TEST_SKIPPED;
   12036                 :            :                 }
   12037                 :            :         } else {
   12038                 :          0 :                 memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
   12039                 :            :                        sizeof(ut_params->cipher_xform));
   12040                 :          0 :                 memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
   12041                 :            :                        sizeof(ut_params->auth_xform));
   12042                 :          0 :                 ut_params->cipher_xform.cipher.key.data = td[0].key.data;
   12043                 :          0 :                 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   12044                 :          0 :                 ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
   12045                 :            : 
   12046                 :            :                 /* Verify crypto capabilities */
   12047                 :            : 
   12048         [ #  # ]:          0 :                 if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
   12049         [ #  # ]:          0 :                         if (!silent)
   12050                 :          0 :                                 RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
   12051                 :          0 :                         return TEST_SKIPPED;
   12052                 :            :                 }
   12053                 :            : 
   12054         [ #  # ]:          0 :                 if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
   12055         [ #  # ]:          0 :                         if (!silent)
   12056                 :          0 :                                 RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
   12057                 :          0 :                         return TEST_SKIPPED;
   12058                 :            :                 }
   12059                 :            :         }
   12060                 :            : 
   12061         [ #  # ]:          0 :         if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
   12062                 :            :                 return TEST_SKIPPED;
   12063                 :            : 
   12064                 :          0 :         struct rte_security_session_conf sess_conf = {
   12065                 :          0 :                 .action_type = ut_params->type,
   12066                 :            :                 .protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
   12067                 :            :         };
   12068                 :            : 
   12069                 :            :         if ((tls_record_xform.ver == RTE_SECURITY_VERSION_DTLS_1_2) &&
   12070                 :            :             (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ))
   12071                 :            :                 sess_conf.tls_record.dtls_1_2.ar_win_sz = flags->ar_win_size;
   12072                 :            : 
   12073         [ #  # ]:          0 :         if (td[0].aead)
   12074                 :          0 :                 test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
   12075                 :            : 
   12076         [ #  # ]:          0 :         if (flags->opt_padding)
   12077                 :          0 :                 tls_record_xform.options.extra_padding_enable = 1;
   12078                 :            : 
   12079                 :          0 :         sess_conf.tls_record = tls_record_xform;
   12080                 :            : 
   12081         [ #  # ]:          0 :         if (td[0].aead) {
   12082                 :          0 :                 sess_conf.crypto_xform = &ut_params->aead_xform;
   12083                 :            :         } else {
   12084         [ #  # ]:          0 :                 if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
   12085                 :          0 :                         sess_conf.crypto_xform = &ut_params->cipher_xform;
   12086                 :          0 :                         ut_params->cipher_xform.next = &ut_params->auth_xform;
   12087                 :            :                 } else {
   12088                 :          0 :                         sess_conf.crypto_xform = &ut_params->auth_xform;
   12089                 :          0 :                         ut_params->auth_xform.next = &ut_params->cipher_xform;
   12090                 :            :                 }
   12091                 :            :         }
   12092                 :            : 
   12093         [ #  # ]:          0 :         if (ut_params->sec_session == NULL) {
   12094                 :            :                 /* Create security session */
   12095                 :          0 :                 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
   12096                 :            :                                 ts_params->session_mpool);
   12097                 :            :         }
   12098                 :            : 
   12099         [ #  # ]:          0 :         if (ut_params->sec_session == NULL)
   12100                 :            :                 return TEST_SKIPPED;
   12101                 :            : 
   12102         [ #  # ]:          0 :         for (i = 0; i < nb_td; i++) {
   12103   [ #  #  #  # ]:          0 :                 if (flags->ar_win_size &&
   12104                 :            :                         (sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)) {
   12105                 :          0 :                         sess_conf.tls_record.dtls_1_2.seq_no =
   12106                 :          0 :                                 td[i].tls_record_xform.dtls_1_2.seq_no;
   12107                 :          0 :                         ret = rte_security_session_update(ctx, ut_params->sec_session, &sess_conf);
   12108         [ #  # ]:          0 :                         if (ret) {
   12109                 :            :                                 printf("Could not update sequence number in session\n");
   12110                 :          0 :                                 return TEST_SKIPPED;
   12111                 :            :                         }
   12112                 :            :                 }
   12113                 :            : 
   12114                 :            :                 /* Setup source mbuf payload */
   12115                 :          0 :                 ut_params->ibuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
   12116                 :          0 :                                 ts_params->large_mbuf_pool, td[i].input_text.len, nb_segs, 0);
   12117                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
   12118         [ #  # ]:          0 :                 if (flags->out_of_place)
   12119                 :          0 :                         ut_params->obuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
   12120                 :          0 :                                         ts_params->large_mbuf_pool, td[i].output_text.len, nb_segs,
   12121                 :            :                                         0);
   12122                 :            :                 else
   12123                 :          0 :                         ut_params->obuf = NULL;
   12124                 :            : 
   12125                 :            :                 /* Generate crypto op data structure */
   12126                 :          0 :                 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   12127                 :            :                                                     RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   12128         [ #  # ]:          0 :                 if (ut_params->op == NULL) {
   12129                 :            :                         printf("Could not allocate crypto op");
   12130                 :            :                         ret = TEST_FAILED;
   12131                 :          0 :                         goto crypto_op_free;
   12132                 :            :                 }
   12133                 :            : 
   12134                 :            :                 /* Attach session to operation */
   12135         [ #  # ]:          0 :                 rte_security_attach_session(ut_params->op, ut_params->sec_session);
   12136                 :            : 
   12137                 :            :                 /* Set crypto operation mbufs */
   12138                 :          0 :                 ut_params->op->sym->m_src = ut_params->ibuf;
   12139                 :          0 :                 ut_params->op->sym->m_dst = ut_params->obuf;
   12140                 :          0 :                 ut_params->op->param1.tls_record.content_type = td[i].app_type;
   12141                 :            : 
   12142         [ #  # ]:          0 :                 if (flags->opt_padding)
   12143                 :          0 :                         ut_params->op->aux_flags = flags->opt_padding;
   12144                 :            : 
   12145                 :            :                 /* Copy IV in crypto operation when IV generation is disabled */
   12146         [ #  # ]:          0 :                 if ((sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE) &&
   12147         [ #  # ]:          0 :                     (tls_record_xform.ver != RTE_SECURITY_VERSION_TLS_1_3) &&
   12148         [ #  # ]:          0 :                     (tls_record_xform.options.iv_gen_disable == 1)) {
   12149                 :            :                         uint8_t *iv;
   12150                 :            :                         int len;
   12151                 :            : 
   12152                 :          0 :                         iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
   12153         [ #  # ]:          0 :                         if (td[i].aead)
   12154                 :          0 :                                 len = td[i].xform.aead.aead.iv.length - 4;
   12155                 :            :                         else
   12156                 :          0 :                                 len = td[i].xform.chain.cipher.cipher.iv.length;
   12157                 :          0 :                         memcpy(iv, td[i].iv.data, len);
   12158                 :            :                 }
   12159                 :            : 
   12160                 :            :                 /* Process crypto operation */
   12161                 :          0 :                 process_crypto_request(dev_id, ut_params->op);
   12162                 :            : 
   12163                 :          0 :                 ret = test_tls_record_status_check(ut_params->op, &td[i]);
   12164         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
   12165                 :          0 :                         goto crypto_op_free;
   12166                 :            : 
   12167         [ #  # ]:          0 :                 if (res_d != NULL)
   12168                 :          0 :                         res_d_tmp = &res_d[i];
   12169                 :            : 
   12170         [ #  # ]:          0 :                 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
   12171         [ #  # ]:          0 :                         struct rte_mbuf *buf = flags->out_of_place ? ut_params->obuf :
   12172                 :            :                                                 ut_params->ibuf;
   12173                 :            : 
   12174                 :          0 :                         ret = test_tls_record_post_process(buf, &td[i], res_d_tmp,
   12175                 :            :                                                            silent, flags);
   12176         [ #  # ]:          0 :                         if (ret != TEST_SUCCESS)
   12177                 :          0 :                                 goto crypto_op_free;
   12178                 :            :                 }
   12179                 :            : 
   12180                 :          0 :                 rte_crypto_op_free(ut_params->op);
   12181                 :          0 :                 ut_params->op = NULL;
   12182                 :            : 
   12183         [ #  # ]:          0 :                 if (flags->out_of_place) {
   12184                 :          0 :                         rte_pktmbuf_free(ut_params->obuf);
   12185                 :          0 :                         ut_params->obuf = NULL;
   12186                 :            :                 }
   12187                 :            : 
   12188                 :          0 :                 rte_pktmbuf_free(ut_params->ibuf);
   12189                 :          0 :                 ut_params->ibuf = NULL;
   12190                 :            :         }
   12191                 :            : 
   12192                 :          0 : crypto_op_free:
   12193                 :          0 :         rte_crypto_op_free(ut_params->op);
   12194                 :          0 :         ut_params->op = NULL;
   12195                 :            : 
   12196         [ #  # ]:          0 :         if (flags->out_of_place) {
   12197                 :          0 :                 rte_pktmbuf_free(ut_params->obuf);
   12198                 :          0 :                 ut_params->obuf = NULL;
   12199                 :            :         }
   12200                 :            : 
   12201                 :          0 :         rte_pktmbuf_free(ut_params->ibuf);
   12202                 :          0 :         ut_params->ibuf = NULL;
   12203                 :            : 
   12204   [ #  #  #  # ]:          0 :         if (ut_params->sec_session != NULL && !flags->skip_sess_destroy) {
   12205                 :          0 :                 rte_security_session_destroy(ctx, ut_params->sec_session);
   12206                 :          0 :                 ut_params->sec_session = NULL;
   12207                 :            :         }
   12208                 :            : 
   12209                 :            :         RTE_SET_USED(flags);
   12210                 :            : 
   12211                 :            :         return ret;
   12212                 :            : }
   12213                 :            : 
   12214                 :            : static int
   12215                 :          0 : test_tls_record_proto_known_vec(const void *test_data)
   12216                 :            : {
   12217                 :            :         struct tls_record_test_data td_write;
   12218                 :            :         struct tls_record_test_flags flags;
   12219                 :            : 
   12220                 :            :         memset(&flags, 0, sizeof(flags));
   12221                 :            : 
   12222                 :            :         memcpy(&td_write, test_data, sizeof(td_write));
   12223                 :            : 
   12224                 :            :         /* Disable IV gen to be able to test with known vectors */
   12225                 :          0 :         td_write.tls_record_xform.options.iv_gen_disable = 1;
   12226                 :            : 
   12227                 :          0 :         return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
   12228                 :            : }
   12229                 :            : 
   12230                 :            : static int
   12231         [ #  # ]:          0 : test_tls_record_proto_known_vec_read(const void *test_data)
   12232                 :            : {
   12233                 :            :         const struct tls_record_test_data *td = test_data;
   12234                 :            :         struct tls_record_test_flags flags;
   12235                 :            :         struct tls_record_test_data td_inb;
   12236                 :            : 
   12237                 :            :         memset(&flags, 0, sizeof(flags));
   12238                 :            : 
   12239         [ #  # ]:          0 :         if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
   12240                 :          0 :                 test_tls_record_td_read_from_write(td, &td_inb);
   12241                 :            :         else
   12242                 :            :                 memcpy(&td_inb, td, sizeof(td_inb));
   12243                 :            : 
   12244                 :          0 :         return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
   12245                 :            : }
   12246                 :            : 
   12247                 :            : static int
   12248                 :          0 : test_tls_record_proto_all(const struct tls_record_test_flags *flags)
   12249                 :            : {
   12250                 :            :         unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
   12251                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   12252                 :            :         struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
   12253                 :            :         struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
   12254                 :            :         void *sec_session_outb = NULL;
   12255                 :            :         void *sec_session_inb = NULL;
   12256                 :            :         int ret;
   12257                 :            : 
   12258      [ #  #  # ]:          0 :         switch (flags->tls_version) {
   12259                 :            :         case RTE_SECURITY_VERSION_TLS_1_2:
   12260                 :            :                 max_payload_len = TLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
   12261                 :            :                 break;
   12262                 :          0 :         case RTE_SECURITY_VERSION_TLS_1_3:
   12263                 :            :                 max_payload_len = TLS_1_3_RECORD_PLAINTEXT_MAX_LEN;
   12264                 :          0 :                 break;
   12265                 :            :         case RTE_SECURITY_VERSION_DTLS_1_2:
   12266                 :            :                 max_payload_len = DTLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
   12267                 :            :                 break;
   12268                 :          0 :         default:
   12269                 :            :                 max_payload_len = 0;
   12270                 :            :         }
   12271                 :            : 
   12272         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
   12273                 :            :                 payload_len = TLS_RECORD_PLAINTEXT_MIN_LEN;
   12274         [ #  # ]:          0 :                 if (flags->nb_segs_in_mbuf)
   12275                 :          0 :                         payload_len = RTE_MAX(payload_len, flags->nb_segs_in_mbuf);
   12276                 :            : 
   12277         [ #  # ]:          0 :                 if (flags->zero_len)
   12278                 :            :                         payload_len = 0;
   12279                 :          0 : again:
   12280                 :          0 :                 ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
   12281                 :            :                                                  flags, td_outb, nb_pkts, payload_len);
   12282         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   12283                 :          0 :                         continue;
   12284                 :            : 
   12285         [ #  # ]:          0 :                 if (flags->skip_sess_destroy)
   12286                 :          0 :                         ut_params->sec_session = sec_session_outb;
   12287                 :            : 
   12288                 :          0 :                 ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
   12289         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   12290                 :          0 :                         continue;
   12291                 :            : 
   12292   [ #  #  #  # ]:          0 :                 if (flags->skip_sess_destroy && sec_session_outb == NULL)
   12293                 :          0 :                         sec_session_outb = ut_params->sec_session;
   12294                 :            : 
   12295   [ #  #  #  # ]:          0 :                 if (flags->zero_len && flags->content_type != TLS_RECORD_TEST_CONTENT_TYPE_APP) {
   12296         [ #  # ]:          0 :                         if (ret == TEST_SUCCESS)
   12297                 :            :                                 return TEST_FAILED;
   12298                 :          0 :                         goto skip_decrypt;
   12299         [ #  # ]:          0 :                 } else if (ret == TEST_FAILED) {
   12300                 :            :                         return TEST_FAILED;
   12301                 :            :                 }
   12302                 :            : 
   12303                 :          0 :                 test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
   12304                 :            : 
   12305         [ #  # ]:          0 :                 if (flags->skip_sess_destroy)
   12306                 :          0 :                         ut_params->sec_session = sec_session_inb;
   12307                 :            : 
   12308                 :          0 :                 ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
   12309         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   12310                 :          0 :                         continue;
   12311                 :            : 
   12312   [ #  #  #  # ]:          0 :                 if (flags->skip_sess_destroy && sec_session_inb == NULL)
   12313                 :          0 :                         sec_session_inb = ut_params->sec_session;
   12314                 :            : 
   12315   [ #  #  #  # ]:          0 :                 if (flags->pkt_corruption || flags->padding_corruption) {
   12316         [ #  # ]:          0 :                         if (ret == TEST_SUCCESS)
   12317                 :            :                                 return TEST_FAILED;
   12318                 :            :                 } else {
   12319         [ #  # ]:          0 :                         if (ret == TEST_FAILED)
   12320                 :            :                                 return TEST_FAILED;
   12321                 :            :                 }
   12322                 :            : 
   12323                 :          0 : skip_decrypt:
   12324   [ #  #  #  # ]:          0 :                 if (flags->data_walkthrough && (++payload_len <= max_payload_len))
   12325                 :          0 :                         goto again;
   12326                 :            : 
   12327         [ #  # ]:          0 :                 if (flags->display_alg)
   12328                 :          0 :                         test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
   12329                 :            : 
   12330         [ #  # ]:          0 :                 if (flags->skip_sess_destroy) {
   12331                 :          0 :                         uint8_t dev_id = testsuite_params.valid_devs[0];
   12332                 :            :                         struct rte_security_ctx *ctx;
   12333                 :            : 
   12334                 :          0 :                         ctx = rte_cryptodev_get_sec_ctx(dev_id);
   12335         [ #  # ]:          0 :                         if (sec_session_inb != NULL) {
   12336                 :          0 :                                 rte_security_session_destroy(ctx, sec_session_inb);
   12337                 :            :                                 sec_session_inb = NULL;
   12338                 :            :                         }
   12339         [ #  # ]:          0 :                         if (sec_session_outb != NULL) {
   12340                 :          0 :                                 rte_security_session_destroy(ctx, sec_session_outb);
   12341                 :            :                                 sec_session_outb = NULL;
   12342                 :            :                         }
   12343                 :          0 :                         ut_params->sec_session = NULL;
   12344                 :            :                 }
   12345                 :            : 
   12346                 :          0 :                 pass_cnt++;
   12347                 :            :         }
   12348                 :            : 
   12349         [ #  # ]:          0 :         if (flags->data_walkthrough)
   12350                 :            :                 printf("\t Min payload size: %d, Max payload size: %d\n",
   12351                 :            :                                 TLS_RECORD_PLAINTEXT_MIN_LEN, max_payload_len);
   12352                 :            : 
   12353         [ #  # ]:          0 :         if (pass_cnt > 0)
   12354                 :            :                 return TEST_SUCCESS;
   12355                 :            :         else
   12356                 :          0 :                 return TEST_SKIPPED;
   12357                 :            : }
   12358                 :            : 
   12359                 :            : static int
   12360                 :          0 : test_tls_1_2_record_proto_data_walkthrough(void)
   12361                 :            : {
   12362                 :            :         struct tls_record_test_flags flags;
   12363                 :            : 
   12364                 :            :         memset(&flags, 0, sizeof(flags));
   12365                 :            : 
   12366                 :          0 :         flags.data_walkthrough = true;
   12367                 :          0 :         flags.skip_sess_destroy = true;
   12368                 :            :         flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
   12369                 :            : 
   12370                 :          0 :         return test_tls_record_proto_all(&flags);
   12371                 :            : }
   12372                 :            : 
   12373                 :            : static int
   12374                 :          0 : test_tls_1_2_record_proto_display_list(void)
   12375                 :            : {
   12376                 :            :         struct tls_record_test_flags flags;
   12377                 :            : 
   12378                 :            :         memset(&flags, 0, sizeof(flags));
   12379                 :            : 
   12380                 :          0 :         flags.display_alg = true;
   12381                 :            :         flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
   12382                 :            : 
   12383                 :          0 :         return test_tls_record_proto_all(&flags);
   12384                 :            : }
   12385                 :            : 
   12386                 :            : static int
   12387                 :          0 : test_tls_record_proto_sgl(enum rte_security_tls_version tls_version)
   12388                 :            : {
   12389                 :          0 :         struct tls_record_test_flags flags = {
   12390                 :            :                 .nb_segs_in_mbuf = 5,
   12391                 :            :                 .tls_version = tls_version
   12392                 :            :         };
   12393                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12394                 :            :         struct rte_cryptodev_info dev_info;
   12395                 :            : 
   12396                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12397         [ #  # ]:          0 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
   12398                 :            :                 printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
   12399                 :          0 :                 return TEST_SKIPPED;
   12400                 :            :         }
   12401                 :            : 
   12402                 :          0 :         return test_tls_record_proto_all(&flags);
   12403                 :            : }
   12404                 :            : 
   12405                 :            : static int
   12406                 :          0 : test_tls_1_2_record_proto_sgl(void)
   12407                 :            : {
   12408                 :          0 :         return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_2);
   12409                 :            : }
   12410                 :            : 
   12411                 :            : static int
   12412                 :          0 : test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_version)
   12413                 :            : {
   12414                 :          0 :         struct tls_record_test_flags flags = {
   12415                 :            :                 .nb_segs_in_mbuf = 5,
   12416                 :            :                 .tls_version = tls_version,
   12417                 :            :                 .skip_sess_destroy = true,
   12418                 :            :                 .data_walkthrough = true
   12419                 :            :         };
   12420                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12421                 :            :         struct rte_cryptodev_info dev_info;
   12422                 :            : 
   12423                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12424         [ #  # ]:          0 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
   12425                 :            :                 printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
   12426                 :          0 :                 return TEST_SKIPPED;
   12427                 :            :         }
   12428                 :            : 
   12429                 :          0 :         return test_tls_record_proto_all(&flags);
   12430                 :            : }
   12431                 :            : 
   12432                 :            : static int
   12433                 :          0 : test_tls_record_proto_sgl_oop(enum rte_security_tls_version tls_version)
   12434                 :            : {
   12435                 :          0 :         struct tls_record_test_flags flags = {
   12436                 :            :                 .nb_segs_in_mbuf = 5,
   12437                 :            :                 .out_of_place = true,
   12438                 :            :                 .tls_version = tls_version
   12439                 :            :         };
   12440                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12441                 :            :         struct rte_cryptodev_info dev_info;
   12442                 :            : 
   12443                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12444         [ #  # ]:          0 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
   12445                 :            :                 printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
   12446                 :          0 :                 return TEST_SKIPPED;
   12447                 :            :         }
   12448                 :            : 
   12449                 :          0 :         return test_tls_record_proto_all(&flags);
   12450                 :            : }
   12451                 :            : 
   12452                 :            : static int
   12453                 :          0 : test_tls_1_2_record_proto_sgl_oop(void)
   12454                 :            : {
   12455                 :          0 :         return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_2);
   12456                 :            : }
   12457                 :            : 
   12458                 :            : static int
   12459                 :          0 : test_tls_1_2_record_proto_sgl_data_walkthrough(void)
   12460                 :            : {
   12461                 :          0 :         return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_2);
   12462                 :            : }
   12463                 :            : 
   12464                 :            : static int
   12465                 :          0 : test_tls_record_proto_corrupt_pkt(void)
   12466                 :            : {
   12467                 :          0 :         struct tls_record_test_flags flags = {
   12468                 :            :                 .pkt_corruption = 1
   12469                 :            :         };
   12470                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12471                 :            :         struct rte_cryptodev_info dev_info;
   12472                 :            : 
   12473                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12474                 :            : 
   12475                 :          0 :         return test_tls_record_proto_all(&flags);
   12476                 :            : }
   12477                 :            : 
   12478                 :            : static int
   12479                 :          0 : test_tls_record_proto_custom_content_type(void)
   12480                 :            : {
   12481                 :          0 :         struct tls_record_test_flags flags = {
   12482                 :            :                 .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM
   12483                 :            :         };
   12484                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12485                 :            :         struct rte_cryptodev_info dev_info;
   12486                 :            : 
   12487                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12488                 :            : 
   12489                 :          0 :         return test_tls_record_proto_all(&flags);
   12490                 :            : }
   12491                 :            : 
   12492                 :            : static int
   12493                 :          0 : test_tls_record_proto_zero_len(void)
   12494                 :            : {
   12495                 :          0 :         struct tls_record_test_flags flags = {
   12496                 :            :                 .zero_len = 1
   12497                 :            :         };
   12498                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12499                 :            :         struct rte_cryptodev_info dev_info;
   12500                 :            : 
   12501                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12502                 :            : 
   12503                 :          0 :         return test_tls_record_proto_all(&flags);
   12504                 :            : }
   12505                 :            : 
   12506                 :            : static int
   12507                 :          0 : test_tls_record_proto_zero_len_non_app(void)
   12508                 :            : {
   12509                 :          0 :         struct tls_record_test_flags flags = {
   12510                 :            :                 .zero_len = 1,
   12511                 :            :                 .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
   12512                 :            :         };
   12513                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12514                 :            :         struct rte_cryptodev_info dev_info;
   12515                 :            : 
   12516                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12517                 :            : 
   12518                 :          0 :         return test_tls_record_proto_all(&flags);
   12519                 :            : }
   12520                 :            : 
   12521                 :            : static int
   12522                 :          0 : test_tls_record_proto_opt_padding(uint8_t padding, uint8_t num_segs,
   12523                 :            :                                   enum rte_security_tls_version tls_version)
   12524                 :            : {
   12525                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12526                 :            :         struct rte_cryptodev_info dev_info;
   12527                 :          0 :         struct tls_record_test_flags flags = {
   12528                 :            :                 .nb_segs_in_mbuf = num_segs,
   12529                 :            :                 .tls_version = tls_version,
   12530                 :            :                 .opt_padding = padding
   12531                 :            :         };
   12532                 :            : 
   12533                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12534                 :            : 
   12535                 :          0 :         return test_tls_record_proto_all(&flags);
   12536                 :            : }
   12537                 :            : 
   12538                 :            : static int
   12539                 :          0 : test_tls_record_proto_dm_opt_padding(void)
   12540                 :            : {
   12541                 :          0 :         return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_TLS_1_2);
   12542                 :            : }
   12543                 :            : 
   12544                 :            : static int
   12545                 :          0 : test_tls_record_proto_dm_opt_padding_1(void)
   12546                 :            : {
   12547                 :          0 :         return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_TLS_1_2);
   12548                 :            : }
   12549                 :            : 
   12550                 :            : static int
   12551                 :          0 : test_tls_record_proto_sg_opt_padding(void)
   12552                 :            : {
   12553                 :          0 :         return test_tls_record_proto_opt_padding(1, 2, RTE_SECURITY_VERSION_TLS_1_2);
   12554                 :            : }
   12555                 :            : 
   12556                 :            : static int
   12557                 :          0 : test_tls_record_proto_sg_opt_padding_1(void)
   12558                 :            : {
   12559                 :          0 :         return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_TLS_1_2);
   12560                 :            : }
   12561                 :            : 
   12562                 :            : static int
   12563                 :          0 : test_tls_record_proto_sg_opt_padding_2(void)
   12564                 :            : {
   12565                 :          0 :         return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_TLS_1_2);
   12566                 :            : }
   12567                 :            : 
   12568                 :            : static int
   12569                 :          0 : test_tls_record_proto_sg_opt_padding_max(void)
   12570                 :            : {
   12571                 :          0 :         return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_TLS_1_2);
   12572                 :            : }
   12573                 :            : 
   12574                 :            : static int
   12575                 :          0 : test_tls_record_proto_sg_opt_padding_corrupt(void)
   12576                 :            : {
   12577                 :          0 :         struct tls_record_test_flags flags = {
   12578                 :            :                 .opt_padding = 8,
   12579                 :            :                 .padding_corruption = true,
   12580                 :            :                 .nb_segs_in_mbuf = 4,
   12581                 :            :         };
   12582                 :            : 
   12583                 :          0 :         return test_tls_record_proto_all(&flags);
   12584                 :            : }
   12585                 :            : 
   12586                 :            : static int
   12587                 :          0 : test_dtls_1_2_record_proto_data_walkthrough(void)
   12588                 :            : {
   12589                 :            :         struct tls_record_test_flags flags;
   12590                 :            : 
   12591                 :            :         memset(&flags, 0, sizeof(flags));
   12592                 :            : 
   12593                 :          0 :         flags.data_walkthrough = true;
   12594                 :          0 :         flags.skip_sess_destroy = true;
   12595                 :          0 :         flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
   12596                 :            : 
   12597                 :          0 :         return test_tls_record_proto_all(&flags);
   12598                 :            : }
   12599                 :            : 
   12600                 :            : static int
   12601                 :          0 : test_dtls_1_2_record_proto_display_list(void)
   12602                 :            : {
   12603                 :            :         struct tls_record_test_flags flags;
   12604                 :            : 
   12605                 :            :         memset(&flags, 0, sizeof(flags));
   12606                 :            : 
   12607                 :          0 :         flags.display_alg = true;
   12608                 :          0 :         flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
   12609                 :            : 
   12610                 :          0 :         return test_tls_record_proto_all(&flags);
   12611                 :            : }
   12612                 :            : 
   12613                 :            : static int
   12614                 :          0 : test_dtls_pkt_replay(const uint64_t seq_no[],
   12615                 :            :                       bool replayed_pkt[], uint32_t nb_pkts,
   12616                 :            :                       struct tls_record_test_flags *flags)
   12617                 :            : {
   12618                 :            :         struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
   12619                 :            :         struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
   12620                 :            :         unsigned int i, idx, pass_cnt = 0;
   12621                 :            :         int ret;
   12622                 :            : 
   12623         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
   12624                 :          0 :                 ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
   12625                 :            :                                                  flags, td_outb, nb_pkts, 0);
   12626         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   12627                 :          0 :                         continue;
   12628                 :            : 
   12629         [ #  # ]:          0 :                 for (idx = 0; idx < nb_pkts; idx++)
   12630                 :          0 :                         td_outb[idx].tls_record_xform.dtls_1_2.seq_no = seq_no[idx];
   12631                 :            : 
   12632                 :          0 :                 ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
   12633         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   12634                 :          0 :                         continue;
   12635                 :            : 
   12636         [ #  # ]:          0 :                 if (ret == TEST_FAILED)
   12637                 :            :                         return TEST_FAILED;
   12638                 :            : 
   12639                 :          0 :                 test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
   12640                 :            : 
   12641         [ #  # ]:          0 :                 for (idx = 0; idx < nb_pkts; idx++) {
   12642                 :          0 :                         td_inb[idx].tls_record_xform.dtls_1_2.ar_win_sz = flags->ar_win_size;
   12643                 :            :                         /* Set antireplay flag for packets to be dropped */
   12644                 :          0 :                         td_inb[idx].ar_packet = replayed_pkt[idx];
   12645                 :            :                 }
   12646                 :            : 
   12647                 :          0 :                 ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
   12648         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   12649                 :          0 :                         continue;
   12650                 :            : 
   12651         [ #  # ]:          0 :                 if (ret == TEST_FAILED)
   12652                 :            :                         return TEST_FAILED;
   12653                 :            : 
   12654         [ #  # ]:          0 :                 if (flags->display_alg)
   12655                 :          0 :                         test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
   12656                 :            : 
   12657                 :          0 :                 pass_cnt++;
   12658                 :            :         }
   12659                 :            : 
   12660         [ #  # ]:          0 :         if (pass_cnt > 0)
   12661                 :            :                 return TEST_SUCCESS;
   12662                 :            :         else
   12663                 :          0 :                 return TEST_SKIPPED;
   12664                 :            : }
   12665                 :            : 
   12666                 :            : static int
   12667                 :          0 : test_dtls_1_2_record_proto_antireplay(uint64_t winsz)
   12668                 :            : {
   12669                 :            :         struct tls_record_test_flags flags;
   12670                 :            :         uint32_t nb_pkts = 5;
   12671                 :            :         bool replayed_pkt[5];
   12672                 :            :         uint64_t seq_no[5];
   12673                 :            : 
   12674                 :            :         memset(&flags, 0, sizeof(flags));
   12675                 :            : 
   12676                 :          0 :         flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
   12677                 :          0 :         flags.ar_win_size = winsz;
   12678                 :            : 
   12679                 :            :         /* 1. Advance the TOP of the window to WS * 2 */
   12680                 :          0 :         seq_no[0] = winsz * 2;
   12681                 :            :         /* 2. Test sequence number within the new window(WS + 1) */
   12682                 :          0 :         seq_no[1] = winsz + 1;
   12683                 :            :         /* 3. Test sequence number less than the window BOTTOM */
   12684                 :          0 :         seq_no[2] = winsz;
   12685                 :            :         /* 4. Test sequence number in the middle of the window */
   12686                 :          0 :         seq_no[3] = winsz + (winsz / 2);
   12687                 :            :         /* 5. Test replay of the packet in the middle of the window */
   12688                 :          0 :         seq_no[4] = winsz + (winsz / 2);
   12689                 :            : 
   12690                 :          0 :         replayed_pkt[0] = false;
   12691                 :          0 :         replayed_pkt[1] = false;
   12692                 :          0 :         replayed_pkt[2] = true;
   12693                 :          0 :         replayed_pkt[3] = false;
   12694                 :          0 :         replayed_pkt[4] = true;
   12695                 :            : 
   12696                 :          0 :         return test_dtls_pkt_replay(seq_no, replayed_pkt, nb_pkts, &flags);
   12697                 :            : }
   12698                 :            : 
   12699                 :            : static int
   12700                 :          0 : test_dtls_1_2_record_proto_antireplay64(void)
   12701                 :            : {
   12702                 :          0 :         return test_dtls_1_2_record_proto_antireplay(64);
   12703                 :            : }
   12704                 :            : 
   12705                 :            : static int
   12706                 :          0 : test_dtls_1_2_record_proto_antireplay128(void)
   12707                 :            : {
   12708                 :          0 :         return test_dtls_1_2_record_proto_antireplay(128);
   12709                 :            : }
   12710                 :            : 
   12711                 :            : static int
   12712                 :          0 : test_dtls_1_2_record_proto_antireplay256(void)
   12713                 :            : {
   12714                 :          0 :         return test_dtls_1_2_record_proto_antireplay(256);
   12715                 :            : }
   12716                 :            : 
   12717                 :            : static int
   12718                 :          0 : test_dtls_1_2_record_proto_antireplay512(void)
   12719                 :            : {
   12720                 :          0 :         return test_dtls_1_2_record_proto_antireplay(512);
   12721                 :            : }
   12722                 :            : 
   12723                 :            : static int
   12724                 :          0 : test_dtls_1_2_record_proto_antireplay1024(void)
   12725                 :            : {
   12726                 :          0 :         return test_dtls_1_2_record_proto_antireplay(1024);
   12727                 :            : }
   12728                 :            : 
   12729                 :            : static int
   12730                 :          0 : test_dtls_1_2_record_proto_antireplay2048(void)
   12731                 :            : {
   12732                 :          0 :         return test_dtls_1_2_record_proto_antireplay(2048);
   12733                 :            : }
   12734                 :            : 
   12735                 :            : static int
   12736                 :          0 : test_dtls_1_2_record_proto_antireplay4096(void)
   12737                 :            : {
   12738                 :          0 :         return test_dtls_1_2_record_proto_antireplay(4096);
   12739                 :            : }
   12740                 :            : 
   12741                 :            : static int
   12742                 :          0 : test_dtls_1_2_record_proto_sgl(void)
   12743                 :            : {
   12744                 :          0 :         return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_DTLS_1_2);
   12745                 :            : }
   12746                 :            : 
   12747                 :            : static int
   12748                 :          0 : test_dtls_1_2_record_proto_sgl_data_walkthrough(void)
   12749                 :            : {
   12750                 :          0 :         return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_DTLS_1_2);
   12751                 :            : }
   12752                 :            : 
   12753                 :            : static int
   12754                 :          0 : test_dtls_1_2_record_proto_sgl_oop(void)
   12755                 :            : {
   12756                 :          0 :         return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_DTLS_1_2);
   12757                 :            : }
   12758                 :            : 
   12759                 :            : static int
   12760                 :          0 : test_dtls_1_2_record_proto_corrupt_pkt(void)
   12761                 :            : {
   12762                 :          0 :         struct tls_record_test_flags flags = {
   12763                 :            :                 .pkt_corruption = 1,
   12764                 :            :                 .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
   12765                 :            :         };
   12766                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12767                 :            :         struct rte_cryptodev_info dev_info;
   12768                 :            : 
   12769                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12770                 :            : 
   12771                 :          0 :         return test_tls_record_proto_all(&flags);
   12772                 :            : }
   12773                 :            : 
   12774                 :            : static int
   12775                 :          0 : test_dtls_1_2_record_proto_custom_content_type(void)
   12776                 :            : {
   12777                 :          0 :         struct tls_record_test_flags flags = {
   12778                 :            :                 .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
   12779                 :            :                 .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
   12780                 :            :         };
   12781                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12782                 :            :         struct rte_cryptodev_info dev_info;
   12783                 :            : 
   12784                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12785                 :            : 
   12786                 :          0 :         return test_tls_record_proto_all(&flags);
   12787                 :            : }
   12788                 :            : 
   12789                 :            : static int
   12790                 :          0 : test_dtls_1_2_record_proto_zero_len(void)
   12791                 :            : {
   12792                 :          0 :         struct tls_record_test_flags flags = {
   12793                 :            :                 .zero_len = 1,
   12794                 :            :                 .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
   12795                 :            :         };
   12796                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12797                 :            :         struct rte_cryptodev_info dev_info;
   12798                 :            : 
   12799                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12800                 :            : 
   12801                 :          0 :         return test_tls_record_proto_all(&flags);
   12802                 :            : }
   12803                 :            : 
   12804                 :            : static int
   12805                 :          0 : test_dtls_1_2_record_proto_zero_len_non_app(void)
   12806                 :            : {
   12807                 :          0 :         struct tls_record_test_flags flags = {
   12808                 :            :                 .zero_len = 1,
   12809                 :            :                 .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
   12810                 :            :                 .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
   12811                 :            :         };
   12812                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12813                 :            :         struct rte_cryptodev_info dev_info;
   12814                 :            : 
   12815                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12816                 :            : 
   12817                 :          0 :         return test_tls_record_proto_all(&flags);
   12818                 :            : }
   12819                 :            : 
   12820                 :            : static int
   12821                 :          0 : test_dtls_1_2_record_proto_dm_opt_padding(void)
   12822                 :            : {
   12823                 :          0 :         return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_DTLS_1_2);
   12824                 :            : }
   12825                 :            : 
   12826                 :            : static int
   12827                 :          0 : test_dtls_1_2_record_proto_dm_opt_padding_1(void)
   12828                 :            : {
   12829                 :          0 :         return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_DTLS_1_2);
   12830                 :            : }
   12831                 :            : 
   12832                 :            : static int
   12833                 :          0 : test_dtls_1_2_record_proto_sg_opt_padding(void)
   12834                 :            : {
   12835                 :          0 :         return test_tls_record_proto_opt_padding(1, 5, RTE_SECURITY_VERSION_DTLS_1_2);
   12836                 :            : }
   12837                 :            : 
   12838                 :            : static int
   12839                 :          0 : test_dtls_1_2_record_proto_sg_opt_padding_1(void)
   12840                 :            : {
   12841                 :          0 :         return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_DTLS_1_2);
   12842                 :            : }
   12843                 :            : 
   12844                 :            : static int
   12845                 :          0 : test_dtls_1_2_record_proto_sg_opt_padding_2(void)
   12846                 :            : {
   12847                 :          0 :         return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_DTLS_1_2);
   12848                 :            : }
   12849                 :            : 
   12850                 :            : static int
   12851                 :          0 : test_dtls_1_2_record_proto_sg_opt_padding_max(void)
   12852                 :            : {
   12853                 :          0 :         return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_DTLS_1_2);
   12854                 :            : }
   12855                 :            : 
   12856                 :            : static int
   12857                 :          0 : test_tls_1_3_record_proto_display_list(void)
   12858                 :            : {
   12859                 :            :         struct tls_record_test_flags flags;
   12860                 :            : 
   12861                 :            :         memset(&flags, 0, sizeof(flags));
   12862                 :            : 
   12863                 :          0 :         flags.display_alg = true;
   12864                 :          0 :         flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
   12865                 :            : 
   12866                 :          0 :         return test_tls_record_proto_all(&flags);
   12867                 :            : }
   12868                 :            : 
   12869                 :            : static int
   12870                 :          0 : test_dtls_1_2_record_proto_sg_opt_padding_corrupt(void)
   12871                 :            : {
   12872                 :          0 :         struct tls_record_test_flags flags = {
   12873                 :            :                 .opt_padding = 8,
   12874                 :            :                 .padding_corruption = true,
   12875                 :            :                 .nb_segs_in_mbuf = 4,
   12876                 :            :                 .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
   12877                 :            :         };
   12878                 :            : 
   12879                 :          0 :         return test_tls_record_proto_all(&flags);
   12880                 :            : }
   12881                 :            : 
   12882                 :            : static int
   12883                 :          0 : test_tls_1_3_record_proto_corrupt_pkt(void)
   12884                 :            : {
   12885                 :          0 :         struct tls_record_test_flags flags = {
   12886                 :            :                 .pkt_corruption = 1,
   12887                 :            :                 .tls_version = RTE_SECURITY_VERSION_TLS_1_3
   12888                 :            :         };
   12889                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12890                 :            :         struct rte_cryptodev_info dev_info;
   12891                 :            : 
   12892                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12893                 :            : 
   12894                 :          0 :         return test_tls_record_proto_all(&flags);
   12895                 :            : }
   12896                 :            : 
   12897                 :            : static int
   12898                 :          0 : test_tls_1_3_record_proto_custom_content_type(void)
   12899                 :            : {
   12900                 :          0 :         struct tls_record_test_flags flags = {
   12901                 :            :                 .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
   12902                 :            :                 .tls_version = RTE_SECURITY_VERSION_TLS_1_3
   12903                 :            :         };
   12904                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12905                 :            :         struct rte_cryptodev_info dev_info;
   12906                 :            : 
   12907                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12908                 :            : 
   12909                 :          0 :         return test_tls_record_proto_all(&flags);
   12910                 :            : }
   12911                 :            : 
   12912                 :            : static int
   12913                 :          0 : test_tls_1_3_record_proto_zero_len(void)
   12914                 :            : {
   12915                 :          0 :         struct tls_record_test_flags flags = {
   12916                 :            :                 .zero_len = 1,
   12917                 :            :                 .tls_version = RTE_SECURITY_VERSION_TLS_1_3
   12918                 :            :         };
   12919                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12920                 :            :         struct rte_cryptodev_info dev_info;
   12921                 :            : 
   12922                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12923                 :            : 
   12924                 :          0 :         return test_tls_record_proto_all(&flags);
   12925                 :            : }
   12926                 :            : 
   12927                 :            : static int
   12928                 :          0 : test_tls_1_3_record_proto_zero_len_non_app(void)
   12929                 :            : {
   12930                 :          0 :         struct tls_record_test_flags flags = {
   12931                 :            :                 .zero_len = 1,
   12932                 :            :                 .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
   12933                 :            :                 .tls_version = RTE_SECURITY_VERSION_TLS_1_3
   12934                 :            :         };
   12935                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12936                 :            :         struct rte_cryptodev_info dev_info;
   12937                 :            : 
   12938                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12939                 :            : 
   12940                 :          0 :         return test_tls_record_proto_all(&flags);
   12941                 :            : }
   12942                 :            : 
   12943                 :            : static int
   12944                 :          0 : test_tls_1_3_record_proto_dm_opt_padding(void)
   12945                 :            : {
   12946                 :          0 :         return test_tls_record_proto_opt_padding(6, 0, RTE_SECURITY_VERSION_TLS_1_3);
   12947                 :            : }
   12948                 :            : 
   12949                 :            : static int
   12950                 :          0 : test_tls_1_3_record_proto_sg_opt_padding(void)
   12951                 :            : {
   12952                 :          0 :         return test_tls_record_proto_opt_padding(25, 5, RTE_SECURITY_VERSION_TLS_1_3);
   12953                 :            : }
   12954                 :            : 
   12955                 :            : static int
   12956                 :          0 : test_tls_1_3_record_proto_sg_opt_padding_1(void)
   12957                 :            : {
   12958                 :          0 :         return test_tls_record_proto_opt_padding(25, 4, RTE_SECURITY_VERSION_TLS_1_3);
   12959                 :            : }
   12960                 :            : 
   12961                 :            : static int
   12962                 :          0 : test_tls_1_3_record_proto_data_walkthrough(void)
   12963                 :            : {
   12964                 :            :         struct tls_record_test_flags flags;
   12965                 :            : 
   12966                 :            :         memset(&flags, 0, sizeof(flags));
   12967                 :            : 
   12968                 :          0 :         flags.data_walkthrough = true;
   12969                 :          0 :         flags.skip_sess_destroy = true;
   12970                 :          0 :         flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
   12971                 :            : 
   12972                 :          0 :         return test_tls_record_proto_all(&flags);
   12973                 :            : }
   12974                 :            : 
   12975                 :            : static int
   12976                 :          0 : test_tls_1_3_record_proto_sgl(void)
   12977                 :            : {
   12978                 :          0 :         return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_3);
   12979                 :            : }
   12980                 :            : 
   12981                 :            : static int
   12982                 :          0 : test_tls_1_3_record_proto_sgl_data_walkthrough(void)
   12983                 :            : {
   12984                 :          0 :         return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_3);
   12985                 :            : }
   12986                 :            : 
   12987                 :            : static int
   12988                 :          0 : test_tls_1_3_record_proto_sgl_oop(void)
   12989                 :            : {
   12990                 :          0 :         return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_3);
   12991                 :            : }
   12992                 :            : 
   12993                 :            : #endif
   12994                 :            : 
   12995                 :            : static int
   12996                 :          1 : test_cryptodev_error_recover_helper_check(void)
   12997                 :            : {
   12998                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12999                 :            :         struct rte_cryptodev_info dev_info;
   13000                 :            :         uint64_t feat_flags;
   13001                 :            :         int ret;
   13002                 :            : 
   13003                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   13004                 :          1 :         feat_flags = dev_info.feature_flags;
   13005                 :            : 
   13006                 :            :         /* Skip the test if queue pair reset is not supported */
   13007                 :          1 :         ret = rte_cryptodev_queue_pair_reset(ts_params->valid_devs[0], 0, NULL, 0);
   13008         [ -  + ]:          1 :         if (ret == -ENOTSUP)
   13009                 :            :                 return TEST_SKIPPED;
   13010                 :            : 
   13011         [ #  # ]:          0 :         ret = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
   13012         [ #  # ]:          0 :         if (ret == -ENOTSUP)
   13013                 :          0 :                 return TEST_SKIPPED;
   13014                 :            : 
   13015         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
   13016         [ #  # ]:          0 :             ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   13017         [ #  # ]:          0 :              !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   13018                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag req for AES Cipheronly, testsuite not met\n");
   13019                 :          0 :                 return TEST_SKIPPED;
   13020                 :            :         }
   13021                 :            : 
   13022                 :            :         return 0;
   13023                 :            : }
   13024                 :            : 
   13025                 :            : static int
   13026                 :          0 : test_cryptodev_error_recover_helper(uint8_t dev_id, const void *test_data, bool generate_err)
   13027                 :            : {
   13028                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   13029                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   13030                 :            :         const struct blockcipher_test_data *tdata = test_data;
   13031                 :          0 :         uint8_t *cipher_key = alloca(tdata->cipher_key.len);
   13032                 :            :         struct rte_crypto_sym_op *sym_op = NULL;
   13033                 :            :         struct rte_crypto_op *op = NULL;
   13034                 :            :         char *dst;
   13035                 :            : 
   13036                 :          0 :         memcpy(cipher_key, tdata->cipher_key.data, tdata->cipher_key.len);
   13037                 :          0 :         ut_params->cipher_xform.next = NULL;
   13038                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   13039                 :          0 :         ut_params->cipher_xform.cipher.algo = tdata->crypto_algo;
   13040                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
   13041                 :          0 :         ut_params->cipher_xform.cipher.key.data = cipher_key;
   13042                 :          0 :         ut_params->cipher_xform.cipher.key.length = tdata->cipher_key.len;
   13043                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   13044                 :          0 :         ut_params->cipher_xform.cipher.iv.length = tdata->iv.len;
   13045                 :            : 
   13046                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id, &ut_params->cipher_xform,
   13047                 :            :                                                            ts_params->session_mpool);
   13048   [ #  #  #  # ]:          0 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   13049                 :            :                 return TEST_SKIPPED;
   13050         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   13051                 :            : 
   13052                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   13053         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
   13054                 :            : 
   13055                 :          0 :         memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), tdata->iv.data,
   13056         [ #  # ]:          0 :                tdata->iv.len);
   13057                 :            :         sym_op = ut_params->op->sym;
   13058                 :          0 :         sym_op->cipher.data.offset = tdata->cipher_offset;
   13059                 :          0 :         sym_op->cipher.data.length = tdata->ciphertext.len - tdata->cipher_offset;
   13060                 :            : 
   13061         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   13062                 :            : 
   13063         [ #  # ]:          0 :         if (generate_err) {
   13064                 :          0 :                 ut_params->ibuf = create_mbuf_from_heap(tdata->ciphertext.len, 0);
   13065         [ #  # ]:          0 :                 if (ut_params->ibuf == NULL)
   13066                 :            :                         return TEST_FAILED;
   13067                 :          0 :                 crypto_err = CRYPTODEV_ERR_TRIGGERED;
   13068                 :            :         } else {
   13069                 :          0 :                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   13070                 :            :         }
   13071                 :            : 
   13072                 :            :         /* clear mbuf payload */
   13073                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   13074                 :          0 :                rte_pktmbuf_tailroom(ut_params->ibuf));
   13075                 :            : 
   13076                 :          0 :         dst = rte_pktmbuf_mtod_offset(ut_params->ibuf, char *, 0);
   13077                 :          0 :         memcpy(dst, tdata->plaintext.data, tdata->plaintext.len);
   13078                 :            : 
   13079                 :          0 :         sym_op->m_src = ut_params->ibuf;
   13080                 :          0 :         sym_op->m_dst = NULL;
   13081                 :            : 
   13082                 :          0 :         op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
   13083                 :            : 
   13084         [ #  # ]:          0 :         if (generate_err) {
   13085                 :          0 :                 free(ut_params->ibuf);
   13086                 :          0 :                 ut_params->ibuf = NULL;
   13087         [ #  # ]:          0 :                 if (op == NULL) {
   13088                 :          0 :                         rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
   13089                 :          0 :                         ut_params->sess = NULL;
   13090                 :          0 :                         return TEST_SUCCESS;
   13091                 :            :                 } else {
   13092                 :            :                         return TEST_FAILED;
   13093                 :            :                 }
   13094                 :            :         }
   13095                 :            : 
   13096         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   13097                 :            :                           "crypto op processing failed");
   13098                 :            : 
   13099         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(dst, tdata->ciphertext.data + tdata->cipher_offset,
   13100                 :            :                                       tdata->ciphertext.len - tdata->cipher_offset,
   13101                 :            :                                       "Data not as expected");
   13102                 :            : 
   13103                 :          0 :         rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
   13104                 :          0 :         ut_params->sess = NULL;
   13105                 :            : 
   13106                 :          0 :         return TEST_SUCCESS;
   13107                 :            : }
   13108                 :            : 
   13109                 :            : /*
   13110                 :            :  * This unit test verifies the recovery of the cryptodev from any fatal error.
   13111                 :            :  * It verifies a single test data multiple times in a iteration. It uses a flag and flips its value
   13112                 :            :  * for every call to helper function.
   13113                 :            :  *
   13114                 :            :  * When the flag is set to 0, the helper function verifies the test data without generating any
   13115                 :            :  * errors, i.e: verifies the default behaviour of the cryptodev.
   13116                 :            :  *
   13117                 :            :  * When the flag is set to 1, the helper function allocates a pointer from heap or non-DMAble
   13118                 :            :  * memory and passes the pointer to cryptodev PMD inorder to generate a fatal error. Once the error
   13119                 :            :  * is generated, it waits till the cryptodev is recoverd from the error.
   13120                 :            :  *
   13121                 :            :  * Iterates the above steps multiple times, to verify the error recovery of cryptodev and behaviour
   13122                 :            :  * of cryptodev after the recovery.
   13123                 :            :  */
   13124                 :            : static int
   13125                 :          1 : test_cryptodev_verify_error_recover(const void *test_data)
   13126                 :            : {
   13127                 :            :         int ret = TEST_FAILED;
   13128                 :            :         int i, num_itr = 5;
   13129                 :            : 
   13130                 :          1 :         ret = test_cryptodev_error_recover_helper_check();
   13131         [ -  + ]:          1 :         if (ret)
   13132                 :            :                 return ret;
   13133                 :            : 
   13134         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_callback_register(p_testsuite_params->valid_devs[0],
   13135                 :            :                                                             RTE_CRYPTODEV_EVENT_ERROR,
   13136                 :            :                                                             test_cryptodev_error_cb, NULL),
   13137                 :            :                             "Failed to register Cryptodev callback");
   13138                 :            : 
   13139         [ #  # ]:          0 :         for (i = 0; i < num_itr; i++) {
   13140                 :            :                 int ticks = 0;
   13141                 :            : 
   13142                 :          0 :                 ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
   13143                 :            :                                                           test_data, false);
   13144         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
   13145                 :            : 
   13146                 :            :                 /* Generate Error */
   13147                 :          0 :                 ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
   13148                 :            :                                                           test_data, true);
   13149         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
   13150                 :            : 
   13151                 :            :                 /* Wait till cryptodev recovered from error */
   13152         [ #  # ]:          0 :                 while (crypto_err == CRYPTODEV_ERR_TRIGGERED) {
   13153                 :            :                         rte_delay_ms(10);
   13154         [ #  # ]:          0 :                         if (ticks++ > HW_ERR_RECOVER_TIMEOUT)
   13155                 :            :                                 return TEST_FAILED;
   13156                 :            :                 }
   13157                 :            :         }
   13158         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(crypto_err, CRYPTODEV_ERR_CLEARED, "cryptodev error recovery failed");
   13159                 :            : 
   13160                 :            :         return ret;
   13161                 :            : }
   13162                 :            : 
   13163                 :            : static int
   13164                 :          1 : test_AES_GCM_authenticated_encryption_test_case_1(void)
   13165                 :            : {
   13166                 :          1 :         return test_authenticated_encryption(&gcm_test_case_1);
   13167                 :            : }
   13168                 :            : 
   13169                 :            : static int
   13170                 :          1 : test_AES_GCM_authenticated_encryption_test_case_2(void)
   13171                 :            : {
   13172                 :          1 :         return test_authenticated_encryption(&gcm_test_case_2);
   13173                 :            : }
   13174                 :            : 
   13175                 :            : static int
   13176                 :          1 : test_AES_GCM_authenticated_encryption_test_case_3(void)
   13177                 :            : {
   13178                 :          1 :         return test_authenticated_encryption(&gcm_test_case_3);
   13179                 :            : }
   13180                 :            : 
   13181                 :            : static int
   13182                 :          1 : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
   13183                 :            : {
   13184                 :          1 :         return test_authenticated_encryption_helper(&gcm_test_case_3, true);
   13185                 :            : }
   13186                 :            : 
   13187                 :            : static int
   13188                 :          1 : test_AES_GCM_authenticated_encryption_test_case_4(void)
   13189                 :            : {
   13190                 :          1 :         return test_authenticated_encryption(&gcm_test_case_4);
   13191                 :            : }
   13192                 :            : 
   13193                 :            : static int
   13194                 :          1 : test_AES_GCM_authenticated_encryption_test_case_5(void)
   13195                 :            : {
   13196                 :          1 :         return test_authenticated_encryption(&gcm_test_case_5);
   13197                 :            : }
   13198                 :            : 
   13199                 :            : static int
   13200                 :          1 : test_AES_GCM_authenticated_encryption_test_case_6(void)
   13201                 :            : {
   13202                 :          1 :         return test_authenticated_encryption(&gcm_test_case_6);
   13203                 :            : }
   13204                 :            : 
   13205                 :            : static int
   13206                 :          1 : test_AES_GCM_authenticated_encryption_test_case_7(void)
   13207                 :            : {
   13208                 :          1 :         return test_authenticated_encryption(&gcm_test_case_7);
   13209                 :            : }
   13210                 :            : 
   13211                 :            : static int
   13212                 :          1 : test_AES_GCM_authenticated_encryption_test_case_8(void)
   13213                 :            : {
   13214                 :          1 :         return test_authenticated_encryption(&gcm_test_case_8);
   13215                 :            : }
   13216                 :            : 
   13217                 :            : static int
   13218                 :          1 : test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
   13219                 :            : {
   13220                 :          1 :         return test_authenticated_encryption(&gcm_J0_test_case_1);
   13221                 :            : }
   13222                 :            : 
   13223                 :            : static int
   13224                 :          1 : test_AES_GCM_auth_encryption_test_case_192_1(void)
   13225                 :            : {
   13226                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_1);
   13227                 :            : }
   13228                 :            : 
   13229                 :            : static int
   13230                 :          1 : test_AES_GCM_auth_encryption_test_case_192_2(void)
   13231                 :            : {
   13232                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_2);
   13233                 :            : }
   13234                 :            : 
   13235                 :            : static int
   13236                 :          1 : test_AES_GCM_auth_encryption_test_case_192_3(void)
   13237                 :            : {
   13238                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_3);
   13239                 :            : }
   13240                 :            : 
   13241                 :            : static int
   13242                 :          1 : test_AES_GCM_auth_encryption_test_case_192_4(void)
   13243                 :            : {
   13244                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_4);
   13245                 :            : }
   13246                 :            : 
   13247                 :            : static int
   13248                 :          1 : test_AES_GCM_auth_encryption_test_case_192_5(void)
   13249                 :            : {
   13250                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_5);
   13251                 :            : }
   13252                 :            : 
   13253                 :            : static int
   13254                 :          1 : test_AES_GCM_auth_encryption_test_case_192_6(void)
   13255                 :            : {
   13256                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_6);
   13257                 :            : }
   13258                 :            : 
   13259                 :            : static int
   13260                 :          1 : test_AES_GCM_auth_encryption_test_case_192_7(void)
   13261                 :            : {
   13262                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_7);
   13263                 :            : }
   13264                 :            : 
   13265                 :            : static int
   13266                 :          1 : test_AES_GCM_auth_encryption_test_case_256_1(void)
   13267                 :            : {
   13268                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_1);
   13269                 :            : }
   13270                 :            : 
   13271                 :            : static int
   13272                 :          1 : test_AES_GCM_auth_encryption_test_case_256_2(void)
   13273                 :            : {
   13274                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_2);
   13275                 :            : }
   13276                 :            : 
   13277                 :            : static int
   13278                 :          1 : test_AES_GCM_auth_encryption_test_case_256_3(void)
   13279                 :            : {
   13280                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_3);
   13281                 :            : }
   13282                 :            : 
   13283                 :            : static int
   13284                 :          1 : test_AES_GCM_auth_encryption_test_case_256_4(void)
   13285                 :            : {
   13286                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_4);
   13287                 :            : }
   13288                 :            : 
   13289                 :            : static int
   13290                 :          1 : test_AES_GCM_auth_encryption_test_case_256_5(void)
   13291                 :            : {
   13292                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_5);
   13293                 :            : }
   13294                 :            : 
   13295                 :            : static int
   13296                 :          1 : test_AES_GCM_auth_encryption_test_case_256_6(void)
   13297                 :            : {
   13298                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_6);
   13299                 :            : }
   13300                 :            : 
   13301                 :            : static int
   13302                 :          1 : test_AES_GCM_auth_encryption_test_case_256_7(void)
   13303                 :            : {
   13304                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_7);
   13305                 :            : }
   13306                 :            : 
   13307                 :            : static int
   13308                 :          1 : test_AES_GCM_auth_encryption_test_case_aad_1(void)
   13309                 :            : {
   13310                 :          1 :         return test_authenticated_encryption(&gcm_test_case_aad_1);
   13311                 :            : }
   13312                 :            : 
   13313                 :            : static int
   13314                 :          1 : test_AES_GCM_auth_encryption_test_case_aad_2(void)
   13315                 :            : {
   13316                 :          1 :         return test_authenticated_encryption(&gcm_test_case_aad_2);
   13317                 :            : }
   13318                 :            : 
   13319                 :            : static int
   13320                 :          1 : test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
   13321                 :            : {
   13322                 :            :         struct aead_test_data tdata;
   13323                 :            :         int res;
   13324                 :            : 
   13325                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13326                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13327                 :          1 :         tdata.iv.data[0] += 1;
   13328                 :            :         res = test_authenticated_encryption(&tdata);
   13329         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13330                 :            :                 return res;
   13331         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
   13332                 :            :         return TEST_SUCCESS;
   13333                 :            : }
   13334                 :            : 
   13335                 :            : static int
   13336                 :          1 : test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
   13337                 :            : {
   13338                 :            :         struct aead_test_data tdata;
   13339                 :            :         int res;
   13340                 :            : 
   13341                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13342                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13343                 :          1 :         tdata.plaintext.data[0] += 1;
   13344                 :            :         res = test_authenticated_encryption(&tdata);
   13345         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13346                 :            :                 return res;
   13347         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
   13348                 :            :         return TEST_SUCCESS;
   13349                 :            : }
   13350                 :            : 
   13351                 :            : static int
   13352                 :          1 : test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
   13353                 :            : {
   13354                 :            :         struct aead_test_data tdata;
   13355                 :            :         int res;
   13356                 :            : 
   13357                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13358                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13359                 :          1 :         tdata.ciphertext.data[0] += 1;
   13360                 :            :         res = test_authenticated_encryption(&tdata);
   13361         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13362                 :            :                 return res;
   13363         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
   13364                 :            :         return TEST_SUCCESS;
   13365                 :            : }
   13366                 :            : 
   13367                 :            : static int
   13368                 :          1 : test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
   13369                 :            : {
   13370                 :            :         struct aead_test_data tdata;
   13371                 :            :         int res;
   13372                 :            : 
   13373                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13374                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13375                 :          1 :         tdata.aad.len += 1;
   13376                 :            :         res = test_authenticated_encryption(&tdata);
   13377         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13378                 :            :                 return res;
   13379         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
   13380                 :            :         return TEST_SUCCESS;
   13381                 :            : }
   13382                 :            : 
   13383                 :            : static int
   13384                 :          1 : test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
   13385                 :            : {
   13386                 :            :         struct aead_test_data tdata;
   13387                 :          1 :         uint8_t *aad = alloca(gcm_test_case_7.aad.len);
   13388                 :            :         int res;
   13389                 :            : 
   13390                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13391                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13392                 :            :         memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
   13393                 :          1 :         aad[0] += 1;
   13394                 :          1 :         tdata.aad.data = aad;
   13395                 :            :         res = test_authenticated_encryption(&tdata);
   13396         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13397                 :            :                 return res;
   13398         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
   13399                 :            :         return TEST_SUCCESS;
   13400                 :            : }
   13401                 :            : 
   13402                 :            : static int
   13403                 :          1 : test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
   13404                 :            : {
   13405                 :            :         struct aead_test_data tdata;
   13406                 :            :         int res;
   13407                 :            : 
   13408                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13409                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13410                 :          1 :         tdata.auth_tag.data[0] += 1;
   13411                 :            :         res = test_authenticated_encryption(&tdata);
   13412         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13413                 :            :                 return res;
   13414         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
   13415                 :            :         return TEST_SUCCESS;
   13416                 :            : }
   13417                 :            : 
   13418                 :            : static int
   13419                 :         43 : test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
   13420                 :            : {
   13421                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   13422                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   13423                 :            : 
   13424                 :            :         int retval;
   13425                 :            :         uint8_t *plaintext;
   13426                 :            :         uint32_t i;
   13427                 :            :         struct rte_cryptodev_info dev_info;
   13428                 :            : 
   13429                 :         43 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   13430                 :         43 :         uint64_t feat_flags = dev_info.feature_flags;
   13431                 :            : 
   13432         [ -  + ]:         43 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   13433         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   13434                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   13435                 :          0 :                 return TEST_SKIPPED;
   13436                 :            :         }
   13437                 :            : 
   13438                 :            :         /* Verify the capabilities */
   13439                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   13440                 :            :         const struct rte_cryptodev_symmetric_capability *capability;
   13441                 :         43 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
   13442                 :         43 :         cap_idx.algo.aead = tdata->algo;
   13443                 :         43 :         capability = rte_cryptodev_sym_capability_get(
   13444                 :         43 :                         ts_params->valid_devs[0], &cap_idx);
   13445         [ +  - ]:         43 :         if (capability == NULL)
   13446                 :            :                 return TEST_SKIPPED;
   13447         [ +  + ]:         43 :         if (rte_cryptodev_sym_capability_check_aead(
   13448                 :         43 :                         capability, tdata->key.len, tdata->auth_tag.len,
   13449                 :         43 :                         tdata->aad.len, tdata->iv.len))
   13450                 :            :                 return TEST_SKIPPED;
   13451                 :            : 
   13452                 :            :         /* Create AEAD session */
   13453                 :         42 :         retval = create_aead_session(ts_params->valid_devs[0],
   13454                 :         42 :                         tdata->algo,
   13455                 :            :                         RTE_CRYPTO_AEAD_OP_DECRYPT,
   13456                 :         42 :                         tdata->key.data, tdata->key.len,
   13457                 :         42 :                         tdata->aad.len, tdata->auth_tag.len,
   13458                 :         42 :                         tdata->iv.len);
   13459         [ +  - ]:         42 :         if (retval != TEST_SUCCESS)
   13460                 :            :                 return retval;
   13461                 :            : 
   13462                 :            :         /* alloc mbuf and set payload */
   13463         [ +  + ]:         42 :         if (tdata->aad.len > MBUF_SIZE) {
   13464         [ -  + ]:          2 :                 if (use_ext_mbuf) {
   13465                 :          0 :                         ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
   13466                 :            :                                                           AEAD_TEXT_MAX_LENGTH,
   13467                 :            :                                                           1 /* nb_segs */,
   13468                 :            :                                                           NULL);
   13469                 :            :                 } else {
   13470                 :          2 :                         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
   13471                 :            :                 }
   13472                 :            :                 /* Populate full size of add data */
   13473         [ +  + ]:       4088 :                 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
   13474                 :       4086 :                         memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
   13475                 :            :         } else {
   13476         [ +  + ]:         40 :                 if (use_ext_mbuf) {
   13477                 :          1 :                         ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
   13478                 :            :                                                           AEAD_TEXT_MAX_LENGTH,
   13479                 :            :                                                           1 /* nb_segs */,
   13480                 :            :                                                           NULL);
   13481                 :            :                 } else {
   13482                 :         39 :                         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   13483                 :            :                 }
   13484                 :            :         }
   13485                 :         42 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   13486                 :         42 :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   13487                 :            : 
   13488                 :            :         /* Create AEAD operation */
   13489                 :         42 :         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
   13490         [ +  - ]:         42 :         if (retval < 0)
   13491                 :            :                 return retval;
   13492                 :            : 
   13493         [ +  - ]:         42 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   13494                 :            : 
   13495                 :         42 :         ut_params->op->sym->m_src = ut_params->ibuf;
   13496                 :            : 
   13497                 :            :         /* Process crypto operation */
   13498         [ -  + ]:         42 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   13499                 :          0 :                 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
   13500         [ -  + ]:         42 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   13501                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
   13502                 :            :                                                0);
   13503         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   13504                 :            :                         return retval;
   13505                 :            :         } else
   13506         [ +  + ]:         42 :                 TEST_ASSERT_NOT_NULL(
   13507                 :            :                         process_crypto_request(ts_params->valid_devs[0],
   13508                 :            :                         ut_params->op), "failed to process sym crypto op");
   13509                 :            : 
   13510         [ -  + ]:         37 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   13511                 :            :                         "crypto op processing failed");
   13512                 :            : 
   13513         [ -  + ]:         37 :         if (ut_params->op->sym->m_dst)
   13514                 :          0 :                 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
   13515                 :            :                                 uint8_t *);
   13516                 :            :         else
   13517                 :         37 :                 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
   13518                 :            :                                 uint8_t *,
   13519                 :            :                                 ut_params->op->sym->cipher.data.offset);
   13520                 :            : 
   13521                 :         37 :         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
   13522                 :            : 
   13523                 :            :         /* Validate obuf */
   13524         [ +  + ]:         38 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   13525                 :            :                         plaintext,
   13526                 :            :                         tdata->plaintext.data,
   13527                 :            :                         tdata->plaintext.len,
   13528                 :            :                         "Plaintext data not as expected");
   13529                 :            : 
   13530         [ -  + ]:         36 :         TEST_ASSERT_EQUAL(ut_params->op->status,
   13531                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   13532                 :            :                         "Authentication failed");
   13533                 :            : 
   13534                 :            :         return 0;
   13535                 :            : }
   13536                 :            : 
   13537                 :            : static int
   13538                 :            : test_authenticated_decryption(const struct aead_test_data *tdata)
   13539                 :            : {
   13540                 :         42 :         return test_authenticated_decryption_helper(tdata, false);
   13541                 :            : }
   13542                 :            : 
   13543                 :            : static int
   13544                 :          1 : test_AES_GCM_authenticated_decryption_test_case_1(void)
   13545                 :            : {
   13546                 :          1 :         return test_authenticated_decryption(&gcm_test_case_1);
   13547                 :            : }
   13548                 :            : 
   13549                 :            : static int
   13550                 :          1 : test_AES_GCM_authenticated_decryption_test_case_2(void)
   13551                 :            : {
   13552                 :          1 :         return test_authenticated_decryption(&gcm_test_case_2);
   13553                 :            : }
   13554                 :            : 
   13555                 :            : static int
   13556                 :          1 : test_AES_GCM_authenticated_decryption_test_case_3(void)
   13557                 :            : {
   13558                 :          1 :         return test_authenticated_decryption(&gcm_test_case_3);
   13559                 :            : }
   13560                 :            : 
   13561                 :            : static int
   13562                 :          1 : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
   13563                 :            : {
   13564                 :          1 :         return test_authenticated_decryption_helper(&gcm_test_case_3, true);
   13565                 :            : }
   13566                 :            : 
   13567                 :            : static int
   13568                 :          1 : test_AES_GCM_authenticated_decryption_test_case_4(void)
   13569                 :            : {
   13570                 :          1 :         return test_authenticated_decryption(&gcm_test_case_4);
   13571                 :            : }
   13572                 :            : 
   13573                 :            : static int
   13574                 :          1 : test_AES_GCM_authenticated_decryption_test_case_5(void)
   13575                 :            : {
   13576                 :          1 :         return test_authenticated_decryption(&gcm_test_case_5);
   13577                 :            : }
   13578                 :            : 
   13579                 :            : static int
   13580                 :          1 : test_AES_GCM_authenticated_decryption_test_case_6(void)
   13581                 :            : {
   13582                 :          1 :         return test_authenticated_decryption(&gcm_test_case_6);
   13583                 :            : }
   13584                 :            : 
   13585                 :            : static int
   13586                 :          1 : test_AES_GCM_authenticated_decryption_test_case_7(void)
   13587                 :            : {
   13588                 :          1 :         return test_authenticated_decryption(&gcm_test_case_7);
   13589                 :            : }
   13590                 :            : 
   13591                 :            : static int
   13592                 :          1 : test_AES_GCM_authenticated_decryption_test_case_8(void)
   13593                 :            : {
   13594                 :          1 :         return test_authenticated_decryption(&gcm_test_case_8);
   13595                 :            : }
   13596                 :            : 
   13597                 :            : static int
   13598                 :          1 : test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
   13599                 :            : {
   13600                 :          1 :         return test_authenticated_decryption(&gcm_J0_test_case_1);
   13601                 :            : }
   13602                 :            : 
   13603                 :            : static int
   13604                 :          1 : test_AES_GCM_auth_decryption_test_case_192_1(void)
   13605                 :            : {
   13606                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_1);
   13607                 :            : }
   13608                 :            : 
   13609                 :            : static int
   13610                 :          1 : test_AES_GCM_auth_decryption_test_case_192_2(void)
   13611                 :            : {
   13612                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_2);
   13613                 :            : }
   13614                 :            : 
   13615                 :            : static int
   13616                 :          1 : test_AES_GCM_auth_decryption_test_case_192_3(void)
   13617                 :            : {
   13618                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_3);
   13619                 :            : }
   13620                 :            : 
   13621                 :            : static int
   13622                 :          1 : test_AES_GCM_auth_decryption_test_case_192_4(void)
   13623                 :            : {
   13624                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_4);
   13625                 :            : }
   13626                 :            : 
   13627                 :            : static int
   13628                 :          1 : test_AES_GCM_auth_decryption_test_case_192_5(void)
   13629                 :            : {
   13630                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_5);
   13631                 :            : }
   13632                 :            : 
   13633                 :            : static int
   13634                 :          1 : test_AES_GCM_auth_decryption_test_case_192_6(void)
   13635                 :            : {
   13636                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_6);
   13637                 :            : }
   13638                 :            : 
   13639                 :            : static int
   13640                 :          1 : test_AES_GCM_auth_decryption_test_case_192_7(void)
   13641                 :            : {
   13642                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_7);
   13643                 :            : }
   13644                 :            : 
   13645                 :            : static int
   13646                 :          1 : test_AES_GCM_auth_decryption_test_case_256_1(void)
   13647                 :            : {
   13648                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_1);
   13649                 :            : }
   13650                 :            : 
   13651                 :            : static int
   13652                 :          1 : test_AES_GCM_auth_decryption_test_case_256_2(void)
   13653                 :            : {
   13654                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_2);
   13655                 :            : }
   13656                 :            : 
   13657                 :            : static int
   13658                 :          1 : test_AES_GCM_auth_decryption_test_case_256_3(void)
   13659                 :            : {
   13660                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_3);
   13661                 :            : }
   13662                 :            : 
   13663                 :            : static int
   13664                 :          1 : test_AES_GCM_auth_decryption_test_case_256_4(void)
   13665                 :            : {
   13666                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_4);
   13667                 :            : }
   13668                 :            : 
   13669                 :            : static int
   13670                 :          1 : test_AES_GCM_auth_decryption_test_case_256_5(void)
   13671                 :            : {
   13672                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_5);
   13673                 :            : }
   13674                 :            : 
   13675                 :            : static int
   13676                 :          1 : test_AES_GCM_auth_decryption_test_case_256_6(void)
   13677                 :            : {
   13678                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_6);
   13679                 :            : }
   13680                 :            : 
   13681                 :            : static int
   13682                 :          1 : test_AES_GCM_auth_decryption_test_case_256_7(void)
   13683                 :            : {
   13684                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_7);
   13685                 :            : }
   13686                 :            : 
   13687                 :            : static int
   13688                 :          1 : test_AES_GCM_auth_decryption_test_case_256_8(void)
   13689                 :            : {
   13690                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_8);
   13691                 :            : }
   13692                 :            : 
   13693                 :            : static int
   13694                 :          1 : test_AES_GCM_auth_encryption_test_case_256_8(void)
   13695                 :            : {
   13696                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_8);
   13697                 :            : }
   13698                 :            : 
   13699                 :            : static int
   13700                 :          1 : test_AES_GCM_auth_decryption_test_case_aad_1(void)
   13701                 :            : {
   13702                 :          1 :         return test_authenticated_decryption(&gcm_test_case_aad_1);
   13703                 :            : }
   13704                 :            : 
   13705                 :            : static int
   13706                 :          1 : test_AES_GCM_auth_decryption_test_case_aad_2(void)
   13707                 :            : {
   13708                 :          1 :         return test_authenticated_decryption(&gcm_test_case_aad_2);
   13709                 :            : }
   13710                 :            : 
   13711                 :            : static int
   13712                 :          1 : test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
   13713                 :            : {
   13714                 :            :         struct aead_test_data tdata;
   13715                 :            :         int res;
   13716                 :            : 
   13717                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13718                 :          1 :         tdata.iv.data[0] += 1;
   13719                 :            :         res = test_authenticated_decryption(&tdata);
   13720         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13721                 :            :                 return res;
   13722         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
   13723                 :            :         return TEST_SUCCESS;
   13724                 :            : }
   13725                 :            : 
   13726                 :            : static int
   13727                 :          1 : test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
   13728                 :            : {
   13729                 :            :         struct aead_test_data tdata;
   13730                 :            :         int res;
   13731                 :            : 
   13732                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13733                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13734                 :          1 :         tdata.plaintext.data[0] += 1;
   13735                 :            :         res = test_authenticated_decryption(&tdata);
   13736         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13737                 :            :                 return res;
   13738         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
   13739                 :            :         return TEST_SUCCESS;
   13740                 :            : }
   13741                 :            : 
   13742                 :            : static int
   13743                 :          1 : test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
   13744                 :            : {
   13745                 :            :         struct aead_test_data tdata;
   13746                 :            :         int res;
   13747                 :            : 
   13748                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13749                 :          1 :         tdata.ciphertext.data[0] += 1;
   13750                 :            :         res = test_authenticated_decryption(&tdata);
   13751         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13752                 :            :                 return res;
   13753         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
   13754                 :            :         return TEST_SUCCESS;
   13755                 :            : }
   13756                 :            : 
   13757                 :            : static int
   13758                 :          1 : test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
   13759                 :            : {
   13760                 :            :         struct aead_test_data tdata;
   13761                 :            :         int res;
   13762                 :            : 
   13763                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13764                 :          1 :         tdata.aad.len += 1;
   13765                 :            :         res = test_authenticated_decryption(&tdata);
   13766         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13767                 :            :                 return res;
   13768         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
   13769                 :            :         return TEST_SUCCESS;
   13770                 :            : }
   13771                 :            : 
   13772                 :            : static int
   13773                 :          1 : test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
   13774                 :            : {
   13775                 :            :         struct aead_test_data tdata;
   13776                 :          1 :         uint8_t *aad = alloca(gcm_test_case_7.aad.len);
   13777                 :            :         int res;
   13778                 :            : 
   13779                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13780                 :            :         memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
   13781                 :          1 :         aad[0] += 1;
   13782                 :          1 :         tdata.aad.data = aad;
   13783                 :            :         res = test_authenticated_decryption(&tdata);
   13784         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13785                 :            :                 return res;
   13786         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
   13787                 :            :         return TEST_SUCCESS;
   13788                 :            : }
   13789                 :            : 
   13790                 :            : static int
   13791                 :          1 : test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
   13792                 :            : {
   13793                 :            :         struct aead_test_data tdata;
   13794                 :            :         int res;
   13795                 :            : 
   13796                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13797                 :          1 :         tdata.auth_tag.data[0] += 1;
   13798                 :            :         res = test_authenticated_decryption(&tdata);
   13799         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13800                 :            :                 return res;
   13801         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
   13802                 :            :         return TEST_SUCCESS;
   13803                 :            : }
   13804                 :            : 
   13805                 :            : static int
   13806                 :          1 : test_authenticated_encryption_oop(const struct aead_test_data *tdata)
   13807                 :            : {
   13808                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   13809                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   13810                 :            : 
   13811                 :            :         uint32_t i;
   13812                 :            :         int retval;
   13813                 :            :         uint8_t *ciphertext, *auth_tag, *buffer_oop;
   13814                 :            :         uint16_t plaintext_pad_len;
   13815                 :            :         struct rte_cryptodev_info dev_info;
   13816                 :            : 
   13817                 :            :         /* Verify the capabilities */
   13818                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   13819                 :            :         const struct rte_cryptodev_symmetric_capability *capability;
   13820                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
   13821                 :          1 :         cap_idx.algo.aead = tdata->algo;
   13822                 :          1 :         capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
   13823         [ +  - ]:          1 :         if (capability == NULL)
   13824                 :            :                 return TEST_SKIPPED;
   13825         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_check_aead(
   13826                 :          1 :                 capability, tdata->key.len, tdata->auth_tag.len,
   13827                 :          1 :                 tdata->aad.len, tdata->iv.len))
   13828                 :            :                 return TEST_SKIPPED;
   13829                 :            : 
   13830                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   13831                 :          1 :         uint64_t feat_flags = dev_info.feature_flags;
   13832                 :            : 
   13833         [ -  + ]:          1 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   13834         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
   13835                 :            :                 return TEST_SKIPPED;
   13836                 :            : 
   13837                 :            :         /* not supported with CPU crypto */
   13838         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   13839                 :            :                 return TEST_SKIPPED;
   13840                 :            : 
   13841                 :            :         /* Create AEAD session */
   13842                 :          1 :         retval = create_aead_session(ts_params->valid_devs[0],
   13843                 :          1 :                         tdata->algo,
   13844                 :            :                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
   13845                 :          1 :                         tdata->key.data, tdata->key.len,
   13846                 :          1 :                         tdata->aad.len, tdata->auth_tag.len,
   13847                 :          1 :                         tdata->iv.len);
   13848         [ +  - ]:          1 :         if (retval < 0)
   13849                 :            :                 return retval;
   13850                 :            : 
   13851                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   13852                 :          1 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   13853                 :            : 
   13854                 :            :         /* clear mbuf payload */
   13855                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   13856                 :          1 :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   13857                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
   13858                 :          1 :                         rte_pktmbuf_tailroom(ut_params->obuf));
   13859                 :            : 
   13860                 :            :         /* Create AEAD operation */
   13861                 :          1 :         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
   13862         [ +  - ]:          1 :         if (retval < 0)
   13863                 :            :                 return retval;
   13864                 :            : 
   13865         [ +  - ]:          1 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   13866                 :            : 
   13867                 :          1 :         ut_params->op->sym->m_src = ut_params->ibuf;
   13868                 :          1 :         ut_params->op->sym->m_dst = ut_params->obuf;
   13869                 :            : 
   13870                 :            :         /* Process crypto operation */
   13871         [ -  + ]:          1 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   13872                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
   13873                 :            :                                                0);
   13874         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   13875                 :            :                         return retval;
   13876                 :            :         } else
   13877         [ -  + ]:          1 :                 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
   13878                 :            :                         ut_params->op), "failed to process sym crypto op");
   13879                 :            : 
   13880         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   13881                 :            :                         "crypto op processing failed");
   13882                 :            : 
   13883                 :          1 :         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
   13884                 :            : 
   13885                 :          1 :         ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
   13886                 :            :                         ut_params->op->sym->cipher.data.offset);
   13887                 :          1 :         auth_tag = ciphertext + plaintext_pad_len;
   13888                 :            : 
   13889                 :            :         /* Check if the data within the offset range is not overwritten in the OOP */
   13890                 :          1 :         buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
   13891         [ +  + ]:         17 :         for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
   13892         [ -  + ]:         16 :                 if (buffer_oop[i]) {
   13893                 :          0 :                         RTE_LOG(ERR, USER1,
   13894                 :            :                                 "Incorrect value of the output buffer header\n");
   13895                 :          0 :                         debug_hexdump(stdout, "Incorrect value:", buffer_oop,
   13896                 :          0 :                                 ut_params->op->sym->cipher.data.offset);
   13897                 :          0 :                         return TEST_FAILED;
   13898                 :            :                 }
   13899                 :            :         }
   13900                 :            : 
   13901                 :          1 :         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
   13902                 :          1 :         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
   13903                 :            : 
   13904                 :            :         /* Validate obuf */
   13905         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   13906                 :            :                         ciphertext,
   13907                 :            :                         tdata->ciphertext.data,
   13908                 :            :                         tdata->ciphertext.len,
   13909                 :            :                         "Ciphertext data not as expected");
   13910                 :            : 
   13911         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   13912                 :            :                         auth_tag,
   13913                 :            :                         tdata->auth_tag.data,
   13914                 :            :                         tdata->auth_tag.len,
   13915                 :            :                         "Generated auth tag not as expected");
   13916                 :            : 
   13917                 :            :         return 0;
   13918                 :            : 
   13919                 :            : }
   13920                 :            : 
   13921                 :            : static int
   13922                 :          1 : test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
   13923                 :            : {
   13924                 :          1 :         return test_authenticated_encryption_oop(&gcm_test_case_5);
   13925                 :            : }
   13926                 :            : 
   13927                 :            : static int
   13928                 :          1 : test_authenticated_decryption_oop(const struct aead_test_data *tdata)
   13929                 :            : {
   13930                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   13931                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   13932                 :            : 
   13933                 :            :         uint32_t i;
   13934                 :            :         int retval;
   13935                 :            :         uint8_t *plaintext, *buffer_oop;
   13936                 :            :         struct rte_cryptodev_info dev_info;
   13937                 :            : 
   13938                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   13939                 :            :         uint64_t feat_flags = dev_info.feature_flags;
   13940                 :            : 
   13941                 :            :         /* Verify the capabilities */
   13942                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   13943                 :            :         const struct rte_cryptodev_symmetric_capability *capability;
   13944                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
   13945                 :          1 :         cap_idx.algo.aead = tdata->algo;
   13946                 :          1 :         capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
   13947                 :            : 
   13948         [ +  - ]:          1 :         if (capability == NULL)
   13949                 :            :                 return TEST_SKIPPED;
   13950                 :            : 
   13951         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
   13952                 :          1 :                         tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
   13953                 :            :                 return TEST_SKIPPED;
   13954                 :            : 
   13955                 :            :         /* not supported with CPU crypto and raw data-path APIs*/
   13956         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
   13957         [ +  - ]:          1 :                         global_api_test_type == CRYPTODEV_RAW_API_TEST)
   13958                 :            :                 return TEST_SKIPPED;
   13959                 :            : 
   13960                 :            :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   13961                 :            :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   13962                 :            :                 printf("Device does not support RAW data-path APIs.\n");
   13963                 :            :                 return TEST_SKIPPED;
   13964                 :            :         }
   13965                 :            : 
   13966                 :            :         /* Create AEAD session */
   13967                 :          1 :         retval = create_aead_session(ts_params->valid_devs[0],
   13968                 :          1 :                         tdata->algo,
   13969                 :            :                         RTE_CRYPTO_AEAD_OP_DECRYPT,
   13970                 :          1 :                         tdata->key.data, tdata->key.len,
   13971                 :          1 :                         tdata->aad.len, tdata->auth_tag.len,
   13972                 :          1 :                         tdata->iv.len);
   13973         [ +  - ]:          1 :         if (retval < 0)
   13974                 :            :                 return retval;
   13975                 :            : 
   13976                 :            :         /* alloc mbuf and set payload */
   13977                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   13978                 :          1 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   13979                 :            : 
   13980                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   13981                 :          1 :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   13982                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
   13983                 :          1 :                         rte_pktmbuf_tailroom(ut_params->obuf));
   13984                 :            : 
   13985                 :            :         /* Create AEAD operation */
   13986                 :          1 :         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
   13987         [ +  - ]:          1 :         if (retval < 0)
   13988                 :            :                 return retval;
   13989                 :            : 
   13990         [ +  - ]:          1 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   13991                 :            : 
   13992                 :          1 :         ut_params->op->sym->m_src = ut_params->ibuf;
   13993                 :          1 :         ut_params->op->sym->m_dst = ut_params->obuf;
   13994                 :            : 
   13995                 :            :         /* Process crypto operation */
   13996         [ -  + ]:          1 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   13997                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
   13998                 :            :                                                0);
   13999         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   14000                 :            :                         return retval;
   14001                 :            :         } else
   14002         [ -  + ]:          1 :                 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
   14003                 :            :                         ut_params->op), "failed to process sym crypto op");
   14004                 :            : 
   14005         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   14006                 :            :                         "crypto op processing failed");
   14007                 :            : 
   14008                 :          1 :         plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
   14009                 :            :                         ut_params->op->sym->cipher.data.offset);
   14010                 :            : 
   14011                 :          1 :         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
   14012                 :            : 
   14013                 :            :         /* Check if the data within the offset range is not overwritten in the OOP */
   14014                 :          1 :         buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
   14015         [ +  + ]:         17 :         for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
   14016         [ -  + ]:         16 :                 if (buffer_oop[i]) {
   14017                 :          0 :                         RTE_LOG(ERR, USER1,
   14018                 :            :                                 "Incorrect value of the output buffer header\n");
   14019                 :          0 :                         debug_hexdump(stdout, "Incorrect value:", buffer_oop,
   14020                 :          0 :                                 ut_params->op->sym->cipher.data.offset);
   14021                 :          0 :                         return TEST_FAILED;
   14022                 :            :                 }
   14023                 :            :         }
   14024                 :            :         /* Validate obuf */
   14025         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   14026                 :            :                         plaintext,
   14027                 :            :                         tdata->plaintext.data,
   14028                 :            :                         tdata->plaintext.len,
   14029                 :            :                         "Plaintext data not as expected");
   14030                 :            : 
   14031         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status,
   14032                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   14033                 :            :                         "Authentication failed");
   14034                 :            :         return 0;
   14035                 :            : }
   14036                 :            : 
   14037                 :            : static int
   14038                 :          1 : test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
   14039                 :            : {
   14040                 :          1 :         return test_authenticated_decryption_oop(&gcm_test_case_5);
   14041                 :            : }
   14042                 :            : 
   14043                 :            : static int
   14044                 :          1 : test_authenticated_encryption_sessionless(
   14045                 :            :                 const struct aead_test_data *tdata)
   14046                 :            : {
   14047                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14048                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   14049                 :            : 
   14050                 :            :         int retval;
   14051                 :            :         uint8_t *ciphertext, *auth_tag;
   14052                 :            :         uint16_t plaintext_pad_len;
   14053                 :          1 :         uint8_t *key = alloca(tdata->key.len + 1);
   14054                 :            :         struct rte_cryptodev_info dev_info;
   14055                 :            : 
   14056                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   14057                 :          1 :         uint64_t feat_flags = dev_info.feature_flags;
   14058                 :            : 
   14059         [ -  + ]:          1 :         if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
   14060                 :            :                 printf("Device doesn't support Sessionless ops.\n");
   14061                 :          0 :                 return TEST_SKIPPED;
   14062                 :            :         }
   14063                 :            : 
   14064                 :            :         /* not supported with CPU crypto */
   14065         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   14066                 :            :                 return TEST_SKIPPED;
   14067                 :            : 
   14068                 :            :         /* Verify the capabilities */
   14069                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14070                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
   14071                 :          1 :         cap_idx.algo.aead = tdata->algo;
   14072         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14073                 :            :                         &cap_idx) == NULL)
   14074                 :            :                 return TEST_SKIPPED;
   14075                 :            : 
   14076                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   14077                 :            : 
   14078                 :            :         /* clear mbuf payload */
   14079                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   14080                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   14081                 :            : 
   14082                 :            :         /* Create AEAD operation */
   14083                 :          1 :         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
   14084         [ +  - ]:          1 :         if (retval < 0)
   14085                 :            :                 return retval;
   14086                 :            : 
   14087                 :            :         /* Create GCM xform */
   14088                 :          1 :         memcpy(key, tdata->key.data, tdata->key.len);
   14089                 :          1 :         retval = create_aead_xform(ut_params->op,
   14090                 :          1 :                         tdata->algo,
   14091                 :            :                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
   14092                 :            :                         key, tdata->key.len,
   14093                 :          1 :                         tdata->aad.len, tdata->auth_tag.len,
   14094                 :          1 :                         tdata->iv.len);
   14095         [ +  - ]:          1 :         if (retval < 0)
   14096                 :            :                 return retval;
   14097                 :            : 
   14098                 :          1 :         ut_params->op->sym->m_src = ut_params->ibuf;
   14099                 :            : 
   14100         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->sess_type,
   14101                 :            :                         RTE_CRYPTO_OP_SESSIONLESS,
   14102                 :            :                         "crypto op session type not sessionless");
   14103                 :            : 
   14104                 :            :         /* Process crypto operation */
   14105         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
   14106                 :            :                         ut_params->op), "failed to process sym crypto op");
   14107                 :            : 
   14108         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
   14109                 :            : 
   14110         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   14111                 :            :                         "crypto op status not success");
   14112                 :            : 
   14113                 :          1 :         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
   14114                 :            : 
   14115                 :          1 :         ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
   14116                 :            :                         ut_params->op->sym->cipher.data.offset);
   14117                 :          1 :         auth_tag = ciphertext + plaintext_pad_len;
   14118                 :            : 
   14119                 :          1 :         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
   14120                 :          1 :         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
   14121                 :            : 
   14122                 :            :         /* Validate obuf */
   14123         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   14124                 :            :                         ciphertext,
   14125                 :            :                         tdata->ciphertext.data,
   14126                 :            :                         tdata->ciphertext.len,
   14127                 :            :                         "Ciphertext data not as expected");
   14128                 :            : 
   14129         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   14130                 :            :                         auth_tag,
   14131                 :            :                         tdata->auth_tag.data,
   14132                 :            :                         tdata->auth_tag.len,
   14133                 :            :                         "Generated auth tag not as expected");
   14134                 :            : 
   14135                 :            :         return 0;
   14136                 :            : 
   14137                 :            : }
   14138                 :            : 
   14139                 :            : static int
   14140                 :          1 : test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
   14141                 :            : {
   14142                 :          1 :         return test_authenticated_encryption_sessionless(
   14143                 :            :                         &gcm_test_case_5);
   14144                 :            : }
   14145                 :            : 
   14146                 :            : static int
   14147                 :          1 : test_authenticated_decryption_sessionless(
   14148                 :            :                 const struct aead_test_data *tdata)
   14149                 :            : {
   14150                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14151                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   14152                 :            : 
   14153                 :            :         int retval;
   14154                 :            :         uint8_t *plaintext;
   14155                 :          1 :         uint8_t *key = alloca(tdata->key.len + 1);
   14156                 :            :         struct rte_cryptodev_info dev_info;
   14157                 :            : 
   14158                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   14159                 :          1 :         uint64_t feat_flags = dev_info.feature_flags;
   14160                 :            : 
   14161         [ -  + ]:          1 :         if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
   14162                 :            :                 printf("Device doesn't support Sessionless ops.\n");
   14163                 :          0 :                 return TEST_SKIPPED;
   14164                 :            :         }
   14165                 :            : 
   14166         [ -  + ]:          1 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   14167         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   14168                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   14169                 :          0 :                 return TEST_SKIPPED;
   14170                 :            :         }
   14171                 :            : 
   14172                 :            :         /* not supported with CPU crypto */
   14173         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   14174                 :            :                 return TEST_SKIPPED;
   14175                 :            : 
   14176                 :            :         /* Verify the capabilities */
   14177                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14178                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
   14179                 :          1 :         cap_idx.algo.aead = tdata->algo;
   14180         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14181                 :            :                         &cap_idx) == NULL)
   14182                 :            :                 return TEST_SKIPPED;
   14183                 :            : 
   14184                 :            :         /* alloc mbuf and set payload */
   14185                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   14186                 :            : 
   14187                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   14188                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   14189                 :            : 
   14190                 :            :         /* Create AEAD operation */
   14191                 :          1 :         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
   14192         [ +  - ]:          1 :         if (retval < 0)
   14193                 :            :                 return retval;
   14194                 :            : 
   14195                 :            :         /* Create AEAD xform */
   14196                 :          1 :         memcpy(key, tdata->key.data, tdata->key.len);
   14197                 :          1 :         retval = create_aead_xform(ut_params->op,
   14198                 :          1 :                         tdata->algo,
   14199                 :            :                         RTE_CRYPTO_AEAD_OP_DECRYPT,
   14200                 :            :                         key, tdata->key.len,
   14201                 :          1 :                         tdata->aad.len, tdata->auth_tag.len,
   14202                 :          1 :                         tdata->iv.len);
   14203         [ +  - ]:          1 :         if (retval < 0)
   14204                 :            :                 return retval;
   14205                 :            : 
   14206                 :          1 :         ut_params->op->sym->m_src = ut_params->ibuf;
   14207                 :            : 
   14208         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->sess_type,
   14209                 :            :                         RTE_CRYPTO_OP_SESSIONLESS,
   14210                 :            :                         "crypto op session type not sessionless");
   14211                 :            : 
   14212                 :            :         /* Process crypto operation */
   14213         [ -  + ]:          1 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   14214                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
   14215                 :            :                                                0);
   14216         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   14217                 :            :                         return retval;
   14218                 :            :         } else
   14219         [ -  + ]:          1 :                 TEST_ASSERT_NOT_NULL(process_crypto_request(
   14220                 :            :                         ts_params->valid_devs[0], ut_params->op),
   14221                 :            :                                 "failed to process sym crypto op");
   14222                 :            : 
   14223         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
   14224                 :            : 
   14225         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   14226                 :            :                         "crypto op status not success");
   14227                 :            : 
   14228                 :          1 :         plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
   14229                 :            :                         ut_params->op->sym->cipher.data.offset);
   14230                 :            : 
   14231                 :          1 :         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
   14232                 :            : 
   14233                 :            :         /* Validate obuf */
   14234         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   14235                 :            :                         plaintext,
   14236                 :            :                         tdata->plaintext.data,
   14237                 :            :                         tdata->plaintext.len,
   14238                 :            :                         "Plaintext data not as expected");
   14239                 :            : 
   14240         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status,
   14241                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   14242                 :            :                         "Authentication failed");
   14243                 :            :         return 0;
   14244                 :            : }
   14245                 :            : 
   14246                 :            : static int
   14247                 :          1 : test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
   14248                 :            : {
   14249                 :          1 :         return test_authenticated_decryption_sessionless(
   14250                 :            :                         &gcm_test_case_5);
   14251                 :            : }
   14252                 :            : 
   14253                 :            : static int
   14254                 :          1 : test_AES_CCM_authenticated_encryption_test_case_128_1(void)
   14255                 :            : {
   14256                 :          1 :         return test_authenticated_encryption(&ccm_test_case_128_1);
   14257                 :            : }
   14258                 :            : 
   14259                 :            : static int
   14260                 :          1 : test_AES_CCM_authenticated_encryption_test_case_128_2(void)
   14261                 :            : {
   14262                 :          1 :         return test_authenticated_encryption(&ccm_test_case_128_2);
   14263                 :            : }
   14264                 :            : 
   14265                 :            : static int
   14266                 :          1 : test_AES_CCM_authenticated_encryption_test_case_128_3(void)
   14267                 :            : {
   14268                 :          1 :         return test_authenticated_encryption(&ccm_test_case_128_3);
   14269                 :            : }
   14270                 :            : 
   14271                 :            : static int
   14272                 :          1 : test_AES_CCM_authenticated_encryption_test_case_128_4(void)
   14273                 :            : {
   14274                 :          1 :         return test_authenticated_encryption(&ccm_test_case_128_4);
   14275                 :            : }
   14276                 :            : 
   14277                 :            : static int
   14278                 :          1 : test_AES_CCM_authenticated_decryption_test_case_128_1(void)
   14279                 :            : {
   14280                 :          1 :         return test_authenticated_decryption(&ccm_test_case_128_1);
   14281                 :            : }
   14282                 :            : 
   14283                 :            : static int
   14284                 :          1 : test_AES_CCM_authenticated_decryption_test_case_128_2(void)
   14285                 :            : {
   14286                 :          1 :         return test_authenticated_decryption(&ccm_test_case_128_2);
   14287                 :            : }
   14288                 :            : 
   14289                 :            : static int
   14290                 :          1 : test_AES_CCM_authenticated_decryption_test_case_128_3(void)
   14291                 :            : {
   14292                 :          1 :         return test_authenticated_decryption(&ccm_test_case_128_3);
   14293                 :            : }
   14294                 :            : 
   14295                 :            : static int
   14296                 :          1 : test_AES_CCM_authenticated_decryption_test_case_128_4(void)
   14297                 :            : {
   14298                 :          1 :         return test_authenticated_decryption(&ccm_test_case_128_4);
   14299                 :            : }
   14300                 :            : 
   14301                 :            : static int
   14302                 :          1 : test_AES_CCM_authenticated_encryption_test_case_192_1(void)
   14303                 :            : {
   14304                 :          1 :         return test_authenticated_encryption(&ccm_test_case_192_1);
   14305                 :            : }
   14306                 :            : 
   14307                 :            : static int
   14308                 :          1 : test_AES_CCM_authenticated_encryption_test_case_192_2(void)
   14309                 :            : {
   14310                 :          1 :         return test_authenticated_encryption(&ccm_test_case_192_2);
   14311                 :            : }
   14312                 :            : 
   14313                 :            : static int
   14314                 :          1 : test_AES_CCM_authenticated_encryption_test_case_192_3(void)
   14315                 :            : {
   14316                 :          1 :         return test_authenticated_encryption(&ccm_test_case_192_3);
   14317                 :            : }
   14318                 :            : 
   14319                 :            : static int
   14320                 :          1 : test_AES_CCM_authenticated_decryption_test_case_192_1(void)
   14321                 :            : {
   14322                 :          1 :         return test_authenticated_decryption(&ccm_test_case_192_1);
   14323                 :            : }
   14324                 :            : 
   14325                 :            : static int
   14326                 :          1 : test_AES_CCM_authenticated_decryption_test_case_192_2(void)
   14327                 :            : {
   14328                 :          1 :         return test_authenticated_decryption(&ccm_test_case_192_2);
   14329                 :            : }
   14330                 :            : 
   14331                 :            : static int
   14332                 :          1 : test_AES_CCM_authenticated_decryption_test_case_192_3(void)
   14333                 :            : {
   14334                 :          1 :         return test_authenticated_decryption(&ccm_test_case_192_3);
   14335                 :            : }
   14336                 :            : 
   14337                 :            : static int
   14338                 :          1 : test_AES_CCM_authenticated_encryption_test_case_256_1(void)
   14339                 :            : {
   14340                 :          1 :         return test_authenticated_encryption(&ccm_test_case_256_1);
   14341                 :            : }
   14342                 :            : 
   14343                 :            : static int
   14344                 :          1 : test_AES_CCM_authenticated_encryption_test_case_256_2(void)
   14345                 :            : {
   14346                 :          1 :         return test_authenticated_encryption(&ccm_test_case_256_2);
   14347                 :            : }
   14348                 :            : 
   14349                 :            : static int
   14350                 :          1 : test_AES_CCM_authenticated_encryption_test_case_256_3(void)
   14351                 :            : {
   14352                 :          1 :         return test_authenticated_encryption(&ccm_test_case_256_3);
   14353                 :            : }
   14354                 :            : 
   14355                 :            : static int
   14356                 :          1 : test_AES_CCM_authenticated_decryption_test_case_256_1(void)
   14357                 :            : {
   14358                 :          1 :         return test_authenticated_decryption(&ccm_test_case_256_1);
   14359                 :            : }
   14360                 :            : 
   14361                 :            : static int
   14362                 :          1 : test_AES_CCM_authenticated_decryption_test_case_256_2(void)
   14363                 :            : {
   14364                 :          1 :         return test_authenticated_decryption(&ccm_test_case_256_2);
   14365                 :            : }
   14366                 :            : 
   14367                 :            : static int
   14368                 :          1 : test_AES_CCM_authenticated_decryption_test_case_256_3(void)
   14369                 :            : {
   14370                 :          1 :         return test_authenticated_decryption(&ccm_test_case_256_3);
   14371                 :            : }
   14372                 :            : 
   14373                 :            : static int
   14374                 :          1 : test_stats(void)
   14375                 :            : {
   14376                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14377                 :            :         struct rte_cryptodev_stats stats;
   14378                 :            : 
   14379         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   14380                 :            :                 return TEST_SKIPPED;
   14381                 :            : 
   14382                 :            :         /* Verify the capabilities */
   14383                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14384                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14385                 :          1 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
   14386         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14387                 :            :                         &cap_idx) == NULL)
   14388                 :            :                 return TEST_SKIPPED;
   14389                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   14390                 :          1 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
   14391         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14392                 :            :                         &cap_idx) == NULL)
   14393                 :            :                 return TEST_SKIPPED;
   14394                 :            : 
   14395         [ +  - ]:          1 :         if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
   14396                 :            :                         == -ENOTSUP)
   14397                 :            :                 return TEST_SKIPPED;
   14398                 :            : 
   14399                 :          1 :         rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
   14400         [ -  + ]:          1 :         TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
   14401                 :            :                         &stats) == -ENODEV),
   14402                 :            :                 "rte_cryptodev_stats_get invalid dev failed");
   14403         [ -  + ]:          1 :         TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
   14404                 :            :                 "rte_cryptodev_stats_get invalid Param failed");
   14405                 :            : 
   14406                 :            :         /* Test expected values */
   14407                 :          1 :         test_AES_CBC_HMAC_SHA1_encrypt_digest();
   14408         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
   14409                 :            :                         &stats),
   14410                 :            :                 "rte_cryptodev_stats_get failed");
   14411         [ -  + ]:          1 :         TEST_ASSERT((stats.enqueued_count == 1),
   14412                 :            :                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
   14413         [ -  + ]:          1 :         TEST_ASSERT((stats.dequeued_count == 1),
   14414                 :            :                 "rte_cryptodev_stats_get returned unexpected dequeued stat");
   14415         [ -  + ]:          1 :         TEST_ASSERT((stats.enqueue_err_count == 0),
   14416                 :            :                 "rte_cryptodev_stats_get returned unexpected enqueued error count stat");
   14417         [ -  + ]:          1 :         TEST_ASSERT((stats.dequeue_err_count == 0),
   14418                 :            :                 "rte_cryptodev_stats_get returned unexpected dequeued error count stat");
   14419                 :            : 
   14420                 :            :         /* invalid device but should ignore and not reset device stats*/
   14421                 :          1 :         rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
   14422         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
   14423                 :            :                         &stats),
   14424                 :            :                 "rte_cryptodev_stats_get failed");
   14425         [ -  + ]:          1 :         TEST_ASSERT((stats.enqueued_count == 1),
   14426                 :            :                 "rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
   14427                 :            : 
   14428                 :            :         /* check that a valid reset clears stats */
   14429                 :          1 :         rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
   14430         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
   14431                 :            :                         &stats),
   14432                 :            :                                           "rte_cryptodev_stats_get failed");
   14433         [ -  + ]:          1 :         TEST_ASSERT((stats.enqueued_count == 0),
   14434                 :            :                 "rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
   14435         [ -  + ]:          1 :         TEST_ASSERT((stats.dequeued_count == 0),
   14436                 :            :                 "rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
   14437                 :            : 
   14438                 :            :         return TEST_SUCCESS;
   14439                 :            : }
   14440                 :            : 
   14441                 :            : static int
   14442                 :          1 : test_device_reconfigure(void)
   14443                 :            : {
   14444                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14445                 :          1 :         uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
   14446                 :          1 :         struct rte_cryptodev_qp_conf qp_conf = {
   14447                 :            :                 .nb_descriptors = MAX_NUM_OPS_INFLIGHT,
   14448                 :          1 :                 .mp_session = ts_params->session_mpool
   14449                 :            :         };
   14450                 :            :         uint16_t qp_id, dev_id, num_devs = 0;
   14451                 :            : 
   14452         [ -  + ]:          1 :         TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
   14453                 :            :                         "Need at least %d devices for test", 1);
   14454                 :            : 
   14455                 :          1 :         dev_id = ts_params->valid_devs[0];
   14456                 :            : 
   14457                 :            :         /* Stop the device in case it's started so it can be configured */
   14458                 :          1 :         rte_cryptodev_stop(dev_id);
   14459                 :            : 
   14460         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
   14461                 :            :                         "Failed test for rte_cryptodev_configure: "
   14462                 :            :                         "dev_num %u", dev_id);
   14463                 :            : 
   14464                 :            :         /* Reconfigure with same configure params */
   14465         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
   14466                 :            :                         "Failed test for rte_cryptodev_configure: "
   14467                 :            :                         "dev_num %u", dev_id);
   14468                 :            : 
   14469                 :            :         /* Reconfigure with just one queue pair */
   14470                 :          1 :         ts_params->conf.nb_queue_pairs = 1;
   14471                 :            : 
   14472         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
   14473                 :            :                         &ts_params->conf),
   14474                 :            :                         "Failed to configure cryptodev: dev_id %u, qp_id %u",
   14475                 :            :                         ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
   14476                 :            : 
   14477         [ +  + ]:          2 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
   14478         [ -  + ]:          1 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
   14479                 :            :                                 ts_params->valid_devs[0], qp_id, &qp_conf,
   14480                 :            :                                 rte_cryptodev_socket_id(
   14481                 :            :                                                 ts_params->valid_devs[0])),
   14482                 :            :                                 "Failed test for "
   14483                 :            :                                 "rte_cryptodev_queue_pair_setup: num_inflights "
   14484                 :            :                                 "%u on qp %u on cryptodev %u",
   14485                 :            :                                 qp_conf.nb_descriptors, qp_id,
   14486                 :            :                                 ts_params->valid_devs[0]);
   14487                 :            :         }
   14488                 :            : 
   14489                 :            :         /* Reconfigure with max number of queue pairs */
   14490                 :          1 :         ts_params->conf.nb_queue_pairs = orig_nb_qps;
   14491                 :            : 
   14492         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
   14493                 :            :                         &ts_params->conf),
   14494                 :            :                         "Failed to configure cryptodev: dev_id %u, qp_id %u",
   14495                 :            :                         ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
   14496                 :            : 
   14497                 :          1 :         qp_conf.mp_session = ts_params->session_mpool;
   14498                 :            : 
   14499         [ +  + ]:          9 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
   14500         [ -  + ]:          8 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
   14501                 :            :                                 ts_params->valid_devs[0], qp_id, &qp_conf,
   14502                 :            :                                 rte_cryptodev_socket_id(
   14503                 :            :                                                 ts_params->valid_devs[0])),
   14504                 :            :                                 "Failed test for "
   14505                 :            :                                 "rte_cryptodev_queue_pair_setup: num_inflights "
   14506                 :            :                                 "%u on qp %u on cryptodev %u",
   14507                 :            :                                 qp_conf.nb_descriptors, qp_id,
   14508                 :            :                                 ts_params->valid_devs[0]);
   14509                 :            :         }
   14510                 :            : 
   14511                 :            :         /* Start the device */
   14512         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
   14513                 :            :                         "Failed to start cryptodev %u",
   14514                 :            :                         ts_params->valid_devs[0]);
   14515                 :            : 
   14516                 :            :         /* Test expected values */
   14517                 :          1 :         return test_AES_CBC_HMAC_SHA1_encrypt_digest();
   14518                 :            : }
   14519                 :            : 
   14520                 :          4 : static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
   14521                 :            :                                    struct crypto_unittest_params *ut_params,
   14522                 :            :                                    enum rte_crypto_auth_operation op,
   14523                 :            :                                    const struct HMAC_MD5_vector *test_case)
   14524                 :            : {
   14525                 :            :         uint8_t key[64];
   14526                 :            : 
   14527                 :          4 :         memcpy(key, test_case->key.data, test_case->key.len);
   14528                 :            : 
   14529                 :          4 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14530                 :          4 :         ut_params->auth_xform.next = NULL;
   14531                 :          4 :         ut_params->auth_xform.auth.op = op;
   14532                 :            : 
   14533                 :          4 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
   14534                 :            : 
   14535                 :          4 :         ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
   14536                 :          4 :         ut_params->auth_xform.auth.key.length = test_case->key.len;
   14537                 :          4 :         ut_params->auth_xform.auth.key.data = key;
   14538                 :            : 
   14539                 :          8 :         ut_params->sess = rte_cryptodev_sym_session_create(
   14540                 :          4 :                 ts_params->valid_devs[0], &ut_params->auth_xform,
   14541                 :            :                         ts_params->session_mpool);
   14542   [ -  +  -  - ]:          4 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   14543                 :            :                 return TEST_SKIPPED;
   14544         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   14545                 :            : 
   14546                 :          4 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   14547                 :            : 
   14548                 :          4 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   14549                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   14550                 :            : 
   14551                 :          4 :         return 0;
   14552                 :            : }
   14553                 :            : 
   14554                 :          4 : static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
   14555                 :            :                               const struct HMAC_MD5_vector *test_case,
   14556                 :            :                               uint8_t **plaintext)
   14557                 :            : {
   14558                 :            :         uint16_t plaintext_pad_len;
   14559                 :            : 
   14560                 :          4 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
   14561                 :            : 
   14562                 :          4 :         plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
   14563                 :            :                                 16);
   14564                 :            : 
   14565                 :          4 :         *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   14566                 :            :                         plaintext_pad_len);
   14567                 :          4 :         memcpy(*plaintext, test_case->plaintext.data,
   14568                 :          4 :                         test_case->plaintext.len);
   14569                 :            : 
   14570                 :          4 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
   14571                 :            :                         ut_params->ibuf, MD5_DIGEST_LEN);
   14572         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
   14573                 :            :                         "no room to append digest");
   14574         [ +  + ]:          4 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
   14575                 :            :                         ut_params->ibuf, plaintext_pad_len);
   14576                 :            : 
   14577         [ +  + ]:          4 :         if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
   14578                 :          2 :                 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
   14579         [ -  + ]:          2 :                            test_case->auth_tag.len);
   14580                 :            :         }
   14581                 :            : 
   14582                 :          4 :         sym_op->auth.data.offset = 0;
   14583                 :          4 :         sym_op->auth.data.length = test_case->plaintext.len;
   14584                 :            : 
   14585         [ +  - ]:          4 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   14586                 :          4 :         ut_params->op->sym->m_src = ut_params->ibuf;
   14587                 :            : 
   14588                 :          4 :         return 0;
   14589                 :            : }
   14590                 :            : 
   14591                 :            : static int
   14592                 :          2 : test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
   14593                 :            : {
   14594                 :            :         uint16_t plaintext_pad_len;
   14595                 :            :         uint8_t *plaintext, *auth_tag;
   14596                 :            :         int ret;
   14597                 :            : 
   14598                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14599                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   14600                 :            :         struct rte_cryptodev_info dev_info;
   14601                 :            : 
   14602                 :          2 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   14603                 :          2 :         uint64_t feat_flags = dev_info.feature_flags;
   14604                 :            : 
   14605         [ -  + ]:          2 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   14606         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   14607                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   14608                 :          0 :                 return TEST_SKIPPED;
   14609                 :            :         }
   14610                 :            : 
   14611                 :            :         /* Verify the capabilities */
   14612                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14613                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14614                 :          2 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
   14615         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14616                 :            :                         &cap_idx) == NULL)
   14617                 :            :                 return TEST_SKIPPED;
   14618                 :            : 
   14619         [ +  - ]:          2 :         if (MD5_HMAC_create_session(ts_params, ut_params,
   14620                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
   14621                 :            :                 return TEST_FAILED;
   14622                 :            : 
   14623                 :            :         /* Generate Crypto op data structure */
   14624                 :          2 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   14625                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   14626         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   14627                 :            :                         "Failed to allocate symmetric crypto operation struct");
   14628                 :            : 
   14629                 :          2 :         plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
   14630                 :            :                                 16);
   14631                 :            : 
   14632         [ +  - ]:          2 :         if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
   14633                 :            :                 return TEST_FAILED;
   14634                 :            : 
   14635         [ -  + ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   14636                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   14637                 :            :                         ut_params->op);
   14638         [ -  + ]:          2 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   14639                 :          0 :                 ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
   14640         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
   14641                 :            :                         return ret;
   14642                 :            :         } else
   14643         [ -  + ]:          2 :                 TEST_ASSERT_NOT_NULL(
   14644                 :            :                         process_crypto_request(ts_params->valid_devs[0],
   14645                 :            :                                 ut_params->op),
   14646                 :            :                                 "failed to process sym crypto op");
   14647                 :            : 
   14648         [ -  + ]:          2 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   14649                 :            :                         "crypto op processing failed");
   14650                 :            : 
   14651         [ -  + ]:          2 :         if (ut_params->op->sym->m_dst) {
   14652                 :          0 :                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
   14653                 :            :                                 uint8_t *, plaintext_pad_len);
   14654                 :            :         } else {
   14655                 :          2 :                 auth_tag = plaintext + plaintext_pad_len;
   14656                 :            :         }
   14657                 :            : 
   14658         [ -  + ]:          2 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   14659                 :            :                         auth_tag,
   14660                 :            :                         test_case->auth_tag.data,
   14661                 :            :                         test_case->auth_tag.len,
   14662                 :            :                         "HMAC_MD5 generated tag not as expected");
   14663                 :            : 
   14664                 :            :         return TEST_SUCCESS;
   14665                 :            : }
   14666                 :            : 
   14667                 :            : static int
   14668                 :          2 : test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
   14669                 :            : {
   14670                 :            :         uint8_t *plaintext;
   14671                 :            :         int ret;
   14672                 :            : 
   14673                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14674                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   14675                 :            :         struct rte_cryptodev_info dev_info;
   14676                 :            : 
   14677                 :          2 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   14678                 :          2 :         uint64_t feat_flags = dev_info.feature_flags;
   14679                 :            : 
   14680         [ -  + ]:          2 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   14681         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   14682                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   14683                 :          0 :                 return TEST_SKIPPED;
   14684                 :            :         }
   14685                 :            : 
   14686                 :            :         /* Verify the capabilities */
   14687                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14688                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14689                 :          2 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
   14690         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14691                 :            :                         &cap_idx) == NULL)
   14692                 :            :                 return TEST_SKIPPED;
   14693                 :            : 
   14694         [ +  - ]:          2 :         if (MD5_HMAC_create_session(ts_params, ut_params,
   14695                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
   14696                 :            :                 return TEST_FAILED;
   14697                 :            :         }
   14698                 :            : 
   14699                 :            :         /* Generate Crypto op data structure */
   14700                 :          2 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   14701                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   14702         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   14703                 :            :                         "Failed to allocate symmetric crypto operation struct");
   14704                 :            : 
   14705         [ +  - ]:          2 :         if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
   14706                 :            :                 return TEST_FAILED;
   14707                 :            : 
   14708         [ -  + ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   14709                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   14710                 :            :                         ut_params->op);
   14711         [ -  + ]:          2 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   14712                 :          0 :                 ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
   14713         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
   14714                 :            :                         return ret;
   14715                 :            :         } else
   14716         [ -  + ]:          2 :                 TEST_ASSERT_NOT_NULL(
   14717                 :            :                         process_crypto_request(ts_params->valid_devs[0],
   14718                 :            :                                 ut_params->op),
   14719                 :            :                                 "failed to process sym crypto op");
   14720                 :            : 
   14721         [ -  + ]:          2 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   14722                 :            :                         "HMAC_MD5 crypto op processing failed");
   14723                 :            : 
   14724                 :            :         return TEST_SUCCESS;
   14725                 :            : }
   14726                 :            : 
   14727                 :            : static int
   14728                 :          1 : test_MD5_HMAC_generate_case_1(void)
   14729                 :            : {
   14730                 :          1 :         return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
   14731                 :            : }
   14732                 :            : 
   14733                 :            : static int
   14734                 :          1 : test_MD5_HMAC_verify_case_1(void)
   14735                 :            : {
   14736                 :          1 :         return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
   14737                 :            : }
   14738                 :            : 
   14739                 :            : static int
   14740                 :          1 : test_MD5_HMAC_generate_case_2(void)
   14741                 :            : {
   14742                 :          1 :         return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
   14743                 :            : }
   14744                 :            : 
   14745                 :            : static int
   14746                 :          1 : test_MD5_HMAC_verify_case_2(void)
   14747                 :            : {
   14748                 :          1 :         return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
   14749                 :            : }
   14750                 :            : 
   14751                 :            : static int
   14752                 :          1 : test_multi_session(void)
   14753                 :            : {
   14754                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14755                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   14756                 :            :         struct rte_cryptodev_info dev_info;
   14757                 :            :         int i, nb_sess, ret = TEST_SUCCESS;
   14758                 :            :         void **sessions;
   14759                 :            : 
   14760                 :            :         /* Verify the capabilities */
   14761                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14762                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14763                 :          1 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
   14764         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14765                 :            :                         &cap_idx) == NULL)
   14766                 :            :                 return TEST_SKIPPED;
   14767                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   14768                 :          1 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
   14769         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14770                 :            :                         &cap_idx) == NULL)
   14771                 :            :                 return TEST_SKIPPED;
   14772                 :            : 
   14773                 :            :         test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
   14774                 :            :                         aes_cbc_key, hmac_sha512_key);
   14775                 :            : 
   14776                 :            : 
   14777                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   14778                 :            : 
   14779                 :          1 :         sessions = rte_malloc(NULL,
   14780                 :            :                         sizeof(void *) *
   14781                 :            :                         (MAX_NB_SESSIONS + 1), 0);
   14782                 :            : 
   14783                 :            :         /* Create multiple crypto sessions*/
   14784         [ +  + ]:          5 :         for (i = 0; i < MAX_NB_SESSIONS; i++) {
   14785                 :          8 :                 sessions[i] = rte_cryptodev_sym_session_create(
   14786                 :          4 :                         ts_params->valid_devs[0], &ut_params->auth_xform,
   14787                 :            :                                 ts_params->session_mpool);
   14788         [ -  + ]:          4 :                 if (sessions[i] == NULL) {
   14789                 :            :                         nb_sess = i;
   14790         [ #  # ]:          0 :                         if (rte_errno == ENOTSUP)
   14791                 :            :                                 ret = TEST_SKIPPED;
   14792                 :            :                         else {
   14793                 :            :                                 ret = TEST_FAILED;
   14794                 :            :                                 printf("TestCase %s() line %d failed : "
   14795                 :            :                                                 "Session creation failed at session number %u",
   14796                 :            :                                                 __func__, __LINE__, i);
   14797                 :            :                         }
   14798                 :            :                         break;
   14799                 :            :                 }
   14800                 :            : 
   14801                 :            : 
   14802                 :            :                 /* Attempt to send a request on each session */
   14803                 :          4 :                 ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
   14804                 :            :                         sessions[i],
   14805                 :            :                         ut_params,
   14806                 :            :                         ts_params,
   14807                 :            :                         catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
   14808                 :            :                         catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
   14809                 :            :                         aes_cbc_iv);
   14810                 :            : 
   14811                 :            :                 /* free crypto operation structure */
   14812                 :          4 :                 rte_crypto_op_free(ut_params->op);
   14813                 :          4 :                 ut_params->op = NULL;
   14814                 :            : 
   14815                 :            :                 /*
   14816                 :            :                  * free mbuf - both obuf and ibuf are usually the same,
   14817                 :            :                  * so check if they point at the same address is necessary,
   14818                 :            :                  * to avoid freeing the mbuf twice.
   14819                 :            :                  */
   14820         [ +  - ]:          4 :                 if (ut_params->obuf) {
   14821                 :          4 :                         rte_pktmbuf_free(ut_params->obuf);
   14822         [ +  - ]:          4 :                         if (ut_params->ibuf == ut_params->obuf)
   14823                 :          4 :                                 ut_params->ibuf = 0;
   14824                 :          4 :                         ut_params->obuf = 0;
   14825                 :            :                 }
   14826         [ -  + ]:          4 :                 if (ut_params->ibuf) {
   14827                 :          0 :                         rte_pktmbuf_free(ut_params->ibuf);
   14828                 :          0 :                         ut_params->ibuf = 0;
   14829                 :            :                 }
   14830                 :            : 
   14831         [ -  + ]:          4 :                 if (ret != TEST_SUCCESS) {
   14832                 :          0 :                         i++;
   14833                 :          0 :                         break;
   14834                 :            :                 }
   14835                 :            :         }
   14836                 :            : 
   14837                 :            :         nb_sess = i;
   14838                 :            : 
   14839         [ +  + ]:          5 :         for (i = 0; i < nb_sess; i++) {
   14840                 :          4 :                 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
   14841                 :          4 :                                 sessions[i]);
   14842                 :            :         }
   14843                 :            : 
   14844                 :          1 :         rte_free(sessions);
   14845                 :            : 
   14846         [ +  - ]:          1 :         if (ret != TEST_SKIPPED)
   14847         [ -  + ]:          1 :                 TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
   14848                 :            : 
   14849                 :            :         return ret;
   14850                 :            : }
   14851                 :            : 
   14852                 :            : struct multi_session_params {
   14853                 :            :         struct crypto_unittest_params ut_params;
   14854                 :            :         uint8_t *cipher_key;
   14855                 :            :         uint8_t *hmac_key;
   14856                 :            :         const uint8_t *cipher;
   14857                 :            :         const uint8_t *digest;
   14858                 :            :         uint8_t *iv;
   14859                 :            : };
   14860                 :            : 
   14861                 :            : #define MB_SESSION_NUMBER 3
   14862                 :            : 
   14863                 :            : static int
   14864                 :          1 : test_multi_session_random_usage(void)
   14865                 :            : {
   14866                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14867                 :            :         struct rte_cryptodev_info dev_info;
   14868                 :            :         int index = 0, ret = TEST_SUCCESS;
   14869                 :            :         uint32_t nb_sess, i, j;
   14870                 :            :         void **sessions;
   14871                 :          1 :         struct multi_session_params ut_paramz[] = {
   14872                 :            : 
   14873                 :            :                 {
   14874                 :            :                         .cipher_key = ms_aes_cbc_key0,
   14875                 :            :                         .hmac_key = ms_hmac_key0,
   14876                 :            :                         .cipher = ms_aes_cbc_cipher0,
   14877                 :            :                         .digest = ms_hmac_digest0,
   14878                 :            :                         .iv = ms_aes_cbc_iv0
   14879                 :            :                 },
   14880                 :            :                 {
   14881                 :            :                         .cipher_key = ms_aes_cbc_key1,
   14882                 :            :                         .hmac_key = ms_hmac_key1,
   14883                 :            :                         .cipher = ms_aes_cbc_cipher1,
   14884                 :            :                         .digest = ms_hmac_digest1,
   14885                 :            :                         .iv = ms_aes_cbc_iv1
   14886                 :            :                 },
   14887                 :            :                 {
   14888                 :            :                         .cipher_key = ms_aes_cbc_key2,
   14889                 :            :                         .hmac_key = ms_hmac_key2,
   14890                 :            :                         .cipher = ms_aes_cbc_cipher2,
   14891                 :            :                         .digest = ms_hmac_digest2,
   14892                 :            :                         .iv = ms_aes_cbc_iv2
   14893                 :            :                 },
   14894                 :            : 
   14895                 :            :         };
   14896                 :            : 
   14897                 :            :         /* Verify the capabilities */
   14898                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14899                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14900                 :          1 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
   14901         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14902                 :            :                         &cap_idx) == NULL)
   14903                 :            :                 return TEST_SKIPPED;
   14904                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   14905                 :          1 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
   14906         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14907                 :            :                         &cap_idx) == NULL)
   14908                 :            :                 return TEST_SKIPPED;
   14909                 :            : 
   14910                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   14911                 :            : 
   14912                 :          1 :         sessions = rte_malloc(NULL, (sizeof(void *)
   14913                 :            :                                         * MAX_NB_SESSIONS) + 1, 0);
   14914                 :            : 
   14915         [ +  + ]:          4 :         for (i = 0; i < MB_SESSION_NUMBER; i++) {
   14916                 :            : 
   14917                 :          3 :                 ut_paramz[i].ut_params = unittest_params;
   14918                 :            : 
   14919                 :          3 :                 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
   14920                 :            :                                 &ut_paramz[i].ut_params,
   14921                 :            :                                 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
   14922                 :            : 
   14923                 :            :                 /* Create multiple crypto sessions*/
   14924                 :          6 :                 sessions[i] = rte_cryptodev_sym_session_create(
   14925                 :          3 :                                 ts_params->valid_devs[0],
   14926                 :            :                                 &ut_paramz[i].ut_params.auth_xform,
   14927                 :            :                                 ts_params->session_mpool);
   14928         [ -  + ]:          3 :                 if (sessions[i] == NULL) {
   14929                 :            :                         nb_sess = i;
   14930         [ #  # ]:          0 :                         if (rte_errno == ENOTSUP)
   14931                 :            :                                 ret = TEST_SKIPPED;
   14932                 :            :                         else {
   14933                 :            :                                 ret = TEST_FAILED;
   14934                 :            :                                 printf("TestCase %s() line %d failed : "
   14935                 :            :                                                 "Session creation failed at session number %u",
   14936                 :            :                                                 __func__, __LINE__, i);
   14937                 :            :                         }
   14938                 :          0 :                         goto session_clear;
   14939                 :            :                 }
   14940                 :            : 
   14941                 :            :         }
   14942                 :            : 
   14943                 :            :         nb_sess = i;
   14944                 :            : 
   14945                 :          1 :         srand(time(NULL));
   14946         [ +  - ]:          1 :         for (i = 0; i < 40000; i++) {
   14947                 :            : 
   14948                 :          1 :                 j = rand() % MB_SESSION_NUMBER;
   14949                 :            : 
   14950                 :          1 :                 ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
   14951                 :          1 :                                         sessions[j],
   14952                 :            :                                         &ut_paramz[j].ut_params,
   14953                 :            :                                         ts_params, ut_paramz[j].cipher,
   14954                 :            :                                         ut_paramz[j].digest,
   14955                 :          1 :                                         ut_paramz[j].iv);
   14956                 :            : 
   14957                 :          1 :                 rte_crypto_op_free(ut_paramz[j].ut_params.op);
   14958                 :          1 :                 ut_paramz[j].ut_params.op = NULL;
   14959                 :            : 
   14960                 :            :                 /*
   14961                 :            :                  * free mbuf - both obuf and ibuf are usually the same,
   14962                 :            :                  * so check if they point at the same address is necessary,
   14963                 :            :                  * to avoid freeing the mbuf twice.
   14964                 :            :                  */
   14965         [ +  - ]:          1 :                 if (ut_paramz[j].ut_params.obuf) {
   14966                 :          1 :                         rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
   14967                 :          1 :                         if (ut_paramz[j].ut_params.ibuf
   14968         [ +  - ]:          1 :                                         == ut_paramz[j].ut_params.obuf)
   14969                 :          1 :                                 ut_paramz[j].ut_params.ibuf = 0;
   14970                 :          1 :                         ut_paramz[j].ut_params.obuf = 0;
   14971                 :            :                 }
   14972         [ -  + ]:          1 :                 if (ut_paramz[j].ut_params.ibuf) {
   14973                 :          0 :                         rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
   14974                 :          0 :                         ut_paramz[j].ut_params.ibuf = 0;
   14975                 :            :                 }
   14976                 :            : 
   14977         [ +  - ]:          1 :                 if (ret != TEST_SKIPPED) {
   14978                 :          1 :                         index = i;
   14979                 :          1 :                         break;
   14980                 :            :                 }
   14981                 :            :         }
   14982                 :            : 
   14983                 :          0 : session_clear:
   14984         [ +  + ]:          4 :         for (i = 0; i < nb_sess; i++) {
   14985                 :          3 :                 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
   14986                 :          3 :                                 sessions[i]);
   14987                 :            :         }
   14988                 :            : 
   14989                 :          1 :         rte_free(sessions);
   14990                 :            : 
   14991         [ +  - ]:          1 :         if (ret != TEST_SKIPPED)
   14992         [ -  + ]:          1 :                 TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
   14993                 :            : 
   14994                 :            :         return TEST_SUCCESS;
   14995                 :            : }
   14996                 :            : 
   14997                 :            : uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
   14998                 :            :                         0xab, 0xab, 0xab, 0xab,
   14999                 :            :                         0xab, 0xab, 0xab, 0xab,
   15000                 :            :                         0xab, 0xab, 0xab, 0xab};
   15001                 :            : 
   15002                 :            : static int
   15003                 :          0 : test_null_invalid_operation(void)
   15004                 :            : {
   15005                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15006                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15007                 :            : 
   15008                 :            :         /* This test is for NULL PMD only */
   15009         [ #  # ]:          0 :         if (gbl_driver_id != rte_cryptodev_driver_id_get(
   15010                 :            :                         RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
   15011                 :            :                 return TEST_SKIPPED;
   15012                 :            : 
   15013                 :            :         /* Setup Cipher Parameters */
   15014                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   15015                 :          0 :         ut_params->cipher_xform.next = NULL;
   15016                 :            : 
   15017                 :          0 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
   15018                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
   15019                 :            : 
   15020                 :            :         /* Create Crypto session*/
   15021                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(
   15022                 :          0 :                         ts_params->valid_devs[0], &ut_params->cipher_xform,
   15023                 :            :                         ts_params->session_mpool);
   15024   [ #  #  #  # ]:          0 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   15025                 :            :                 return TEST_SKIPPED;
   15026         [ #  # ]:          0 :         TEST_ASSERT(ut_params->sess == NULL,
   15027                 :            :                         "Session creation succeeded unexpectedly");
   15028                 :            : 
   15029                 :            :         /* Setup HMAC Parameters */
   15030                 :          0 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15031                 :          0 :         ut_params->auth_xform.next = NULL;
   15032                 :            : 
   15033                 :          0 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
   15034                 :          0 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
   15035                 :            : 
   15036                 :            :         /* Create Crypto session*/
   15037                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(
   15038                 :          0 :                         ts_params->valid_devs[0], &ut_params->auth_xform,
   15039                 :            :                         ts_params->session_mpool);
   15040   [ #  #  #  # ]:          0 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   15041                 :            :                 return TEST_SKIPPED;
   15042         [ #  # ]:          0 :         TEST_ASSERT(ut_params->sess == NULL,
   15043                 :            :                         "Session creation succeeded unexpectedly");
   15044                 :            : 
   15045                 :            :         return TEST_SUCCESS;
   15046                 :            : }
   15047                 :            : 
   15048                 :            : 
   15049                 :            : #define NULL_BURST_LENGTH (32)
   15050                 :            : 
   15051                 :            : static int
   15052                 :          0 : test_null_burst_operation(void)
   15053                 :            : {
   15054                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15055                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15056                 :            : 
   15057                 :            :         unsigned i, burst_len = NULL_BURST_LENGTH;
   15058                 :            : 
   15059                 :          0 :         struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
   15060                 :          0 :         struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
   15061                 :            : 
   15062                 :            :         /* This test is for NULL PMD only */
   15063         [ #  # ]:          0 :         if (gbl_driver_id != rte_cryptodev_driver_id_get(
   15064                 :            :                         RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
   15065                 :            :                 return TEST_SKIPPED;
   15066                 :            : 
   15067                 :            :         /* Setup Cipher Parameters */
   15068                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   15069                 :          0 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
   15070                 :            : 
   15071                 :          0 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
   15072                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
   15073                 :            : 
   15074                 :            :         /* Setup HMAC Parameters */
   15075                 :          0 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15076                 :          0 :         ut_params->auth_xform.next = NULL;
   15077                 :            : 
   15078                 :          0 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
   15079                 :          0 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
   15080                 :            : 
   15081                 :            :         /* Create Crypto session*/
   15082                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(
   15083                 :          0 :                                 ts_params->valid_devs[0],
   15084                 :            :                                 &ut_params->auth_xform,
   15085                 :            :                                 ts_params->session_mpool);
   15086   [ #  #  #  # ]:          0 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   15087                 :            :                 return TEST_SKIPPED;
   15088         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   15089                 :            : 
   15090         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
   15091                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
   15092                 :            :                         burst_len, "failed to generate burst of crypto ops");
   15093                 :            : 
   15094                 :            :         /* Generate an operation for each mbuf in burst */
   15095         [ #  # ]:          0 :         for (i = 0; i < burst_len; i++) {
   15096                 :          0 :                 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   15097                 :            : 
   15098         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
   15099                 :            : 
   15100                 :            :                 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
   15101                 :            :                                 sizeof(unsigned));
   15102                 :          0 :                 *data = i;
   15103                 :            : 
   15104         [ #  # ]:          0 :                 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
   15105                 :            : 
   15106                 :          0 :                 burst[i]->sym->m_src = m;
   15107                 :            :         }
   15108                 :            : 
   15109                 :            :         /* Process crypto operation */
   15110         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
   15111                 :            :                         0, burst, burst_len),
   15112                 :            :                         burst_len,
   15113                 :            :                         "Error enqueuing burst");
   15114                 :            : 
   15115         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
   15116                 :            :                         0, burst_dequeued, burst_len),
   15117                 :            :                         burst_len,
   15118                 :            :                         "Error dequeuing burst");
   15119                 :            : 
   15120                 :            : 
   15121         [ #  # ]:          0 :         for (i = 0; i < burst_len; i++) {
   15122         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(
   15123                 :            :                         *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
   15124                 :            :                         *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
   15125                 :            :                                         uint32_t *),
   15126                 :            :                         "data not as expected");
   15127                 :            : 
   15128                 :          0 :                 rte_pktmbuf_free(burst[i]->sym->m_src);
   15129                 :          0 :                 rte_crypto_op_free(burst[i]);
   15130                 :            :         }
   15131                 :            : 
   15132                 :            :         return TEST_SUCCESS;
   15133                 :            : }
   15134                 :            : 
   15135                 :            : static uint16_t
   15136                 :          0 : test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
   15137                 :            :                   uint16_t nb_ops, void *user_param)
   15138                 :            : {
   15139                 :            :         RTE_SET_USED(dev_id);
   15140                 :            :         RTE_SET_USED(qp_id);
   15141                 :            :         RTE_SET_USED(ops);
   15142                 :            :         RTE_SET_USED(user_param);
   15143                 :            : 
   15144                 :          0 :         enq_cb_called = true;
   15145                 :            :         printf("crypto enqueue callback called\n");
   15146                 :          0 :         return nb_ops;
   15147                 :            : }
   15148                 :            : 
   15149                 :            : static uint16_t
   15150                 :          0 : test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
   15151                 :            :                   uint16_t nb_ops, void *user_param)
   15152                 :            : {
   15153                 :            :         RTE_SET_USED(dev_id);
   15154                 :            :         RTE_SET_USED(qp_id);
   15155                 :            :         RTE_SET_USED(ops);
   15156                 :            :         RTE_SET_USED(user_param);
   15157                 :            : 
   15158                 :          0 :         deq_cb_called = true;
   15159                 :            :         printf("crypto dequeue callback called\n");
   15160                 :          0 :         return nb_ops;
   15161                 :            : }
   15162                 :            : 
   15163                 :            : /*
   15164                 :            :  * Process enqueue/dequeue NULL crypto request to verify callback with RCU.
   15165                 :            :  */
   15166                 :            : static int
   15167                 :          0 : test_enqdeq_callback_null_cipher(void)
   15168                 :            : {
   15169                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15170                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15171                 :            : 
   15172                 :            :         /* Setup Cipher Parameters */
   15173                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   15174                 :          0 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
   15175                 :            : 
   15176                 :          0 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
   15177                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
   15178                 :            : 
   15179                 :            :         /* Setup Auth Parameters */
   15180                 :          0 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15181                 :          0 :         ut_params->auth_xform.next = NULL;
   15182                 :            : 
   15183                 :          0 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
   15184                 :          0 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
   15185                 :            : 
   15186                 :            :         /* Create Crypto session */
   15187                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
   15188                 :            :                                 &ut_params->auth_xform, ts_params->session_mpool);
   15189   [ #  #  #  # ]:          0 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   15190                 :            :                 return TEST_SKIPPED;
   15191         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   15192                 :            : 
   15193                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   15194         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
   15195                 :            : 
   15196                 :            :         /* Allocate mbuf */
   15197                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   15198         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf, "Failed to allocate mbuf");
   15199                 :            : 
   15200                 :            :         /* Append some random data */
   15201         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->ibuf, sizeof(unsigned int)),
   15202                 :            :                         "no room to append data");
   15203                 :            : 
   15204         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   15205                 :            : 
   15206                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
   15207                 :            : 
   15208                 :            :         /* Process crypto operation */
   15209         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], ut_params->op),
   15210                 :            :                         "failed to process sym crypto op");
   15211                 :            : 
   15212                 :            :         return 0;
   15213                 :            : }
   15214                 :            : 
   15215                 :            : static int
   15216                 :          1 : test_enq_callback_setup(void)
   15217                 :            : {
   15218                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15219                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   15220                 :            :         struct rte_cryptodev_info dev_info;
   15221                 :          1 :         struct rte_cryptodev_qp_conf qp_conf = {
   15222                 :            :                 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
   15223                 :            :         };
   15224                 :            : 
   15225                 :            :         struct rte_cryptodev_cb *cb;
   15226                 :            :         uint16_t qp_id = 0;
   15227                 :            :         int j = 0;
   15228                 :            : 
   15229                 :            :         /* Skip test if synchronous API is used */
   15230         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   15231                 :            :                 return TEST_SKIPPED;
   15232                 :            : 
   15233                 :            :         /* Verify the crypto capabilities for which enqueue/dequeue is done. */
   15234                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15235                 :          1 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
   15236         [ -  + ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15237                 :            :                         &cap_idx) == NULL)
   15238                 :            :                 return TEST_SKIPPED;
   15239                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   15240                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
   15241         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15242                 :            :                         &cap_idx) == NULL)
   15243                 :            :                 return TEST_SKIPPED;
   15244                 :            : 
   15245                 :            :         /* Stop the device in case it's started so it can be configured */
   15246                 :          0 :         rte_cryptodev_stop(ts_params->valid_devs[0]);
   15247                 :            : 
   15248                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   15249                 :            : 
   15250         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
   15251                 :            :                         &ts_params->conf),
   15252                 :            :                         "Failed to configure cryptodev %u",
   15253                 :            :                         ts_params->valid_devs[0]);
   15254                 :            : 
   15255                 :          0 :         qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
   15256                 :          0 :         qp_conf.mp_session = ts_params->session_mpool;
   15257                 :            : 
   15258         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
   15259                 :            :                         ts_params->valid_devs[0], qp_id, &qp_conf,
   15260                 :            :                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
   15261                 :            :                         "Failed test for "
   15262                 :            :                         "rte_cryptodev_queue_pair_setup: num_inflights "
   15263                 :            :                         "%u on qp %u on cryptodev %u",
   15264                 :            :                         qp_conf.nb_descriptors, qp_id,
   15265                 :            :                         ts_params->valid_devs[0]);
   15266                 :            : 
   15267                 :          0 :         enq_cb_called = false;
   15268                 :            :         /* Test with invalid crypto device */
   15269                 :          0 :         cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
   15270                 :            :                         qp_id, test_enq_callback, NULL);
   15271         [ #  # ]:          0 :         if (rte_errno == ENOTSUP) {
   15272                 :          0 :                 RTE_LOG(ERR, USER1, "%s line %d: "
   15273                 :            :                         "rte_cryptodev_add_enq_callback() "
   15274                 :            :                         "Not supported, skipped\n", __func__, __LINE__);
   15275                 :          0 :                 return TEST_SKIPPED;
   15276                 :            :         }
   15277         [ #  # ]:          0 :         TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
   15278                 :            :                         "cryptodev %u did not fail",
   15279                 :            :                         qp_id, RTE_CRYPTO_MAX_DEVS);
   15280                 :            : 
   15281                 :            :         /* Test with invalid queue pair */
   15282                 :          0 :         cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
   15283                 :          0 :                         dev_info.max_nb_queue_pairs + 1,
   15284                 :            :                         test_enq_callback, NULL);
   15285         [ #  # ]:          0 :         TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
   15286                 :            :                         "cryptodev %u did not fail",
   15287                 :            :                         dev_info.max_nb_queue_pairs + 1,
   15288                 :            :                         ts_params->valid_devs[0]);
   15289                 :            : 
   15290                 :            :         /* Test with NULL callback */
   15291                 :          0 :         cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
   15292                 :            :                         qp_id, NULL, NULL);
   15293         [ #  # ]:          0 :         TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
   15294                 :            :                         "cryptodev %u did not fail",
   15295                 :            :                         qp_id, ts_params->valid_devs[0]);
   15296                 :            : 
   15297                 :            :         /* Test with valid configuration */
   15298                 :          0 :         cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
   15299                 :            :                         qp_id, test_enq_callback, NULL);
   15300         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
   15301                 :            :                         "qp %u on cryptodev %u",
   15302                 :            :                         qp_id, ts_params->valid_devs[0]);
   15303                 :            : 
   15304                 :          0 :         rte_cryptodev_start(ts_params->valid_devs[0]);
   15305                 :            : 
   15306         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto Processing failed");
   15307                 :            : 
   15308                 :            :         /* Wait until callback not called. */
   15309   [ #  #  #  # ]:          0 :         while (!enq_cb_called && (j++ < 10))
   15310                 :            :                 rte_delay_ms(10);
   15311                 :            : 
   15312                 :            :         /* Test with invalid crypto device */
   15313         [ #  # ]:          0 :         TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
   15314                 :            :                         RTE_CRYPTO_MAX_DEVS, qp_id, cb),
   15315                 :            :                         "Expected call to fail as crypto device is invalid");
   15316                 :            : 
   15317                 :            :         /* Test with invalid queue pair */
   15318         [ #  # ]:          0 :         TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
   15319                 :            :                         ts_params->valid_devs[0],
   15320                 :            :                         dev_info.max_nb_queue_pairs + 1, cb),
   15321                 :            :                         "Expected call to fail as queue pair is invalid");
   15322                 :            : 
   15323                 :            :         /* Test with NULL callback */
   15324         [ #  # ]:          0 :         TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
   15325                 :            :                         ts_params->valid_devs[0], qp_id, NULL),
   15326                 :            :                         "Expected call to fail as callback is NULL");
   15327                 :            : 
   15328                 :            :         /* Test with valid configuration */
   15329         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
   15330                 :            :                         ts_params->valid_devs[0], qp_id, cb),
   15331                 :            :                         "Failed test to remove callback on "
   15332                 :            :                         "qp %u on cryptodev %u",
   15333                 :            :                         qp_id, ts_params->valid_devs[0]);
   15334                 :            : 
   15335         [ #  # ]:          0 :         TEST_ASSERT(enq_cb_called == true, "Crypto enqueue callback not called");
   15336                 :            : 
   15337                 :            :         return TEST_SUCCESS;
   15338                 :            : }
   15339                 :            : 
   15340                 :            : static int
   15341                 :          1 : test_deq_callback_setup(void)
   15342                 :            : {
   15343                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15344                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   15345                 :            :         struct rte_cryptodev_info dev_info;
   15346                 :          1 :         struct rte_cryptodev_qp_conf qp_conf = {
   15347                 :            :                 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
   15348                 :            :         };
   15349                 :            : 
   15350                 :            :         struct rte_cryptodev_cb *cb;
   15351                 :            :         uint16_t qp_id = 0;
   15352                 :            :         int j = 0;
   15353                 :            : 
   15354                 :            :         /* Skip test if synchronous API is used */
   15355         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   15356                 :            :                 return TEST_SKIPPED;
   15357                 :            : 
   15358                 :            :         /* Verify the crypto capabilities for which enqueue/dequeue is done. */
   15359                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15360                 :          1 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
   15361         [ -  + ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15362                 :            :                         &cap_idx) == NULL)
   15363                 :            :                 return TEST_SKIPPED;
   15364                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   15365                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
   15366         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15367                 :            :                         &cap_idx) == NULL)
   15368                 :            :                 return TEST_SKIPPED;
   15369                 :            : 
   15370                 :            :         /* Stop the device in case it's started so it can be configured */
   15371                 :          0 :         rte_cryptodev_stop(ts_params->valid_devs[0]);
   15372                 :            : 
   15373                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   15374                 :            : 
   15375         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
   15376                 :            :                         &ts_params->conf),
   15377                 :            :                         "Failed to configure cryptodev %u",
   15378                 :            :                         ts_params->valid_devs[0]);
   15379                 :            : 
   15380                 :          0 :         qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
   15381                 :          0 :         qp_conf.mp_session = ts_params->session_mpool;
   15382                 :            : 
   15383         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
   15384                 :            :                         ts_params->valid_devs[0], qp_id, &qp_conf,
   15385                 :            :                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
   15386                 :            :                         "Failed test for "
   15387                 :            :                         "rte_cryptodev_queue_pair_setup: num_inflights "
   15388                 :            :                         "%u on qp %u on cryptodev %u",
   15389                 :            :                         qp_conf.nb_descriptors, qp_id,
   15390                 :            :                         ts_params->valid_devs[0]);
   15391                 :            : 
   15392                 :          0 :         deq_cb_called = false;
   15393                 :            :         /* Test with invalid crypto device */
   15394                 :          0 :         cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
   15395                 :            :                         qp_id, test_deq_callback, NULL);
   15396         [ #  # ]:          0 :         if (rte_errno == ENOTSUP) {
   15397                 :          0 :                 RTE_LOG(ERR, USER1, "%s line %d: "
   15398                 :            :                         "rte_cryptodev_add_deq_callback() "
   15399                 :            :                         "Not supported, skipped\n", __func__, __LINE__);
   15400                 :          0 :                 return TEST_SKIPPED;
   15401                 :            :         }
   15402         [ #  # ]:          0 :         TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
   15403                 :            :                         "cryptodev %u did not fail",
   15404                 :            :                         qp_id, RTE_CRYPTO_MAX_DEVS);
   15405                 :            : 
   15406                 :            :         /* Test with invalid queue pair */
   15407                 :          0 :         cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
   15408                 :          0 :                         dev_info.max_nb_queue_pairs + 1,
   15409                 :            :                         test_deq_callback, NULL);
   15410         [ #  # ]:          0 :         TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
   15411                 :            :                         "cryptodev %u did not fail",
   15412                 :            :                         dev_info.max_nb_queue_pairs + 1,
   15413                 :            :                         ts_params->valid_devs[0]);
   15414                 :            : 
   15415                 :            :         /* Test with NULL callback */
   15416                 :          0 :         cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
   15417                 :            :                         qp_id, NULL, NULL);
   15418         [ #  # ]:          0 :         TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
   15419                 :            :                         "cryptodev %u did not fail",
   15420                 :            :                         qp_id, ts_params->valid_devs[0]);
   15421                 :            : 
   15422                 :            :         /* Test with valid configuration */
   15423                 :          0 :         cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
   15424                 :            :                         qp_id, test_deq_callback, NULL);
   15425         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
   15426                 :            :                         "qp %u on cryptodev %u",
   15427                 :            :                         qp_id, ts_params->valid_devs[0]);
   15428                 :            : 
   15429                 :          0 :         rte_cryptodev_start(ts_params->valid_devs[0]);
   15430                 :            : 
   15431         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto processing failed");
   15432                 :            : 
   15433                 :            :         /* Wait until callback not called. */
   15434   [ #  #  #  # ]:          0 :         while (!deq_cb_called && (j++ < 10))
   15435                 :            :                 rte_delay_ms(10);
   15436                 :            : 
   15437                 :            :         /* Test with invalid crypto device */
   15438         [ #  # ]:          0 :         TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
   15439                 :            :                         RTE_CRYPTO_MAX_DEVS, qp_id, cb),
   15440                 :            :                         "Expected call to fail as crypto device is invalid");
   15441                 :            : 
   15442                 :            :         /* Test with invalid queue pair */
   15443         [ #  # ]:          0 :         TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
   15444                 :            :                         ts_params->valid_devs[0],
   15445                 :            :                         dev_info.max_nb_queue_pairs + 1, cb),
   15446                 :            :                         "Expected call to fail as queue pair is invalid");
   15447                 :            : 
   15448                 :            :         /* Test with NULL callback */
   15449         [ #  # ]:          0 :         TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
   15450                 :            :                         ts_params->valid_devs[0], qp_id, NULL),
   15451                 :            :                         "Expected call to fail as callback is NULL");
   15452                 :            : 
   15453                 :            :         /* Test with valid configuration */
   15454         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
   15455                 :            :                         ts_params->valid_devs[0], qp_id, cb),
   15456                 :            :                         "Failed test to remove callback on "
   15457                 :            :                         "qp %u on cryptodev %u",
   15458                 :            :                         qp_id, ts_params->valid_devs[0]);
   15459                 :            : 
   15460         [ #  # ]:          0 :         TEST_ASSERT(deq_cb_called == true, "Crypto dequeue callback not called");
   15461                 :            : 
   15462                 :            :         return TEST_SUCCESS;
   15463                 :            : }
   15464                 :            : 
   15465                 :            : static void
   15466                 :            : generate_gmac_large_plaintext(uint8_t *data)
   15467                 :            : {
   15468                 :            :         uint16_t i;
   15469                 :            : 
   15470   [ +  +  +  + ]:       4084 :         for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
   15471                 :       4082 :                 memcpy(&data[i], &data[0], 32);
   15472                 :            : }
   15473                 :            : 
   15474                 :            : static int
   15475                 :          8 : create_gmac_operation(enum rte_crypto_auth_operation op,
   15476                 :            :                 const struct gmac_test_data *tdata)
   15477                 :            : {
   15478                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15479                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15480                 :            :         struct rte_crypto_sym_op *sym_op;
   15481                 :            : 
   15482                 :          8 :         uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
   15483                 :            : 
   15484                 :            :         /* Generate Crypto op data structure */
   15485                 :          8 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   15486                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   15487         [ -  + ]:          8 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   15488                 :            :                         "Failed to allocate symmetric crypto operation struct");
   15489                 :            : 
   15490                 :            :         sym_op = ut_params->op->sym;
   15491                 :            : 
   15492                 :         16 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
   15493                 :          8 :                         ut_params->ibuf, tdata->gmac_tag.len);
   15494         [ -  + ]:          8 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
   15495                 :            :                         "no room to append digest");
   15496                 :            : 
   15497         [ +  + ]:          8 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
   15498                 :            :                         ut_params->ibuf, plaintext_pad_len);
   15499                 :            : 
   15500         [ +  + ]:          8 :         if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
   15501                 :          4 :                 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
   15502         [ -  + ]:          4 :                                 tdata->gmac_tag.len);
   15503                 :          4 :                 debug_hexdump(stdout, "digest:",
   15504                 :          4 :                                 sym_op->auth.digest.data,
   15505                 :          4 :                                 tdata->gmac_tag.len);
   15506                 :            :         }
   15507                 :            : 
   15508                 :          8 :         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
   15509                 :            :                         uint8_t *, IV_OFFSET);
   15510                 :            : 
   15511         [ -  + ]:          8 :         rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
   15512                 :            : 
   15513                 :          8 :         debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
   15514                 :            : 
   15515                 :          8 :         sym_op->cipher.data.length = 0;
   15516                 :          8 :         sym_op->cipher.data.offset = 0;
   15517                 :            : 
   15518                 :          8 :         sym_op->auth.data.offset = 0;
   15519                 :          8 :         sym_op->auth.data.length = tdata->plaintext.len;
   15520                 :            : 
   15521                 :          8 :         return 0;
   15522                 :            : }
   15523                 :            : 
   15524                 :            : static int
   15525                 :          0 : create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
   15526                 :            :                 const struct gmac_test_data *tdata,
   15527                 :            :                 void *digest_mem, uint64_t digest_phys)
   15528                 :            : {
   15529                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15530                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15531                 :            :         struct rte_crypto_sym_op *sym_op;
   15532                 :            : 
   15533                 :            :         /* Generate Crypto op data structure */
   15534                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   15535                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   15536         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   15537                 :            :                         "Failed to allocate symmetric crypto operation struct");
   15538                 :            : 
   15539                 :            :         sym_op = ut_params->op->sym;
   15540                 :            : 
   15541                 :          0 :         sym_op->auth.digest.data = digest_mem;
   15542         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
   15543                 :            :                         "no room to append digest");
   15544                 :            : 
   15545                 :          0 :         sym_op->auth.digest.phys_addr = digest_phys;
   15546                 :            : 
   15547         [ #  # ]:          0 :         if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
   15548                 :          0 :                 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
   15549         [ #  # ]:          0 :                                 tdata->gmac_tag.len);
   15550                 :          0 :                 debug_hexdump(stdout, "digest:",
   15551                 :          0 :                                 sym_op->auth.digest.data,
   15552                 :          0 :                                 tdata->gmac_tag.len);
   15553                 :            :         }
   15554                 :            : 
   15555                 :          0 :         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
   15556                 :            :                         uint8_t *, IV_OFFSET);
   15557                 :            : 
   15558         [ #  # ]:          0 :         rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
   15559                 :            : 
   15560                 :          0 :         debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
   15561                 :            : 
   15562                 :          0 :         sym_op->cipher.data.length = 0;
   15563                 :          0 :         sym_op->cipher.data.offset = 0;
   15564                 :            : 
   15565                 :          0 :         sym_op->auth.data.offset = 0;
   15566                 :          0 :         sym_op->auth.data.length = tdata->plaintext.len;
   15567                 :            : 
   15568                 :          0 :         return 0;
   15569                 :            : }
   15570                 :            : 
   15571                 :          8 : static int create_gmac_session(uint8_t dev_id,
   15572                 :            :                 const struct gmac_test_data *tdata,
   15573                 :            :                 enum rte_crypto_auth_operation auth_op)
   15574                 :            : {
   15575                 :          8 :         uint8_t *auth_key = alloca(tdata->key.len);
   15576                 :            : 
   15577                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15578                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15579                 :            : 
   15580                 :          8 :         memcpy(auth_key, tdata->key.data, tdata->key.len);
   15581                 :            : 
   15582                 :          8 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15583                 :          8 :         ut_params->auth_xform.next = NULL;
   15584                 :            : 
   15585                 :          8 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
   15586                 :          8 :         ut_params->auth_xform.auth.op = auth_op;
   15587                 :          8 :         ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
   15588                 :          8 :         ut_params->auth_xform.auth.key.length = tdata->key.len;
   15589                 :          8 :         ut_params->auth_xform.auth.key.data = auth_key;
   15590                 :          8 :         ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
   15591                 :          8 :         ut_params->auth_xform.auth.iv.length = tdata->iv.len;
   15592                 :            : 
   15593                 :            : 
   15594                 :          8 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
   15595                 :            :                         &ut_params->auth_xform, ts_params->session_mpool);
   15596   [ -  +  -  - ]:          8 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   15597                 :            :                 return TEST_SKIPPED;
   15598         [ -  + ]:          8 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   15599                 :            : 
   15600                 :            :         return 0;
   15601                 :            : }
   15602                 :            : 
   15603                 :            : static int
   15604                 :          4 : test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
   15605                 :            : {
   15606                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15607                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15608                 :            :         struct rte_cryptodev_info dev_info;
   15609                 :            : 
   15610                 :          4 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   15611                 :          4 :         uint64_t feat_flags = dev_info.feature_flags;
   15612                 :            : 
   15613         [ -  + ]:          4 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   15614         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   15615                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   15616                 :          0 :                 return TEST_SKIPPED;
   15617                 :            :         }
   15618                 :            : 
   15619                 :            :         int retval;
   15620                 :            : 
   15621                 :            :         uint8_t *auth_tag, *plaintext;
   15622                 :            :         uint16_t plaintext_pad_len;
   15623                 :            : 
   15624         [ -  + ]:          4 :         TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
   15625                 :            :                               "No GMAC length in the source data");
   15626                 :            : 
   15627                 :            :         /* Verify the capabilities */
   15628                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   15629                 :          4 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15630                 :          4 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
   15631         [ +  - ]:          4 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15632                 :            :                         &cap_idx) == NULL)
   15633                 :            :                 return TEST_SKIPPED;
   15634                 :            : 
   15635                 :          4 :         retval = create_gmac_session(ts_params->valid_devs[0],
   15636                 :            :                         tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
   15637                 :            : 
   15638         [ +  - ]:          4 :         if (retval == TEST_SKIPPED)
   15639                 :            :                 return TEST_SKIPPED;
   15640         [ +  - ]:          4 :         if (retval < 0)
   15641                 :            :                 return retval;
   15642                 :            : 
   15643         [ +  + ]:          4 :         if (tdata->plaintext.len > MBUF_SIZE)
   15644                 :          1 :                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
   15645                 :            :         else
   15646                 :          3 :                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   15647         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   15648                 :            :                         "Failed to allocate input buffer in mempool");
   15649                 :            : 
   15650         [ +  + ]:          4 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   15651                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   15652                 :            : 
   15653                 :          4 :         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
   15654                 :            :         /*
   15655                 :            :          * Runtime generate the large plain text instead of use hard code
   15656                 :            :          * plain text vector. It is done to avoid create huge source file
   15657                 :            :          * with the test vector.
   15658                 :            :          */
   15659         [ +  + ]:          4 :         if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
   15660                 :          1 :                 generate_gmac_large_plaintext(tdata->plaintext.data);
   15661                 :            : 
   15662                 :          4 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   15663                 :            :                                 plaintext_pad_len);
   15664         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
   15665                 :            : 
   15666                 :          4 :         memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
   15667                 :          4 :         debug_hexdump(stdout, "plaintext:", plaintext,
   15668                 :          4 :                         tdata->plaintext.len);
   15669                 :            : 
   15670                 :          4 :         retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
   15671                 :            :                         tdata);
   15672                 :            : 
   15673         [ +  - ]:          4 :         if (retval < 0)
   15674                 :            :                 return retval;
   15675                 :            : 
   15676         [ +  - ]:          4 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   15677                 :            : 
   15678                 :          4 :         ut_params->op->sym->m_src = ut_params->ibuf;
   15679                 :            : 
   15680         [ -  + ]:          4 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   15681                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   15682                 :            :                         ut_params->op);
   15683         [ -  + ]:          4 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   15684                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
   15685                 :            :                                                0);
   15686         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   15687                 :            :                         return retval;
   15688                 :            :         } else
   15689         [ -  + ]:          4 :                 TEST_ASSERT_NOT_NULL(
   15690                 :            :                         process_crypto_request(ts_params->valid_devs[0],
   15691                 :            :                         ut_params->op), "failed to process sym crypto op");
   15692                 :            : 
   15693         [ -  + ]:          4 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   15694                 :            :                         "crypto op processing failed");
   15695                 :            : 
   15696         [ -  + ]:          4 :         if (ut_params->op->sym->m_dst) {
   15697                 :          0 :                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
   15698                 :            :                                 uint8_t *, plaintext_pad_len);
   15699                 :            :         } else {
   15700                 :          4 :                 auth_tag = plaintext + plaintext_pad_len;
   15701                 :            :         }
   15702                 :            : 
   15703                 :          4 :         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
   15704                 :            : 
   15705         [ -  + ]:          4 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   15706                 :            :                         auth_tag,
   15707                 :            :                         tdata->gmac_tag.data,
   15708                 :            :                         tdata->gmac_tag.len,
   15709                 :            :                         "GMAC Generated auth tag not as expected");
   15710                 :            : 
   15711                 :            :         return 0;
   15712                 :            : }
   15713                 :            : 
   15714                 :            : static int
   15715                 :          1 : test_AES_GMAC_authentication_test_case_1(void)
   15716                 :            : {
   15717                 :          1 :         return test_AES_GMAC_authentication(&gmac_test_case_1);
   15718                 :            : }
   15719                 :            : 
   15720                 :            : static int
   15721                 :          1 : test_AES_GMAC_authentication_test_case_2(void)
   15722                 :            : {
   15723                 :          1 :         return test_AES_GMAC_authentication(&gmac_test_case_2);
   15724                 :            : }
   15725                 :            : 
   15726                 :            : static int
   15727                 :          1 : test_AES_GMAC_authentication_test_case_3(void)
   15728                 :            : {
   15729                 :          1 :         return test_AES_GMAC_authentication(&gmac_test_case_3);
   15730                 :            : }
   15731                 :            : 
   15732                 :            : static int
   15733                 :          1 : test_AES_GMAC_authentication_test_case_4(void)
   15734                 :            : {
   15735                 :          1 :         return test_AES_GMAC_authentication(&gmac_test_case_4);
   15736                 :            : }
   15737                 :            : 
   15738                 :            : static int
   15739                 :          4 : test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
   15740                 :            : {
   15741                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15742                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15743                 :            :         int retval;
   15744                 :            :         uint32_t plaintext_pad_len;
   15745                 :            :         uint8_t *plaintext;
   15746                 :            :         struct rte_cryptodev_info dev_info;
   15747                 :            : 
   15748                 :          4 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   15749                 :          4 :         uint64_t feat_flags = dev_info.feature_flags;
   15750                 :            : 
   15751         [ -  + ]:          4 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   15752         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   15753                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   15754                 :          0 :                 return TEST_SKIPPED;
   15755                 :            :         }
   15756                 :            : 
   15757         [ -  + ]:          4 :         TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
   15758                 :            :                               "No GMAC length in the source data");
   15759                 :            : 
   15760                 :            :         /* Verify the capabilities */
   15761                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   15762                 :          4 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15763                 :          4 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
   15764         [ +  - ]:          4 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15765                 :            :                         &cap_idx) == NULL)
   15766                 :            :                 return TEST_SKIPPED;
   15767                 :            : 
   15768                 :          4 :         retval = create_gmac_session(ts_params->valid_devs[0],
   15769                 :            :                         tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
   15770                 :            : 
   15771         [ +  - ]:          4 :         if (retval == TEST_SKIPPED)
   15772                 :            :                 return TEST_SKIPPED;
   15773         [ +  - ]:          4 :         if (retval < 0)
   15774                 :            :                 return retval;
   15775                 :            : 
   15776         [ +  + ]:          4 :         if (tdata->plaintext.len > MBUF_SIZE)
   15777                 :          1 :                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
   15778                 :            :         else
   15779                 :          3 :                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   15780         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   15781                 :            :                         "Failed to allocate input buffer in mempool");
   15782                 :            : 
   15783         [ +  + ]:          4 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   15784                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   15785                 :            : 
   15786                 :          4 :         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
   15787                 :            : 
   15788                 :            :         /*
   15789                 :            :          * Runtime generate the large plain text instead of use hard code
   15790                 :            :          * plain text vector. It is done to avoid create huge source file
   15791                 :            :          * with the test vector.
   15792                 :            :          */
   15793         [ +  + ]:          4 :         if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
   15794                 :          1 :                 generate_gmac_large_plaintext(tdata->plaintext.data);
   15795                 :            : 
   15796                 :          4 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   15797                 :            :                                 plaintext_pad_len);
   15798         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
   15799                 :            : 
   15800                 :          4 :         memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
   15801                 :          4 :         debug_hexdump(stdout, "plaintext:", plaintext,
   15802                 :          4 :                         tdata->plaintext.len);
   15803                 :            : 
   15804                 :          4 :         retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
   15805                 :            :                         tdata);
   15806                 :            : 
   15807         [ +  - ]:          4 :         if (retval < 0)
   15808                 :            :                 return retval;
   15809                 :            : 
   15810         [ +  - ]:          4 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   15811                 :            : 
   15812                 :          4 :         ut_params->op->sym->m_src = ut_params->ibuf;
   15813                 :            : 
   15814         [ -  + ]:          4 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   15815                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   15816                 :            :                         ut_params->op);
   15817         [ -  + ]:          4 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   15818                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
   15819                 :            :                                                0);
   15820         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   15821                 :            :                         return retval;
   15822                 :            :         } else
   15823         [ -  + ]:          4 :                 TEST_ASSERT_NOT_NULL(
   15824                 :            :                         process_crypto_request(ts_params->valid_devs[0],
   15825                 :            :                         ut_params->op), "failed to process sym crypto op");
   15826                 :            : 
   15827         [ -  + ]:          4 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   15828                 :            :                         "crypto op processing failed");
   15829                 :            : 
   15830                 :            :         return 0;
   15831                 :            : 
   15832                 :            : }
   15833                 :            : 
   15834                 :            : static int
   15835                 :          1 : test_AES_GMAC_authentication_verify_test_case_1(void)
   15836                 :            : {
   15837                 :          1 :         return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
   15838                 :            : }
   15839                 :            : 
   15840                 :            : static int
   15841                 :          1 : test_AES_GMAC_authentication_verify_test_case_2(void)
   15842                 :            : {
   15843                 :          1 :         return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
   15844                 :            : }
   15845                 :            : 
   15846                 :            : static int
   15847                 :          1 : test_AES_GMAC_authentication_verify_test_case_3(void)
   15848                 :            : {
   15849                 :          1 :         return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
   15850                 :            : }
   15851                 :            : 
   15852                 :            : static int
   15853                 :          1 : test_AES_GMAC_authentication_verify_test_case_4(void)
   15854                 :            : {
   15855                 :          1 :         return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
   15856                 :            : }
   15857                 :            : 
   15858                 :            : static int
   15859                 :          4 : test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
   15860                 :            :                                 uint32_t fragsz)
   15861                 :            : {
   15862                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15863                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15864                 :            :         struct rte_cryptodev_info dev_info;
   15865                 :            :         uint64_t feature_flags;
   15866                 :            :         unsigned int trn_data = 0;
   15867                 :            :         void *digest_mem = NULL;
   15868                 :            :         unsigned int to_trn = 0;
   15869                 :            :         struct rte_mbuf *buf = NULL;
   15870                 :            :         uint8_t *auth_tag, *plaintext;
   15871                 :            :         int retval;
   15872                 :            : 
   15873         [ -  + ]:          4 :         TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
   15874                 :            :                               "No GMAC length in the source data");
   15875                 :            : 
   15876                 :            :         /* Verify the capabilities */
   15877                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   15878                 :          4 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15879                 :          4 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
   15880         [ +  - ]:          4 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15881                 :            :                         &cap_idx) == NULL)
   15882                 :            :                 return TEST_SKIPPED;
   15883                 :            : 
   15884                 :            :         /* Check for any input SGL support */
   15885                 :          4 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   15886                 :          4 :         feature_flags = dev_info.feature_flags;
   15887                 :            : 
   15888                 :          4 :         if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
   15889         [ -  + ]:          4 :                         (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
   15890                 :            :                         (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
   15891                 :            :                 return TEST_SKIPPED;
   15892                 :            : 
   15893                 :          0 :         if (fragsz > tdata->plaintext.len)
   15894                 :            :                 fragsz = tdata->plaintext.len;
   15895                 :            : 
   15896                 :          0 :         uint16_t plaintext_len = fragsz;
   15897                 :            : 
   15898                 :          0 :         retval = create_gmac_session(ts_params->valid_devs[0],
   15899                 :            :                         tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
   15900                 :            : 
   15901         [ #  # ]:          0 :         if (retval == TEST_SKIPPED)
   15902                 :            :                 return TEST_SKIPPED;
   15903         [ #  # ]:          0 :         if (retval < 0)
   15904                 :            :                 return retval;
   15905                 :            : 
   15906                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   15907         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   15908                 :            :                         "Failed to allocate input buffer in mempool");
   15909                 :            : 
   15910                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   15911                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   15912                 :            : 
   15913                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   15914                 :            :                                 plaintext_len);
   15915         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
   15916                 :            : 
   15917                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
   15918                 :            : 
   15919                 :            :         trn_data += plaintext_len;
   15920                 :            : 
   15921                 :          0 :         buf = ut_params->ibuf;
   15922                 :            : 
   15923                 :            :         /*
   15924                 :            :          * Loop until no more fragments
   15925                 :            :          */
   15926                 :            : 
   15927         [ #  # ]:          0 :         while (trn_data < tdata->plaintext.len) {
   15928                 :          0 :                 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
   15929                 :            :                                 (tdata->plaintext.len - trn_data) : fragsz;
   15930                 :            : 
   15931                 :          0 :                 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   15932                 :            :                 buf = buf->next;
   15933                 :          0 :                 ut_params->ibuf->nb_segs++;
   15934                 :            : 
   15935                 :          0 :                 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
   15936                 :            :                                 rte_pktmbuf_tailroom(buf));
   15937                 :            : 
   15938                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   15939                 :            :                                 to_trn);
   15940         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(plaintext, "Failed to append plaintext");
   15941                 :            : 
   15942         [ #  # ]:          0 :                 memcpy(plaintext, tdata->plaintext.data + trn_data,
   15943                 :            :                                 to_trn);
   15944                 :          0 :                 trn_data += to_trn;
   15945         [ #  # ]:          0 :                 if (trn_data  == tdata->plaintext.len) {
   15946                 :          0 :                         digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   15947                 :          0 :                                         tdata->gmac_tag.len);
   15948         [ #  # ]:          0 :                         TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append digest data");
   15949                 :            :                 }
   15950                 :            :         }
   15951                 :            : 
   15952                 :            :         /*
   15953                 :            :          * Place digest at the end of the last buffer
   15954                 :            :          */
   15955                 :          0 :         uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
   15956                 :            : 
   15957         [ #  # ]:          0 :         if (!digest_mem) {
   15958                 :          0 :                 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   15959                 :          0 :                                 + tdata->gmac_tag.len);
   15960                 :          0 :                 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
   15961                 :            :                                 tdata->plaintext.len);
   15962                 :            :         }
   15963                 :            : 
   15964                 :          0 :         retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
   15965                 :            :                         tdata, digest_mem, digest_phys);
   15966                 :            : 
   15967         [ #  # ]:          0 :         if (retval < 0)
   15968                 :            :                 return retval;
   15969                 :            : 
   15970         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   15971                 :            : 
   15972                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
   15973                 :            : 
   15974         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   15975                 :            :                 return TEST_SKIPPED;
   15976                 :            : 
   15977         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(
   15978                 :            :                 process_crypto_request(ts_params->valid_devs[0],
   15979                 :            :                 ut_params->op), "failed to process sym crypto op");
   15980                 :            : 
   15981         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   15982                 :            :                         "crypto op processing failed");
   15983                 :            : 
   15984                 :            :         auth_tag = digest_mem;
   15985                 :          0 :         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
   15986         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   15987                 :            :                         auth_tag,
   15988                 :            :                         tdata->gmac_tag.data,
   15989                 :            :                         tdata->gmac_tag.len,
   15990                 :            :                         "GMAC Generated auth tag not as expected");
   15991                 :            : 
   15992                 :            :         return 0;
   15993                 :            : }
   15994                 :            : 
   15995                 :            : /* Segment size not multiple of block size (16B) */
   15996                 :            : static int
   15997                 :          1 : test_AES_GMAC_authentication_SGL_40B(void)
   15998                 :            : {
   15999                 :          1 :         return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
   16000                 :            : }
   16001                 :            : 
   16002                 :            : static int
   16003                 :          1 : test_AES_GMAC_authentication_SGL_80B(void)
   16004                 :            : {
   16005                 :          1 :         return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
   16006                 :            : }
   16007                 :            : 
   16008                 :            : static int
   16009                 :          1 : test_AES_GMAC_authentication_SGL_2048B(void)
   16010                 :            : {
   16011                 :          1 :         return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
   16012                 :            : }
   16013                 :            : 
   16014                 :            : /* Segment size not multiple of block size (16B) */
   16015                 :            : static int
   16016                 :          1 : test_AES_GMAC_authentication_SGL_2047B(void)
   16017                 :            : {
   16018                 :          1 :         return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
   16019                 :            : }
   16020                 :            : 
   16021                 :            : struct test_crypto_vector {
   16022                 :            :         enum rte_crypto_cipher_algorithm crypto_algo;
   16023                 :            :         unsigned int cipher_offset;
   16024                 :            :         unsigned int cipher_len;
   16025                 :            : 
   16026                 :            :         struct {
   16027                 :            :                 uint8_t data[64];
   16028                 :            :                 unsigned int len;
   16029                 :            :         } cipher_key;
   16030                 :            : 
   16031                 :            :         struct {
   16032                 :            :                 uint8_t data[64];
   16033                 :            :                 unsigned int len;
   16034                 :            :         } iv;
   16035                 :            : 
   16036                 :            :         struct {
   16037                 :            :                 const uint8_t *data;
   16038                 :            :                 unsigned int len;
   16039                 :            :         } plaintext;
   16040                 :            : 
   16041                 :            :         struct {
   16042                 :            :                 const uint8_t *data;
   16043                 :            :                 unsigned int len;
   16044                 :            :         } ciphertext;
   16045                 :            : 
   16046                 :            :         enum rte_crypto_auth_algorithm auth_algo;
   16047                 :            :         unsigned int auth_offset;
   16048                 :            : 
   16049                 :            :         struct {
   16050                 :            :                 uint8_t data[128];
   16051                 :            :                 unsigned int len;
   16052                 :            :         } auth_key;
   16053                 :            : 
   16054                 :            :         struct {
   16055                 :            :                 const uint8_t *data;
   16056                 :            :                 unsigned int len;
   16057                 :            :         } aad;
   16058                 :            : 
   16059                 :            :         struct {
   16060                 :            :                 uint8_t data[128];
   16061                 :            :                 unsigned int len;
   16062                 :            :         } digest;
   16063                 :            : };
   16064                 :            : 
   16065                 :            : static const struct test_crypto_vector
   16066                 :            : hmac_sha1_test_crypto_vector = {
   16067                 :            :         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
   16068                 :            :         .plaintext = {
   16069                 :            :                 .data = plaintext_hash,
   16070                 :            :                 .len = 512
   16071                 :            :         },
   16072                 :            :         .auth_key = {
   16073                 :            :                 .data = {
   16074                 :            :                         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
   16075                 :            :                         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
   16076                 :            :                         0xDE, 0xF4, 0xDE, 0xAD
   16077                 :            :                 },
   16078                 :            :                 .len = 20
   16079                 :            :         },
   16080                 :            :         .digest = {
   16081                 :            :                 .data = {
   16082                 :            :                         0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
   16083                 :            :                         0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
   16084                 :            :                         0x3F, 0x91, 0x64, 0x59
   16085                 :            :                 },
   16086                 :            :                 .len = 20
   16087                 :            :         }
   16088                 :            : };
   16089                 :            : 
   16090                 :            : static const struct test_crypto_vector
   16091                 :            : aes128_gmac_test_vector = {
   16092                 :            :         .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
   16093                 :            :         .plaintext = {
   16094                 :            :                 .data = plaintext_hash,
   16095                 :            :                 .len = 512
   16096                 :            :         },
   16097                 :            :         .iv = {
   16098                 :            :                 .data = {
   16099                 :            :                         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
   16100                 :            :                         0x08, 0x09, 0x0A, 0x0B
   16101                 :            :                 },
   16102                 :            :                 .len = 12
   16103                 :            :         },
   16104                 :            :         .auth_key = {
   16105                 :            :                 .data = {
   16106                 :            :                         0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
   16107                 :            :                         0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
   16108                 :            :                 },
   16109                 :            :                 .len = 16
   16110                 :            :         },
   16111                 :            :         .digest = {
   16112                 :            :                 .data = {
   16113                 :            :                         0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
   16114                 :            :                         0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
   16115                 :            :                 },
   16116                 :            :                 .len = 16
   16117                 :            :         }
   16118                 :            : };
   16119                 :            : 
   16120                 :            : static const struct test_crypto_vector
   16121                 :            : aes128cbc_hmac_sha1_test_vector = {
   16122                 :            :         .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
   16123                 :            :         .cipher_offset = 0,
   16124                 :            :         .cipher_len = 512,
   16125                 :            :         .cipher_key = {
   16126                 :            :                 .data = {
   16127                 :            :                         0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
   16128                 :            :                         0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
   16129                 :            :                 },
   16130                 :            :                 .len = 16
   16131                 :            :         },
   16132                 :            :         .iv = {
   16133                 :            :                 .data = {
   16134                 :            :                         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
   16135                 :            :                         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
   16136                 :            :                 },
   16137                 :            :                 .len = 16
   16138                 :            :         },
   16139                 :            :         .plaintext = {
   16140                 :            :                 .data = plaintext_hash,
   16141                 :            :                 .len = 512
   16142                 :            :         },
   16143                 :            :         .ciphertext = {
   16144                 :            :                 .data = ciphertext512_aes128cbc,
   16145                 :            :                 .len = 512
   16146                 :            :         },
   16147                 :            :         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
   16148                 :            :         .auth_offset = 0,
   16149                 :            :         .auth_key = {
   16150                 :            :                 .data = {
   16151                 :            :                         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
   16152                 :            :                         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
   16153                 :            :                         0xDE, 0xF4, 0xDE, 0xAD
   16154                 :            :                 },
   16155                 :            :                 .len = 20
   16156                 :            :         },
   16157                 :            :         .digest = {
   16158                 :            :                 .data = {
   16159                 :            :                         0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
   16160                 :            :                         0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
   16161                 :            :                         0x18, 0x8C, 0x1D, 0x32
   16162                 :            :                 },
   16163                 :            :                 .len = 20
   16164                 :            :         }
   16165                 :            : };
   16166                 :            : 
   16167                 :            : static const struct test_crypto_vector
   16168                 :            : aes128cbc_hmac_sha1_aad_test_vector = {
   16169                 :            :         .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
   16170                 :            :         .cipher_offset = 8,
   16171                 :            :         .cipher_len = 496,
   16172                 :            :         .cipher_key = {
   16173                 :            :                 .data = {
   16174                 :            :                         0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
   16175                 :            :                         0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
   16176                 :            :                 },
   16177                 :            :                 .len = 16
   16178                 :            :         },
   16179                 :            :         .iv = {
   16180                 :            :                 .data = {
   16181                 :            :                         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
   16182                 :            :                         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
   16183                 :            :                 },
   16184                 :            :                 .len = 16
   16185                 :            :         },
   16186                 :            :         .plaintext = {
   16187                 :            :                 .data = plaintext_hash,
   16188                 :            :                 .len = 512
   16189                 :            :         },
   16190                 :            :         .ciphertext = {
   16191                 :            :                 .data = ciphertext512_aes128cbc_aad,
   16192                 :            :                 .len = 512
   16193                 :            :         },
   16194                 :            :         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
   16195                 :            :         .auth_offset = 0,
   16196                 :            :         .auth_key = {
   16197                 :            :                 .data = {
   16198                 :            :                         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
   16199                 :            :                         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
   16200                 :            :                         0xDE, 0xF4, 0xDE, 0xAD
   16201                 :            :                 },
   16202                 :            :                 .len = 20
   16203                 :            :         },
   16204                 :            :         .digest = {
   16205                 :            :                 .data = {
   16206                 :            :                         0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
   16207                 :            :                         0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
   16208                 :            :                         0x62, 0x0F, 0xFB, 0x10
   16209                 :            :                 },
   16210                 :            :                 .len = 20
   16211                 :            :         }
   16212                 :            : };
   16213                 :            : 
   16214                 :            : static void
   16215                 :            : data_corruption(uint8_t *data)
   16216                 :            : {
   16217                 :          3 :         data[0] += 1;
   16218                 :          3 : }
   16219                 :            : 
   16220                 :            : static void
   16221                 :            : tag_corruption(uint8_t *data, unsigned int tag_offset)
   16222                 :            : {
   16223                 :          3 :         data[tag_offset] += 1;
   16224                 :          3 : }
   16225                 :            : 
   16226                 :            : static int
   16227                 :          2 : create_auth_session(struct crypto_unittest_params *ut_params,
   16228                 :            :                 uint8_t dev_id,
   16229                 :            :                 const struct test_crypto_vector *reference,
   16230                 :            :                 enum rte_crypto_auth_operation auth_op)
   16231                 :            : {
   16232                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   16233                 :          2 :         uint8_t *auth_key = alloca(reference->auth_key.len + 1);
   16234                 :            : 
   16235                 :          2 :         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
   16236                 :            : 
   16237                 :            :         /* Setup Authentication Parameters */
   16238                 :          2 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16239                 :          2 :         ut_params->auth_xform.auth.op = auth_op;
   16240                 :          2 :         ut_params->auth_xform.next = NULL;
   16241                 :          2 :         ut_params->auth_xform.auth.algo = reference->auth_algo;
   16242                 :          2 :         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
   16243                 :          2 :         ut_params->auth_xform.auth.key.data = auth_key;
   16244                 :          2 :         ut_params->auth_xform.auth.digest_length = reference->digest.len;
   16245                 :            : 
   16246                 :            :         /* Create Crypto session*/
   16247                 :          2 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
   16248                 :            :                                 &ut_params->auth_xform,
   16249                 :            :                                 ts_params->session_mpool);
   16250   [ -  +  -  - ]:          2 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   16251                 :            :                 return TEST_SKIPPED;
   16252         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   16253                 :            : 
   16254                 :            :         return 0;
   16255                 :            : }
   16256                 :            : 
   16257                 :            : static int
   16258                 :          4 : create_auth_cipher_session(struct crypto_unittest_params *ut_params,
   16259                 :            :                 uint8_t dev_id,
   16260                 :            :                 const struct test_crypto_vector *reference,
   16261                 :            :                 enum rte_crypto_auth_operation auth_op,
   16262                 :            :                 enum rte_crypto_cipher_operation cipher_op)
   16263                 :            : {
   16264                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   16265                 :          4 :         uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
   16266                 :          4 :         uint8_t *auth_key = alloca(reference->auth_key.len + 1);
   16267                 :            : 
   16268         [ +  + ]:          4 :         memcpy(cipher_key, reference->cipher_key.data,
   16269                 :            :                         reference->cipher_key.len);
   16270                 :          4 :         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
   16271                 :            : 
   16272                 :            :         /* Setup Authentication Parameters */
   16273                 :          4 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16274                 :          4 :         ut_params->auth_xform.auth.op = auth_op;
   16275                 :          4 :         ut_params->auth_xform.auth.algo = reference->auth_algo;
   16276                 :          4 :         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
   16277                 :          4 :         ut_params->auth_xform.auth.key.data = auth_key;
   16278                 :          4 :         ut_params->auth_xform.auth.digest_length = reference->digest.len;
   16279                 :            : 
   16280         [ +  + ]:          4 :         if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
   16281                 :          2 :                 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
   16282                 :          2 :                 ut_params->auth_xform.auth.iv.length = reference->iv.len;
   16283                 :            :         } else {
   16284                 :          2 :                 ut_params->auth_xform.next = &ut_params->cipher_xform;
   16285                 :            : 
   16286                 :            :                 /* Setup Cipher Parameters */
   16287                 :          2 :                 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   16288                 :          2 :                 ut_params->cipher_xform.next = NULL;
   16289                 :          2 :                 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
   16290                 :          2 :                 ut_params->cipher_xform.cipher.op = cipher_op;
   16291                 :          2 :                 ut_params->cipher_xform.cipher.key.data = cipher_key;
   16292                 :          2 :                 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
   16293                 :          2 :                 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   16294                 :          2 :                 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
   16295                 :            :         }
   16296                 :            : 
   16297                 :            :         /* Create Crypto session*/
   16298                 :          4 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
   16299                 :            :                                 &ut_params->auth_xform,
   16300                 :            :                                 ts_params->session_mpool);
   16301   [ -  +  -  - ]:          4 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   16302                 :            :                 return TEST_SKIPPED;
   16303         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   16304                 :            : 
   16305                 :            :         return 0;
   16306                 :            : }
   16307                 :            : 
   16308                 :            : static int
   16309                 :          2 : create_auth_operation(struct crypto_testsuite_params *ts_params,
   16310                 :            :                 struct crypto_unittest_params *ut_params,
   16311                 :            :                 const struct test_crypto_vector *reference,
   16312                 :            :                 unsigned int auth_generate)
   16313                 :            : {
   16314                 :            :         /* Generate Crypto op data structure */
   16315                 :          2 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   16316                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   16317         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   16318                 :            :                         "Failed to allocate pktmbuf offload");
   16319                 :            : 
   16320                 :            :         /* Set crypto operation data parameters */
   16321         [ +  - ]:          2 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   16322                 :            : 
   16323                 :          2 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
   16324                 :            : 
   16325                 :            :         /* set crypto operation source mbuf */
   16326                 :          2 :         sym_op->m_src = ut_params->ibuf;
   16327                 :            : 
   16328                 :            :         /* digest */
   16329                 :          4 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
   16330                 :          2 :                         ut_params->ibuf, reference->digest.len);
   16331                 :            : 
   16332         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
   16333                 :            :                         "no room to append auth tag");
   16334                 :            : 
   16335         [ -  + ]:          2 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
   16336                 :            :                         ut_params->ibuf, reference->plaintext.len);
   16337                 :            : 
   16338         [ -  + ]:          2 :         if (auth_generate)
   16339                 :          0 :                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
   16340                 :            :         else
   16341                 :          2 :                 memcpy(sym_op->auth.digest.data,
   16342                 :          2 :                                 reference->digest.data,
   16343                 :          2 :                                 reference->digest.len);
   16344                 :            : 
   16345                 :          2 :         debug_hexdump(stdout, "digest:",
   16346                 :          2 :                         sym_op->auth.digest.data,
   16347                 :          2 :                         reference->digest.len);
   16348                 :            : 
   16349                 :          2 :         sym_op->auth.data.length = reference->plaintext.len;
   16350                 :          2 :         sym_op->auth.data.offset = 0;
   16351                 :            : 
   16352                 :          2 :         return 0;
   16353                 :            : }
   16354                 :            : 
   16355                 :            : static int
   16356                 :          2 : create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
   16357                 :            :                 struct crypto_unittest_params *ut_params,
   16358                 :            :                 const struct test_crypto_vector *reference,
   16359                 :            :                 unsigned int auth_generate)
   16360                 :            : {
   16361                 :            :         /* Generate Crypto op data structure */
   16362                 :          2 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   16363                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   16364         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   16365                 :            :                         "Failed to allocate pktmbuf offload");
   16366                 :            : 
   16367                 :            :         /* Set crypto operation data parameters */
   16368         [ +  - ]:          2 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   16369                 :            : 
   16370                 :          2 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
   16371                 :            : 
   16372                 :            :         /* set crypto operation source mbuf */
   16373                 :          2 :         sym_op->m_src = ut_params->ibuf;
   16374                 :            : 
   16375                 :            :         /* digest */
   16376                 :          4 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
   16377                 :          2 :                         ut_params->ibuf, reference->digest.len);
   16378                 :            : 
   16379         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
   16380                 :            :                         "no room to append auth tag");
   16381                 :            : 
   16382         [ -  + ]:          2 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
   16383                 :            :                         ut_params->ibuf, reference->ciphertext.len);
   16384                 :            : 
   16385         [ -  + ]:          2 :         if (auth_generate)
   16386                 :          0 :                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
   16387                 :            :         else
   16388                 :          2 :                 memcpy(sym_op->auth.digest.data,
   16389                 :          2 :                                 reference->digest.data,
   16390                 :          2 :                                 reference->digest.len);
   16391                 :            : 
   16392                 :          2 :         debug_hexdump(stdout, "digest:",
   16393                 :          2 :                         sym_op->auth.digest.data,
   16394                 :          2 :                         reference->digest.len);
   16395                 :            : 
   16396                 :          2 :         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
   16397         [ -  + ]:          2 :                         reference->iv.data, reference->iv.len);
   16398                 :            : 
   16399                 :          2 :         sym_op->cipher.data.length = 0;
   16400                 :          2 :         sym_op->cipher.data.offset = 0;
   16401                 :            : 
   16402                 :          2 :         sym_op->auth.data.length = reference->plaintext.len;
   16403                 :          2 :         sym_op->auth.data.offset = 0;
   16404                 :            : 
   16405                 :          2 :         return 0;
   16406                 :            : }
   16407                 :            : 
   16408                 :            : static int
   16409                 :          4 : create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
   16410                 :            :                 struct crypto_unittest_params *ut_params,
   16411                 :            :                 const struct test_crypto_vector *reference,
   16412                 :            :                 unsigned int auth_generate)
   16413                 :            : {
   16414                 :            :         /* Generate Crypto op data structure */
   16415                 :          4 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   16416                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   16417         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   16418                 :            :                         "Failed to allocate pktmbuf offload");
   16419                 :            : 
   16420                 :            :         /* Set crypto operation data parameters */
   16421         [ +  - ]:          4 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   16422                 :            : 
   16423                 :          4 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
   16424                 :            : 
   16425                 :            :         /* set crypto operation source mbuf */
   16426                 :          4 :         sym_op->m_src = ut_params->ibuf;
   16427                 :            : 
   16428                 :            :         /* digest */
   16429                 :          8 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
   16430                 :          4 :                         ut_params->ibuf, reference->digest.len);
   16431                 :            : 
   16432         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
   16433                 :            :                         "no room to append auth tag");
   16434                 :            : 
   16435         [ -  + ]:          4 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
   16436                 :            :                         ut_params->ibuf, reference->ciphertext.len);
   16437                 :            : 
   16438         [ -  + ]:          4 :         if (auth_generate)
   16439                 :          0 :                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
   16440                 :            :         else
   16441                 :          4 :                 memcpy(sym_op->auth.digest.data,
   16442                 :          4 :                                 reference->digest.data,
   16443                 :          4 :                                 reference->digest.len);
   16444                 :            : 
   16445                 :          4 :         debug_hexdump(stdout, "digest:",
   16446                 :          4 :                         sym_op->auth.digest.data,
   16447                 :          4 :                         reference->digest.len);
   16448                 :            : 
   16449                 :          4 :         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
   16450         [ -  + ]:          4 :                         reference->iv.data, reference->iv.len);
   16451                 :            : 
   16452                 :          4 :         sym_op->cipher.data.length = reference->cipher_len;
   16453                 :          4 :         sym_op->cipher.data.offset = reference->cipher_offset;
   16454                 :            : 
   16455                 :          4 :         sym_op->auth.data.length = reference->plaintext.len;
   16456                 :          4 :         sym_op->auth.data.offset = reference->auth_offset;
   16457                 :            : 
   16458                 :          4 :         return 0;
   16459                 :            : }
   16460                 :            : 
   16461                 :            : static int
   16462                 :            : create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
   16463                 :            :                 struct crypto_unittest_params *ut_params,
   16464                 :            :                 const struct test_crypto_vector *reference)
   16465                 :            : {
   16466                 :          2 :         return create_auth_operation(ts_params, ut_params, reference, 0);
   16467                 :            : }
   16468                 :            : 
   16469                 :            : static int
   16470                 :            : create_auth_verify_GMAC_operation(
   16471                 :            :                 struct crypto_testsuite_params *ts_params,
   16472                 :            :                 struct crypto_unittest_params *ut_params,
   16473                 :            :                 const struct test_crypto_vector *reference)
   16474                 :            : {
   16475                 :          2 :         return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
   16476                 :            : }
   16477                 :            : 
   16478                 :            : static int
   16479                 :            : create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
   16480                 :            :                 struct crypto_unittest_params *ut_params,
   16481                 :            :                 const struct test_crypto_vector *reference)
   16482                 :            : {
   16483                 :          3 :         return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
   16484                 :            : }
   16485                 :            : 
   16486                 :            : static int
   16487                 :          2 : test_authentication_verify_fail_when_data_corruption(
   16488                 :            :                 struct crypto_testsuite_params *ts_params,
   16489                 :            :                 struct crypto_unittest_params *ut_params,
   16490                 :            :                 const struct test_crypto_vector *reference,
   16491                 :            :                 unsigned int data_corrupted)
   16492                 :            : {
   16493                 :            :         int retval;
   16494                 :            : 
   16495                 :            :         uint8_t *plaintext;
   16496                 :            :         struct rte_cryptodev_info dev_info;
   16497                 :            : 
   16498                 :          2 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   16499                 :          2 :         uint64_t feat_flags = dev_info.feature_flags;
   16500                 :            : 
   16501         [ -  + ]:          2 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   16502         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   16503                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   16504                 :          0 :                 return TEST_SKIPPED;
   16505                 :            :         }
   16506                 :            : 
   16507                 :            :         /* Verify the capabilities */
   16508                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   16509                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16510                 :          2 :         cap_idx.algo.auth = reference->auth_algo;
   16511         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16512                 :            :                         &cap_idx) == NULL)
   16513                 :            :                 return TEST_SKIPPED;
   16514                 :            : 
   16515                 :            : 
   16516                 :            :         /* Create session */
   16517                 :          2 :         retval = create_auth_session(ut_params,
   16518                 :          2 :                         ts_params->valid_devs[0],
   16519                 :            :                         reference,
   16520                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
   16521                 :            : 
   16522         [ +  - ]:          2 :         if (retval == TEST_SKIPPED)
   16523                 :            :                 return TEST_SKIPPED;
   16524         [ +  - ]:          2 :         if (retval < 0)
   16525                 :            :                 return retval;
   16526                 :            : 
   16527                 :          2 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   16528         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   16529                 :            :                         "Failed to allocate input buffer in mempool");
   16530                 :            : 
   16531                 :            :         /* clear mbuf payload */
   16532                 :          2 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   16533                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   16534                 :            : 
   16535                 :          2 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   16536                 :          2 :                         reference->plaintext.len);
   16537         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
   16538                 :          2 :         memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
   16539                 :            : 
   16540                 :          2 :         debug_hexdump(stdout, "plaintext:", plaintext,
   16541                 :          2 :                 reference->plaintext.len);
   16542                 :            : 
   16543                 :            :         /* Create operation */
   16544                 :            :         retval = create_auth_verify_operation(ts_params, ut_params, reference);
   16545                 :            : 
   16546         [ +  - ]:          2 :         if (retval < 0)
   16547                 :            :                 return retval;
   16548                 :            : 
   16549         [ +  + ]:          2 :         if (data_corrupted)
   16550                 :            :                 data_corruption(plaintext);
   16551                 :            :         else
   16552                 :          1 :                 tag_corruption(plaintext, reference->plaintext.len);
   16553                 :            : 
   16554         [ -  + ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
   16555                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   16556                 :            :                         ut_params->op);
   16557         [ #  # ]:          0 :                 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
   16558                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   16559                 :            :                         "authentication not failed");
   16560         [ -  + ]:          2 :         } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   16561                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
   16562                 :            :                                                0);
   16563         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   16564                 :            :                         return retval;
   16565                 :            :         } else {
   16566                 :          2 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
   16567                 :            :                         ut_params->op);
   16568                 :            :         }
   16569         [ -  + ]:          2 :         if (ut_params->op == NULL)
   16570                 :            :                 return 0;
   16571         [ #  # ]:          0 :         else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
   16572                 :          0 :                 return 0;
   16573                 :            : 
   16574                 :            :         return -1;
   16575                 :            : }
   16576                 :            : 
   16577                 :            : static int
   16578                 :          2 : test_authentication_verify_GMAC_fail_when_corruption(
   16579                 :            :                 struct crypto_testsuite_params *ts_params,
   16580                 :            :                 struct crypto_unittest_params *ut_params,
   16581                 :            :                 const struct test_crypto_vector *reference,
   16582                 :            :                 unsigned int data_corrupted)
   16583                 :            : {
   16584                 :            :         int retval;
   16585                 :            :         uint8_t *plaintext;
   16586                 :            :         struct rte_cryptodev_info dev_info;
   16587                 :            : 
   16588                 :          2 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   16589                 :          2 :         uint64_t feat_flags = dev_info.feature_flags;
   16590                 :            : 
   16591         [ -  + ]:          2 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   16592         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   16593                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   16594                 :          0 :                 return TEST_SKIPPED;
   16595                 :            :         }
   16596                 :            : 
   16597                 :            :         /* Verify the capabilities */
   16598                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   16599                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16600                 :          2 :         cap_idx.algo.auth = reference->auth_algo;
   16601         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16602                 :            :                         &cap_idx) == NULL)
   16603                 :            :                 return TEST_SKIPPED;
   16604                 :            : 
   16605                 :            :         /* Create session */
   16606                 :          2 :         retval = create_auth_cipher_session(ut_params,
   16607                 :          2 :                         ts_params->valid_devs[0],
   16608                 :            :                         reference,
   16609                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY,
   16610                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
   16611         [ +  - ]:          2 :         if (retval == TEST_SKIPPED)
   16612                 :            :                 return TEST_SKIPPED;
   16613         [ +  - ]:          2 :         if (retval < 0)
   16614                 :            :                 return retval;
   16615                 :            : 
   16616                 :          2 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   16617         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   16618                 :            :                         "Failed to allocate input buffer in mempool");
   16619                 :            : 
   16620                 :            :         /* clear mbuf payload */
   16621                 :          2 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   16622                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   16623                 :            : 
   16624                 :          2 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   16625                 :          2 :                         reference->plaintext.len);
   16626         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
   16627                 :          2 :         memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
   16628                 :            : 
   16629                 :          2 :         debug_hexdump(stdout, "plaintext:", plaintext,
   16630                 :          2 :                 reference->plaintext.len);
   16631                 :            : 
   16632                 :            :         /* Create operation */
   16633                 :            :         retval = create_auth_verify_GMAC_operation(ts_params,
   16634                 :            :                         ut_params,
   16635                 :            :                         reference);
   16636                 :            : 
   16637         [ +  - ]:          2 :         if (retval < 0)
   16638                 :            :                 return retval;
   16639                 :            : 
   16640         [ +  + ]:          2 :         if (data_corrupted)
   16641                 :            :                 data_corruption(plaintext);
   16642                 :            :         else
   16643                 :          1 :                 tag_corruption(plaintext, reference->aad.len);
   16644                 :            : 
   16645         [ -  + ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
   16646                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   16647                 :            :                         ut_params->op);
   16648         [ #  # ]:          0 :                 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
   16649                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   16650                 :            :                         "authentication not failed");
   16651         [ -  + ]:          2 :         } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   16652                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
   16653                 :            :                                                0);
   16654         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   16655                 :          0 :                         return retval;
   16656                 :            :         } else {
   16657                 :          2 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
   16658                 :            :                         ut_params->op);
   16659         [ -  + ]:          2 :                 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
   16660                 :            :         }
   16661                 :            : 
   16662                 :            :         return 0;
   16663                 :            : }
   16664                 :            : 
   16665                 :            : static int
   16666                 :          2 : test_authenticated_decryption_fail_when_corruption(
   16667                 :            :                 struct crypto_testsuite_params *ts_params,
   16668                 :            :                 struct crypto_unittest_params *ut_params,
   16669                 :            :                 const struct test_crypto_vector *reference,
   16670                 :            :                 unsigned int data_corrupted)
   16671                 :            : {
   16672                 :            :         int retval;
   16673                 :            : 
   16674                 :            :         uint8_t *ciphertext;
   16675                 :            :         struct rte_cryptodev_info dev_info;
   16676                 :            : 
   16677                 :          2 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   16678                 :          2 :         uint64_t feat_flags = dev_info.feature_flags;
   16679                 :            : 
   16680         [ -  + ]:          2 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   16681         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   16682                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   16683                 :          0 :                 return TEST_SKIPPED;
   16684                 :            :         }
   16685                 :            : 
   16686                 :            :         /* Verify the capabilities */
   16687                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   16688                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16689                 :          2 :         cap_idx.algo.auth = reference->auth_algo;
   16690         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16691                 :            :                         &cap_idx) == NULL)
   16692                 :            :                 return TEST_SKIPPED;
   16693                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   16694                 :          2 :         cap_idx.algo.cipher = reference->crypto_algo;
   16695         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16696                 :            :                         &cap_idx) == NULL)
   16697                 :            :                 return TEST_SKIPPED;
   16698                 :            : 
   16699                 :            :         /* Create session */
   16700                 :          2 :         retval = create_auth_cipher_session(ut_params,
   16701                 :          2 :                         ts_params->valid_devs[0],
   16702                 :            :                         reference,
   16703                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY,
   16704                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
   16705         [ +  - ]:          2 :         if (retval == TEST_SKIPPED)
   16706                 :            :                 return TEST_SKIPPED;
   16707         [ +  - ]:          2 :         if (retval < 0)
   16708                 :            :                 return retval;
   16709                 :            : 
   16710                 :          2 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   16711         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   16712                 :            :                         "Failed to allocate input buffer in mempool");
   16713                 :            : 
   16714                 :            :         /* clear mbuf payload */
   16715                 :          2 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   16716                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   16717                 :            : 
   16718                 :          2 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   16719                 :          2 :                         reference->ciphertext.len);
   16720         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
   16721                 :          2 :         memcpy(ciphertext, reference->ciphertext.data,
   16722                 :          2 :                         reference->ciphertext.len);
   16723                 :            : 
   16724                 :            :         /* Create operation */
   16725                 :            :         retval = create_cipher_auth_verify_operation(ts_params,
   16726                 :            :                         ut_params,
   16727                 :            :                         reference);
   16728                 :            : 
   16729         [ +  - ]:          2 :         if (retval < 0)
   16730                 :            :                 return retval;
   16731                 :            : 
   16732         [ +  + ]:          2 :         if (data_corrupted)
   16733                 :            :                 data_corruption(ciphertext);
   16734                 :            :         else
   16735                 :          1 :                 tag_corruption(ciphertext, reference->ciphertext.len);
   16736                 :            : 
   16737         [ -  + ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
   16738                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   16739                 :            :                         ut_params->op);
   16740         [ #  # ]:          0 :                 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
   16741                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   16742                 :            :                         "authentication not failed");
   16743         [ -  + ]:          2 :         } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   16744                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
   16745                 :            :                                                0);
   16746         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   16747                 :          0 :                         return retval;
   16748                 :            :         } else {
   16749                 :          2 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
   16750                 :            :                         ut_params->op);
   16751         [ -  + ]:          2 :                 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
   16752                 :            :         }
   16753                 :            : 
   16754                 :            :         return 0;
   16755                 :            : }
   16756                 :            : 
   16757                 :            : static int
   16758                 :          1 : test_authenticated_encrypt_with_esn(
   16759                 :            :                 struct crypto_testsuite_params *ts_params,
   16760                 :            :                 struct crypto_unittest_params *ut_params,
   16761                 :            :                 const struct test_crypto_vector *reference)
   16762                 :            : {
   16763                 :            :         int retval;
   16764                 :            : 
   16765                 :            :         uint8_t *authciphertext, *plaintext, *auth_tag;
   16766                 :            :         uint16_t plaintext_pad_len;
   16767                 :          1 :         uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
   16768                 :          1 :         uint8_t *auth_key = alloca(reference->auth_key.len + 1);
   16769                 :            :         struct rte_cryptodev_info dev_info;
   16770                 :            : 
   16771                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   16772                 :          1 :         uint64_t feat_flags = dev_info.feature_flags;
   16773                 :            : 
   16774         [ -  + ]:          1 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   16775         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   16776                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   16777                 :          0 :                 return TEST_SKIPPED;
   16778                 :            :         }
   16779                 :            : 
   16780                 :            :         /* Verify the capabilities */
   16781                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   16782                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16783                 :          1 :         cap_idx.algo.auth = reference->auth_algo;
   16784         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16785                 :            :                         &cap_idx) == NULL)
   16786                 :            :                 return TEST_SKIPPED;
   16787                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   16788                 :          1 :         cap_idx.algo.cipher = reference->crypto_algo;
   16789         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16790                 :            :                         &cap_idx) == NULL)
   16791                 :            :                 return TEST_SKIPPED;
   16792                 :            : 
   16793                 :            :         /* Create session */
   16794                 :          1 :         memcpy(cipher_key, reference->cipher_key.data,
   16795                 :          1 :                         reference->cipher_key.len);
   16796                 :          1 :         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
   16797                 :            : 
   16798                 :            :         /* Setup Cipher Parameters */
   16799                 :          1 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   16800                 :          1 :         ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
   16801                 :          1 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
   16802                 :          1 :         ut_params->cipher_xform.cipher.key.data = cipher_key;
   16803                 :          1 :         ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
   16804                 :          1 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   16805                 :          1 :         ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
   16806                 :            : 
   16807                 :          1 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
   16808                 :            : 
   16809                 :            :         /* Setup Authentication Parameters */
   16810                 :          1 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16811                 :          1 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
   16812                 :          1 :         ut_params->auth_xform.auth.algo = reference->auth_algo;
   16813                 :          1 :         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
   16814                 :          1 :         ut_params->auth_xform.auth.key.data = auth_key;
   16815                 :          1 :         ut_params->auth_xform.auth.digest_length = reference->digest.len;
   16816                 :          1 :         ut_params->auth_xform.next = NULL;
   16817                 :            : 
   16818                 :            :         /* Create Crypto session*/
   16819                 :          2 :         ut_params->sess = rte_cryptodev_sym_session_create(
   16820                 :          1 :                         ts_params->valid_devs[0], &ut_params->cipher_xform,
   16821                 :            :                         ts_params->session_mpool);
   16822   [ -  +  -  - ]:          1 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   16823                 :            :                 return TEST_SKIPPED;
   16824         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   16825                 :            : 
   16826                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   16827         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   16828                 :            :                         "Failed to allocate input buffer in mempool");
   16829                 :            : 
   16830                 :            :         /* clear mbuf payload */
   16831                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   16832                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   16833                 :            : 
   16834                 :          1 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   16835                 :          1 :                         reference->plaintext.len);
   16836         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
   16837                 :          1 :         memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
   16838                 :            : 
   16839                 :            :         /* Create operation */
   16840                 :          1 :         retval = create_cipher_auth_operation(ts_params,
   16841                 :            :                         ut_params,
   16842                 :            :                         reference, 0);
   16843                 :            : 
   16844         [ +  - ]:          1 :         if (retval < 0)
   16845                 :            :                 return retval;
   16846                 :            : 
   16847         [ -  + ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   16848                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   16849                 :            :                         ut_params->op);
   16850         [ -  + ]:          1 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   16851                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
   16852                 :            :                                                0);
   16853         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   16854                 :            :                         return retval;
   16855                 :            :         } else
   16856                 :          1 :                 ut_params->op = process_crypto_request(
   16857                 :          1 :                         ts_params->valid_devs[0], ut_params->op);
   16858                 :            : 
   16859         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
   16860                 :            : 
   16861         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   16862                 :            :                         "crypto op processing failed");
   16863                 :            : 
   16864                 :          1 :         plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
   16865                 :            : 
   16866                 :          1 :         authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
   16867                 :            :                         ut_params->op->sym->auth.data.offset);
   16868                 :          1 :         auth_tag = authciphertext + plaintext_pad_len;
   16869                 :          1 :         debug_hexdump(stdout, "ciphertext:", authciphertext,
   16870                 :          1 :                         reference->ciphertext.len);
   16871                 :          1 :         debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
   16872                 :            : 
   16873                 :            :         /* Validate obuf */
   16874         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   16875                 :            :                         authciphertext,
   16876                 :            :                         reference->ciphertext.data,
   16877                 :            :                         reference->ciphertext.len,
   16878                 :            :                         "Ciphertext data not as expected");
   16879                 :            : 
   16880         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   16881                 :            :                         auth_tag,
   16882                 :            :                         reference->digest.data,
   16883                 :            :                         reference->digest.len,
   16884                 :            :                         "Generated digest not as expected");
   16885                 :            : 
   16886                 :            :         return TEST_SUCCESS;
   16887                 :            : 
   16888                 :            : }
   16889                 :            : 
   16890                 :            : static int
   16891                 :          1 : test_authenticated_decrypt_with_esn(
   16892                 :            :                 struct crypto_testsuite_params *ts_params,
   16893                 :            :                 struct crypto_unittest_params *ut_params,
   16894                 :            :                 const struct test_crypto_vector *reference)
   16895                 :            : {
   16896                 :            :         int retval;
   16897                 :            : 
   16898                 :            :         uint8_t *ciphertext;
   16899                 :          1 :         uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
   16900                 :          1 :         uint8_t *auth_key = alloca(reference->auth_key.len + 1);
   16901                 :            :         struct rte_cryptodev_info dev_info;
   16902                 :            : 
   16903                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   16904                 :          1 :         uint64_t feat_flags = dev_info.feature_flags;
   16905                 :            : 
   16906         [ -  + ]:          1 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   16907         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   16908                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   16909                 :          0 :                 return TEST_SKIPPED;
   16910                 :            :         }
   16911                 :            : 
   16912                 :            :         /* Verify the capabilities */
   16913                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   16914                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16915                 :          1 :         cap_idx.algo.auth = reference->auth_algo;
   16916         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16917                 :            :                         &cap_idx) == NULL)
   16918                 :            :                 return TEST_SKIPPED;
   16919                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   16920                 :          1 :         cap_idx.algo.cipher = reference->crypto_algo;
   16921         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16922                 :            :                         &cap_idx) == NULL)
   16923                 :            :                 return TEST_SKIPPED;
   16924                 :            : 
   16925                 :            :         /* Create session */
   16926                 :          1 :         memcpy(cipher_key, reference->cipher_key.data,
   16927                 :          1 :                         reference->cipher_key.len);
   16928                 :          1 :         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
   16929                 :            : 
   16930                 :            :         /* Setup Authentication Parameters */
   16931                 :          1 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16932                 :          1 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
   16933                 :          1 :         ut_params->auth_xform.auth.algo = reference->auth_algo;
   16934                 :          1 :         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
   16935                 :          1 :         ut_params->auth_xform.auth.key.data = auth_key;
   16936                 :          1 :         ut_params->auth_xform.auth.digest_length = reference->digest.len;
   16937                 :          1 :         ut_params->auth_xform.next = &ut_params->cipher_xform;
   16938                 :            : 
   16939                 :            :         /* Setup Cipher Parameters */
   16940                 :          1 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   16941                 :          1 :         ut_params->cipher_xform.next = NULL;
   16942                 :          1 :         ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
   16943                 :          1 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
   16944                 :          1 :         ut_params->cipher_xform.cipher.key.data = cipher_key;
   16945                 :          1 :         ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
   16946                 :          1 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   16947                 :          1 :         ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
   16948                 :            : 
   16949                 :            :         /* Create Crypto session*/
   16950                 :          2 :         ut_params->sess = rte_cryptodev_sym_session_create(
   16951                 :          1 :                         ts_params->valid_devs[0], &ut_params->auth_xform,
   16952                 :            :                         ts_params->session_mpool);
   16953   [ -  +  -  - ]:          1 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   16954                 :            :                 return TEST_SKIPPED;
   16955         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   16956                 :            : 
   16957                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   16958         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   16959                 :            :                         "Failed to allocate input buffer in mempool");
   16960                 :            : 
   16961                 :            :         /* clear mbuf payload */
   16962                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   16963                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   16964                 :            : 
   16965                 :          1 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   16966                 :          1 :                         reference->ciphertext.len);
   16967         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
   16968                 :          1 :         memcpy(ciphertext, reference->ciphertext.data,
   16969                 :          1 :                         reference->ciphertext.len);
   16970                 :            : 
   16971                 :            :         /* Create operation */
   16972                 :            :         retval = create_cipher_auth_verify_operation(ts_params,
   16973                 :            :                         ut_params,
   16974                 :            :                         reference);
   16975                 :            : 
   16976         [ +  - ]:          1 :         if (retval < 0)
   16977                 :            :                 return retval;
   16978                 :            : 
   16979         [ -  + ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   16980                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   16981                 :            :                         ut_params->op);
   16982         [ -  + ]:          1 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   16983                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
   16984                 :            :                                                0);
   16985         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   16986                 :            :                         return retval;
   16987                 :            :         } else
   16988                 :          1 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
   16989                 :            :                         ut_params->op);
   16990                 :            : 
   16991         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
   16992         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status,
   16993                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   16994                 :            :                         "crypto op processing passed");
   16995                 :            : 
   16996                 :          1 :         ut_params->obuf = ut_params->op->sym->m_src;
   16997         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
   16998                 :            : 
   16999                 :            :         return 0;
   17000                 :            : }
   17001                 :            : 
   17002                 :            : static int
   17003                 :          1 : create_aead_operation_SGL(enum rte_crypto_aead_operation op,
   17004                 :            :                 const struct aead_test_data *tdata,
   17005                 :            :                 void *digest_mem, uint64_t digest_phys)
   17006                 :            : {
   17007                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   17008                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   17009                 :            : 
   17010                 :          1 :         const unsigned int auth_tag_len = tdata->auth_tag.len;
   17011                 :          1 :         const unsigned int iv_len = tdata->iv.len;
   17012                 :          1 :         unsigned int aad_len = tdata->aad.len;
   17013                 :            :         unsigned int aad_len_pad = 0;
   17014                 :            : 
   17015                 :            :         /* Generate Crypto op data structure */
   17016                 :          1 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   17017                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   17018         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   17019                 :            :                 "Failed to allocate symmetric crypto operation struct");
   17020                 :            : 
   17021                 :            :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
   17022                 :            : 
   17023                 :          1 :         sym_op->aead.digest.data = digest_mem;
   17024                 :            : 
   17025         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
   17026                 :            :                         "no room to append digest");
   17027                 :            : 
   17028                 :          1 :         sym_op->aead.digest.phys_addr = digest_phys;
   17029                 :            : 
   17030         [ -  + ]:          1 :         if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
   17031         [ #  # ]:          0 :                 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
   17032                 :            :                                 auth_tag_len);
   17033                 :          0 :                 debug_hexdump(stdout, "digest:",
   17034                 :          0 :                                 sym_op->aead.digest.data,
   17035                 :            :                                 auth_tag_len);
   17036                 :            :         }
   17037                 :            : 
   17038                 :            :         /* Append aad data */
   17039         [ -  + ]:          1 :         if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
   17040                 :          0 :                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
   17041                 :            :                                 uint8_t *, IV_OFFSET);
   17042                 :            : 
   17043                 :            :                 /* Copy IV 1 byte after the IV pointer, according to the API */
   17044         [ #  # ]:          0 :                 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
   17045                 :            : 
   17046                 :          0 :                 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
   17047                 :            : 
   17048         [ #  # ]:          0 :                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
   17049                 :            :                                 ut_params->ibuf, aad_len);
   17050         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
   17051                 :            :                                 "no room to prepend aad");
   17052         [ #  # ]:          0 :                 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
   17053                 :            :                                 ut_params->ibuf);
   17054                 :            : 
   17055         [ #  # ]:          0 :                 memset(sym_op->aead.aad.data, 0, aad_len);
   17056                 :            :                 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
   17057         [ #  # ]:          0 :                 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
   17058                 :            : 
   17059                 :          0 :                 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
   17060                 :          0 :                 debug_hexdump(stdout, "aad:",
   17061                 :          0 :                                 sym_op->aead.aad.data, aad_len);
   17062                 :            :         } else {
   17063                 :          1 :                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
   17064                 :            :                                 uint8_t *, IV_OFFSET);
   17065                 :            : 
   17066         [ -  + ]:          1 :                 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
   17067                 :            : 
   17068                 :          1 :                 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
   17069                 :            : 
   17070         [ +  - ]:          1 :                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
   17071                 :            :                                 ut_params->ibuf, aad_len_pad);
   17072         [ -  + ]:          1 :                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
   17073                 :            :                                 "no room to prepend aad");
   17074         [ -  + ]:          1 :                 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
   17075                 :            :                                 ut_params->ibuf);
   17076                 :            : 
   17077         [ -  + ]:          1 :                 memset(sym_op->aead.aad.data, 0, aad_len);
   17078         [ -  + ]:          1 :                 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
   17079                 :            : 
   17080                 :          1 :                 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
   17081                 :          1 :                 debug_hexdump(stdout, "aad:",
   17082                 :          1 :                                 sym_op->aead.aad.data, aad_len);
   17083                 :            :         }
   17084                 :            : 
   17085                 :          1 :         sym_op->aead.data.length = tdata->plaintext.len;
   17086                 :          1 :         sym_op->aead.data.offset = aad_len_pad;
   17087                 :            : 
   17088                 :          1 :         return 0;
   17089                 :            : }
   17090                 :            : 
   17091                 :            : #define SGL_MAX_NO      16
   17092                 :            : 
   17093                 :            : static int
   17094                 :          3 : test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
   17095                 :            :                 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
   17096                 :            : {
   17097                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   17098                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   17099                 :            :         struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
   17100                 :            :         int retval;
   17101                 :            :         int to_trn = 0;
   17102                 :            :         int to_trn_tbl[SGL_MAX_NO];
   17103                 :            :         unsigned int trn_data = 0;
   17104                 :            :         uint8_t *plaintext, *ciphertext, *auth_tag;
   17105                 :            :         struct rte_cryptodev_info dev_info;
   17106                 :            : 
   17107                 :            :         /* Verify the capabilities */
   17108                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   17109                 :            :         const struct rte_cryptodev_symmetric_capability *capability;
   17110                 :          3 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
   17111                 :          3 :         cap_idx.algo.aead = tdata->algo;
   17112                 :          3 :         capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
   17113         [ +  - ]:          3 :         if (capability == NULL)
   17114                 :            :                 return TEST_SKIPPED;
   17115         [ +  - ]:          3 :         if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
   17116                 :          3 :                         tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
   17117                 :            :                 return TEST_SKIPPED;
   17118                 :            : 
   17119                 :            :         /*
   17120                 :            :          * SGL not supported on AESNI_MB PMD CPU crypto,
   17121                 :            :          * OOP not supported on AESNI_GCM CPU crypto
   17122                 :            :          */
   17123         [ -  + ]:          3 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
   17124         [ #  # ]:          0 :                         (gbl_driver_id == rte_cryptodev_driver_id_get(
   17125         [ #  # ]:          0 :                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
   17126                 :            :                 return TEST_SKIPPED;
   17127                 :            : 
   17128                 :            :         /* Detailed check for the particular SGL support flag */
   17129                 :          3 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   17130         [ -  + ]:          3 :         if (!oop) {
   17131                 :          0 :                 unsigned int sgl_in = fragsz < tdata->plaintext.len;
   17132   [ #  #  #  # ]:          0 :                 if (sgl_in && (!(dev_info.feature_flags &
   17133                 :            :                                 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
   17134                 :            :                         return TEST_SKIPPED;
   17135                 :            : 
   17136                 :          0 :                 uint64_t feat_flags = dev_info.feature_flags;
   17137                 :            : 
   17138         [ #  # ]:          0 :                 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   17139         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   17140                 :            :                         printf("Device doesn't support RAW data-path APIs.\n");
   17141                 :          0 :                         return TEST_SKIPPED;
   17142                 :            :                 }
   17143                 :            :         } else {
   17144                 :          3 :                 unsigned int sgl_in = fragsz < tdata->plaintext.len;
   17145         [ -  + ]:          3 :                 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
   17146                 :            :                                 tdata->plaintext.len;
   17147                 :            :                 /* Raw data path API does not support OOP */
   17148         [ +  - ]:          3 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
   17149                 :            :                         return TEST_SKIPPED;
   17150         [ +  + ]:          3 :                 if (sgl_in && !sgl_out) {
   17151         [ +  - ]:          1 :                         if (!(dev_info.feature_flags &
   17152                 :            :                                         RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
   17153                 :            :                                 return TEST_SKIPPED;
   17154         [ -  + ]:          2 :                 } else if (!sgl_in && sgl_out) {
   17155         [ #  # ]:          0 :                         if (!(dev_info.feature_flags &
   17156                 :            :                                         RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
   17157                 :            :                                 return TEST_SKIPPED;
   17158         [ +  - ]:          2 :                 } else if (sgl_in && sgl_out) {
   17159         [ -  + ]:          2 :                         if (!(dev_info.feature_flags &
   17160                 :            :                                         RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
   17161                 :            :                                 return TEST_SKIPPED;
   17162                 :            :                 }
   17163                 :            :         }
   17164                 :            : 
   17165                 :          1 :         if (fragsz > tdata->plaintext.len)
   17166                 :            :                 fragsz = tdata->plaintext.len;
   17167                 :            : 
   17168                 :          1 :         uint16_t plaintext_len = fragsz;
   17169         [ +  - ]:          1 :         uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
   17170                 :            : 
   17171         [ -  + ]:          1 :         if (fragsz_oop > tdata->plaintext.len)
   17172                 :          0 :                 frag_size_oop = tdata->plaintext.len;
   17173                 :            : 
   17174                 :            :         int ecx = 0;
   17175                 :            :         void *digest_mem = NULL;
   17176                 :            : 
   17177                 :          1 :         uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
   17178                 :            : 
   17179         [ +  - ]:          1 :         if (tdata->plaintext.len % fragsz != 0) {
   17180         [ +  - ]:          1 :                 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
   17181                 :            :                         return 1;
   17182                 :            :         }       else {
   17183         [ #  # ]:          0 :                 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
   17184                 :            :                         return 1;
   17185                 :            :         }
   17186                 :            : 
   17187                 :            :         /*
   17188                 :            :          * For out-of-place we need to alloc another mbuf
   17189                 :            :          */
   17190         [ +  - ]:          1 :         if (oop) {
   17191                 :          1 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   17192                 :            :                 rte_pktmbuf_append(ut_params->obuf,
   17193                 :          1 :                                 frag_size_oop + prepend_len);
   17194                 :          1 :                 buf_oop = ut_params->obuf;
   17195                 :            :         }
   17196                 :            : 
   17197                 :            :         /* Create AEAD session */
   17198                 :          1 :         retval = create_aead_session(ts_params->valid_devs[0],
   17199                 :          1 :                         tdata->algo,
   17200                 :            :                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
   17201                 :          1 :                         tdata->key.data, tdata->key.len,
   17202                 :          1 :                         tdata->aad.len, tdata->auth_tag.len,
   17203                 :          1 :                         tdata->iv.len);
   17204         [ +  - ]:          1 :         if (retval < 0)
   17205                 :            :                 return retval;
   17206                 :            : 
   17207                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   17208                 :            : 
   17209                 :            :         /* clear mbuf payload */
   17210                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   17211                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   17212                 :            : 
   17213                 :          1 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   17214                 :            :                         plaintext_len);
   17215                 :            : 
   17216                 :          1 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
   17217                 :            : 
   17218                 :            :         trn_data += plaintext_len;
   17219                 :            : 
   17220                 :          1 :         buf = ut_params->ibuf;
   17221                 :            : 
   17222                 :            :         /*
   17223                 :            :          * Loop until no more fragments
   17224                 :            :          */
   17225                 :            : 
   17226         [ +  + ]:          6 :         while (trn_data < tdata->plaintext.len) {
   17227                 :          5 :                 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
   17228                 :          5 :                                 (tdata->plaintext.len - trn_data) : fragsz;
   17229                 :            : 
   17230                 :          5 :                 to_trn_tbl[ecx++] = to_trn;
   17231                 :            : 
   17232                 :          5 :                 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   17233                 :            :                 buf = buf->next;
   17234         [ -  + ]:          5 :                 ut_params->ibuf->nb_segs++;
   17235                 :            : 
   17236         [ -  + ]:          5 :                 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
   17237                 :            :                                 rte_pktmbuf_tailroom(buf));
   17238                 :            : 
   17239                 :            :                 /* OOP */
   17240         [ -  + ]:          5 :                 if (oop && !fragsz_oop) {
   17241                 :          0 :                         buf_last_oop = buf_oop->next =
   17242                 :          0 :                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
   17243                 :            :                         buf_oop = buf_oop->next;
   17244                 :          0 :                         ut_params->obuf->nb_segs++;
   17245                 :          0 :                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
   17246                 :            :                                         0, rte_pktmbuf_tailroom(buf_oop));
   17247         [ #  # ]:          0 :                         TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
   17248                 :            :                 }
   17249                 :            : 
   17250                 :          5 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   17251                 :            :                                 to_trn);
   17252         [ -  + ]:          5 :                 TEST_ASSERT_NOT_NULL(plaintext, "Failed to append plaintext");
   17253                 :            : 
   17254         [ +  + ]:          5 :                 memcpy(plaintext, tdata->plaintext.data + trn_data,
   17255                 :            :                                 to_trn);
   17256                 :          5 :                 trn_data += to_trn;
   17257         [ +  + ]:          5 :                 if (trn_data  == tdata->plaintext.len) {
   17258         [ +  - ]:          1 :                         if (oop) {
   17259         [ -  + ]:          1 :                                 if (!fragsz_oop) {
   17260                 :          0 :                                         digest_mem = rte_pktmbuf_append(ut_params->obuf,
   17261                 :          0 :                                                 tdata->auth_tag.len);
   17262         [ #  # ]:          0 :                                         TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append auth tag");
   17263                 :            :                                 }
   17264                 :            :                         } else {
   17265                 :          0 :                                 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   17266                 :          0 :                                         tdata->auth_tag.len);
   17267         [ #  # ]:          0 :                                 TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append auth tag");
   17268                 :            :                         }
   17269                 :            :                 }
   17270                 :            :         }
   17271                 :            : 
   17272                 :            :         uint64_t digest_phys = 0;
   17273                 :            : 
   17274         [ +  - ]:          1 :         if (fragsz_oop && oop) {
   17275                 :            :                 to_trn = 0;
   17276                 :            :                 ecx = 0;
   17277                 :            : 
   17278         [ +  - ]:          1 :                 if (frag_size_oop == tdata->plaintext.len) {
   17279                 :          1 :                         digest_mem = rte_pktmbuf_append(ut_params->obuf,
   17280                 :          1 :                                 tdata->auth_tag.len);
   17281                 :            : 
   17282                 :          1 :                         digest_phys = rte_pktmbuf_iova_offset(
   17283                 :            :                                         ut_params->obuf,
   17284                 :            :                                         tdata->plaintext.len + prepend_len);
   17285                 :            :                 }
   17286                 :            : 
   17287                 :            :                 trn_data = frag_size_oop;
   17288         [ -  + ]:          1 :                 while (trn_data < tdata->plaintext.len) {
   17289                 :          0 :                         to_trn =
   17290                 :          0 :                                 (tdata->plaintext.len - trn_data <
   17291                 :            :                                                 frag_size_oop) ?
   17292                 :          0 :                                 (tdata->plaintext.len - trn_data) :
   17293                 :            :                                                 frag_size_oop;
   17294                 :            : 
   17295                 :          0 :                         to_trn_tbl[ecx++] = to_trn;
   17296                 :            : 
   17297                 :          0 :                         buf_last_oop = buf_oop->next =
   17298                 :          0 :                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
   17299         [ #  # ]:          0 :                         TEST_ASSERT_NOT_NULL(buf_oop->next, "Unexpected end of chain");
   17300                 :          0 :                         ut_params->obuf->nb_segs++;
   17301                 :          0 :                         buf_oop = buf_oop->next;
   17302                 :          0 :                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
   17303                 :            :                                         0, rte_pktmbuf_tailroom(buf_oop));
   17304         [ #  # ]:          0 :                         TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
   17305                 :            : 
   17306                 :          0 :                         trn_data += to_trn;
   17307                 :            : 
   17308         [ #  # ]:          0 :                         if (trn_data  == tdata->plaintext.len) {
   17309                 :          0 :                                 digest_mem = rte_pktmbuf_append(ut_params->obuf,
   17310                 :          0 :                                         tdata->auth_tag.len);
   17311         [ #  # ]:          0 :                                 TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append auth tag");
   17312                 :            :                         }
   17313                 :            :                 }
   17314                 :            :         }
   17315                 :            : 
   17316                 :            :         /*
   17317                 :            :          * Place digest at the end of the last buffer
   17318                 :            :          */
   17319         [ -  + ]:          1 :         if (!digest_phys)
   17320                 :          0 :                 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
   17321         [ -  + ]:          1 :         if (oop && buf_last_oop)
   17322                 :          0 :                 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
   17323                 :            : 
   17324         [ -  + ]:          1 :         if (!digest_mem && !oop) {
   17325                 :          0 :                 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   17326                 :          0 :                                 + tdata->auth_tag.len);
   17327                 :          0 :                 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
   17328                 :            :                                 tdata->plaintext.len);
   17329                 :            :         }
   17330                 :            : 
   17331                 :            :         /* Create AEAD operation */
   17332                 :          1 :         retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
   17333                 :            :                         tdata, digest_mem, digest_phys);
   17334                 :            : 
   17335         [ +  - ]:          1 :         if (retval < 0)
   17336                 :            :                 return retval;
   17337                 :            : 
   17338         [ +  - ]:          1 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   17339                 :            : 
   17340                 :          1 :         ut_params->op->sym->m_src = ut_params->ibuf;
   17341         [ +  - ]:          1 :         if (oop)
   17342                 :          1 :                 ut_params->op->sym->m_dst = ut_params->obuf;
   17343                 :            : 
   17344                 :            :         /* Process crypto operation */
   17345         [ -  + ]:          1 :         if (oop == IN_PLACE &&
   17346         [ #  # ]:          0 :                         gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   17347                 :          0 :                 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
   17348         [ -  + ]:          1 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   17349                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
   17350                 :            :                                                0);
   17351         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   17352                 :            :                         return retval;
   17353                 :            :         } else
   17354         [ -  + ]:          1 :                 TEST_ASSERT_NOT_NULL(
   17355                 :            :                         process_crypto_request(ts_params->valid_devs[0],
   17356                 :            :                         ut_params->op), "failed to process sym crypto op");
   17357                 :            : 
   17358         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   17359                 :            :                         "crypto op processing failed");
   17360                 :            : 
   17361                 :            : 
   17362                 :          1 :         ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
   17363                 :            :                         uint8_t *, prepend_len);
   17364         [ +  - ]:          1 :         if (oop) {
   17365                 :          1 :                 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
   17366                 :            :                                 uint8_t *, prepend_len);
   17367                 :            :         }
   17368                 :            : 
   17369         [ +  - ]:          1 :         if (fragsz_oop)
   17370                 :            :                 fragsz = fragsz_oop;
   17371                 :            : 
   17372         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   17373                 :            :                         ciphertext,
   17374                 :            :                         tdata->ciphertext.data,
   17375                 :            :                         fragsz,
   17376                 :            :                         "Ciphertext data not as expected");
   17377                 :            : 
   17378                 :          1 :         buf = ut_params->op->sym->m_src->next;
   17379         [ +  - ]:          1 :         if (oop)
   17380                 :          1 :                 buf = ut_params->op->sym->m_dst->next;
   17381                 :            : 
   17382                 :            :         unsigned int off = fragsz;
   17383                 :            : 
   17384                 :            :         ecx = 0;
   17385         [ -  + ]:          1 :         while (buf) {
   17386                 :          0 :                 ciphertext = rte_pktmbuf_mtod(buf,
   17387                 :            :                                 uint8_t *);
   17388                 :            : 
   17389         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
   17390                 :            :                                 ciphertext,
   17391                 :            :                                 tdata->ciphertext.data + off,
   17392                 :            :                                 to_trn_tbl[ecx],
   17393                 :            :                                 "Ciphertext data not as expected");
   17394                 :            : 
   17395                 :          0 :                 off += to_trn_tbl[ecx++];
   17396                 :          0 :                 buf = buf->next;
   17397                 :            :         }
   17398                 :            : 
   17399                 :            :         auth_tag = digest_mem;
   17400         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   17401                 :            :                         auth_tag,
   17402                 :            :                         tdata->auth_tag.data,
   17403                 :            :                         tdata->auth_tag.len,
   17404                 :            :                         "Generated auth tag not as expected");
   17405                 :            : 
   17406                 :            :         return 0;
   17407                 :            : }
   17408                 :            : 
   17409                 :            : static int
   17410                 :          1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
   17411                 :            : {
   17412                 :          1 :         return test_authenticated_encryption_SGL(
   17413                 :            :                         &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
   17414                 :            : }
   17415                 :            : 
   17416                 :            : static int
   17417                 :          1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
   17418                 :            : {
   17419                 :          1 :         return test_authenticated_encryption_SGL(
   17420                 :            :                         &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
   17421                 :            : }
   17422                 :            : 
   17423                 :            : static int
   17424                 :          1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
   17425                 :            : {
   17426                 :          1 :         return test_authenticated_encryption_SGL(
   17427                 :            :                         &gcm_test_case_8, OUT_OF_PLACE, 400,
   17428                 :            :                         gcm_test_case_8.plaintext.len);
   17429                 :            : }
   17430                 :            : 
   17431                 :            : static int
   17432                 :          1 : test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
   17433                 :            : {
   17434                 :            :         /* This test is not for OPENSSL PMD */
   17435         [ -  + ]:          1 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   17436                 :            :                         RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
   17437                 :            :                 return TEST_SKIPPED;
   17438                 :            : 
   17439                 :          0 :         return test_authenticated_encryption_SGL(
   17440                 :            :                         &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
   17441                 :            : }
   17442                 :            : 
   17443                 :            : static int
   17444                 :            : test_authentication_verify_fail_when_data_corrupted(
   17445                 :            :                 struct crypto_testsuite_params *ts_params,
   17446                 :            :                 struct crypto_unittest_params *ut_params,
   17447                 :            :                 const struct test_crypto_vector *reference)
   17448                 :            : {
   17449                 :          1 :         return test_authentication_verify_fail_when_data_corruption(
   17450                 :            :                         ts_params, ut_params, reference, 1);
   17451                 :            : }
   17452                 :            : 
   17453                 :            : static int
   17454                 :            : test_authentication_verify_fail_when_tag_corrupted(
   17455                 :            :                 struct crypto_testsuite_params *ts_params,
   17456                 :            :                 struct crypto_unittest_params *ut_params,
   17457                 :            :                 const struct test_crypto_vector *reference)
   17458                 :            : {
   17459                 :          1 :         return test_authentication_verify_fail_when_data_corruption(
   17460                 :            :                         ts_params, ut_params, reference, 0);
   17461                 :            : }
   17462                 :            : 
   17463                 :            : static int
   17464                 :            : test_authentication_verify_GMAC_fail_when_data_corrupted(
   17465                 :            :                 struct crypto_testsuite_params *ts_params,
   17466                 :            :                 struct crypto_unittest_params *ut_params,
   17467                 :            :                 const struct test_crypto_vector *reference)
   17468                 :            : {
   17469                 :          1 :         return test_authentication_verify_GMAC_fail_when_corruption(
   17470                 :            :                         ts_params, ut_params, reference, 1);
   17471                 :            : }
   17472                 :            : 
   17473                 :            : static int
   17474                 :            : test_authentication_verify_GMAC_fail_when_tag_corrupted(
   17475                 :            :                 struct crypto_testsuite_params *ts_params,
   17476                 :            :                 struct crypto_unittest_params *ut_params,
   17477                 :            :                 const struct test_crypto_vector *reference)
   17478                 :            : {
   17479                 :          1 :         return test_authentication_verify_GMAC_fail_when_corruption(
   17480                 :            :                         ts_params, ut_params, reference, 0);
   17481                 :            : }
   17482                 :            : 
   17483                 :            : static int
   17484                 :            : test_authenticated_decryption_fail_when_data_corrupted(
   17485                 :            :                 struct crypto_testsuite_params *ts_params,
   17486                 :            :                 struct crypto_unittest_params *ut_params,
   17487                 :            :                 const struct test_crypto_vector *reference)
   17488                 :            : {
   17489                 :          1 :         return test_authenticated_decryption_fail_when_corruption(
   17490                 :            :                         ts_params, ut_params, reference, 1);
   17491                 :            : }
   17492                 :            : 
   17493                 :            : static int
   17494                 :            : test_authenticated_decryption_fail_when_tag_corrupted(
   17495                 :            :                 struct crypto_testsuite_params *ts_params,
   17496                 :            :                 struct crypto_unittest_params *ut_params,
   17497                 :            :                 const struct test_crypto_vector *reference)
   17498                 :            : {
   17499                 :          1 :         return test_authenticated_decryption_fail_when_corruption(
   17500                 :            :                         ts_params, ut_params, reference, 0);
   17501                 :            : }
   17502                 :            : 
   17503                 :            : static int
   17504                 :          1 : authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
   17505                 :            : {
   17506                 :          1 :         return test_authentication_verify_fail_when_data_corrupted(
   17507                 :            :                         &testsuite_params, &unittest_params,
   17508                 :            :                         &hmac_sha1_test_crypto_vector);
   17509                 :            : }
   17510                 :            : 
   17511                 :            : static int
   17512                 :          1 : authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
   17513                 :            : {
   17514                 :          1 :         return test_authentication_verify_fail_when_tag_corrupted(
   17515                 :            :                         &testsuite_params, &unittest_params,
   17516                 :            :                         &hmac_sha1_test_crypto_vector);
   17517                 :            : }
   17518                 :            : 
   17519                 :            : static int
   17520                 :          1 : authentication_verify_AES128_GMAC_fail_data_corrupt(void)
   17521                 :            : {
   17522                 :          1 :         return test_authentication_verify_GMAC_fail_when_data_corrupted(
   17523                 :            :                         &testsuite_params, &unittest_params,
   17524                 :            :                         &aes128_gmac_test_vector);
   17525                 :            : }
   17526                 :            : 
   17527                 :            : static int
   17528                 :          1 : authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
   17529                 :            : {
   17530                 :          1 :         return test_authentication_verify_GMAC_fail_when_tag_corrupted(
   17531                 :            :                         &testsuite_params, &unittest_params,
   17532                 :            :                         &aes128_gmac_test_vector);
   17533                 :            : }
   17534                 :            : 
   17535                 :            : static int
   17536                 :          1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
   17537                 :            : {
   17538                 :          1 :         return test_authenticated_decryption_fail_when_data_corrupted(
   17539                 :            :                         &testsuite_params,
   17540                 :            :                         &unittest_params,
   17541                 :            :                         &aes128cbc_hmac_sha1_test_vector);
   17542                 :            : }
   17543                 :            : 
   17544                 :            : static int
   17545                 :          1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
   17546                 :            : {
   17547                 :          1 :         return test_authenticated_decryption_fail_when_tag_corrupted(
   17548                 :            :                         &testsuite_params,
   17549                 :            :                         &unittest_params,
   17550                 :            :                         &aes128cbc_hmac_sha1_test_vector);
   17551                 :            : }
   17552                 :            : 
   17553                 :            : static int
   17554                 :          1 : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
   17555                 :            : {
   17556                 :          1 :         return test_authenticated_encrypt_with_esn(
   17557                 :            :                         &testsuite_params,
   17558                 :            :                         &unittest_params,
   17559                 :            :                         &aes128cbc_hmac_sha1_aad_test_vector);
   17560                 :            : }
   17561                 :            : 
   17562                 :            : static int
   17563                 :          1 : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
   17564                 :            : {
   17565                 :          1 :         return test_authenticated_decrypt_with_esn(
   17566                 :            :                         &testsuite_params,
   17567                 :            :                         &unittest_params,
   17568                 :            :                         &aes128cbc_hmac_sha1_aad_test_vector);
   17569                 :            : }
   17570                 :            : 
   17571                 :            : static int
   17572                 :          0 : test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
   17573                 :            : {
   17574                 :          0 :         return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
   17575                 :            : }
   17576                 :            : 
   17577                 :            : static int
   17578                 :          0 : test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
   17579                 :            : {
   17580                 :          0 :         return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
   17581                 :            : }
   17582                 :            : 
   17583                 :            : static int
   17584                 :          0 : test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
   17585                 :            : {
   17586                 :          0 :         return test_authenticated_encryption_SGL(
   17587                 :            :                 &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
   17588                 :            :                 chacha20_poly1305_case_2.plaintext.len);
   17589                 :            : }
   17590                 :            : 
   17591                 :            : static int
   17592                 :          0 : test_SM4_GCM_case_1(void)
   17593                 :            : {
   17594                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_1);
   17595                 :            : }
   17596                 :            : 
   17597                 :            : static int
   17598                 :          0 : test_SM4_GCM_case_2(void)
   17599                 :            : {
   17600                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_2);
   17601                 :            : }
   17602                 :            : 
   17603                 :            : static int
   17604                 :          0 : test_SM4_GCM_case_3(void)
   17605                 :            : {
   17606                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_3);
   17607                 :            : }
   17608                 :            : 
   17609                 :            : static int
   17610                 :          0 : test_SM4_GCM_case_4(void)
   17611                 :            : {
   17612                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_4);
   17613                 :            : }
   17614                 :            : 
   17615                 :            : static int
   17616                 :          0 : test_SM4_GCM_case_5(void)
   17617                 :            : {
   17618                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_5);
   17619                 :            : }
   17620                 :            : 
   17621                 :            : static int
   17622                 :          0 : test_SM4_GCM_case_6(void)
   17623                 :            : {
   17624                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_6);
   17625                 :            : }
   17626                 :            : 
   17627                 :            : static int
   17628                 :          0 : test_SM4_GCM_case_7(void)
   17629                 :            : {
   17630                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_7);
   17631                 :            : }
   17632                 :            : 
   17633                 :            : static int
   17634                 :          0 : test_SM4_GCM_case_8(void)
   17635                 :            : {
   17636                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_8);
   17637                 :            : }
   17638                 :            : 
   17639                 :            : static int
   17640                 :          0 : test_SM4_GCM_case_9(void)
   17641                 :            : {
   17642                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_9);
   17643                 :            : }
   17644                 :            : 
   17645                 :            : static int
   17646                 :          0 : test_SM4_GCM_case_10(void)
   17647                 :            : {
   17648                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_10);
   17649                 :            : }
   17650                 :            : 
   17651                 :            : static int
   17652                 :          0 : test_SM4_GCM_case_11(void)
   17653                 :            : {
   17654                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_11);
   17655                 :            : }
   17656                 :            : 
   17657                 :            : static int
   17658                 :          0 : test_SM4_GCM_case_12(void)
   17659                 :            : {
   17660                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_12);
   17661                 :            : }
   17662                 :            : 
   17663                 :            : static int
   17664                 :          0 : test_SM4_GCM_case_13(void)
   17665                 :            : {
   17666                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_13);
   17667                 :            : }
   17668                 :            : 
   17669                 :            : static int
   17670                 :          0 : test_SM4_GCM_case_14(void)
   17671                 :            : {
   17672                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_14);
   17673                 :            : }
   17674                 :            : 
   17675                 :            : static int
   17676                 :          0 : test_SM4_GCM_case_15(void)
   17677                 :            : {
   17678                 :          0 :         return test_authenticated_encryption(&sm4_gcm_case_15);
   17679                 :            : }
   17680                 :            : 
   17681                 :            : #ifdef RTE_CRYPTO_SCHEDULER
   17682                 :            : 
   17683                 :            : /* global AESNI worker IDs for the scheduler test */
   17684                 :            : uint8_t aesni_ids[2];
   17685                 :            : 
   17686                 :            : static int
   17687                 :          0 : scheduler_testsuite_setup(void)
   17688                 :            : {
   17689                 :            :         uint32_t i = 0;
   17690                 :            :         int32_t nb_devs, ret;
   17691                 :          0 :         char vdev_args[VDEV_ARGS_SIZE] = {""};
   17692                 :          0 :         char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
   17693                 :            :                 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
   17694                 :            :         uint16_t worker_core_count = 0;
   17695                 :            :         uint16_t socket_id = 0;
   17696                 :            : 
   17697         [ #  # ]:          0 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   17698                 :            :                         RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
   17699                 :            : 
   17700                 :            :                 /* Identify the Worker Cores
   17701                 :            :                  * Use 2 worker cores for the device args
   17702                 :            :                  */
   17703         [ #  # ]:          0 :                 RTE_LCORE_FOREACH_WORKER(i) {
   17704         [ #  # ]:          0 :                         if (worker_core_count > 1)
   17705                 :            :                                 break;
   17706                 :            :                         ret = snprintf(vdev_args, sizeof(vdev_args), "%s%d", temp_str, i);
   17707                 :            : 
   17708                 :            :                         /* If too many args the result will have been truncated */
   17709         [ #  # ]:          0 :                         if (ret >= VDEV_ARGS_SIZE) {
   17710                 :          0 :                                 RTE_LOG(ERR, USER1,
   17711                 :            :                                         "Cryptodev scheduler test vdev arg size exceeded\n");
   17712                 :          0 :                                 return TEST_FAILED;
   17713                 :            :                         }
   17714                 :            : 
   17715                 :            :                         strcpy(temp_str, vdev_args);
   17716                 :          0 :                         strlcat(temp_str, ";", sizeof(temp_str));
   17717                 :          0 :                         worker_core_count++;
   17718                 :          0 :                         socket_id = rte_lcore_to_socket_id(i);
   17719                 :            :                 }
   17720         [ #  # ]:          0 :                 if (worker_core_count != 2) {
   17721                 :          0 :                         RTE_LOG(ERR, USER1,
   17722                 :            :                                 "Cryptodev scheduler test require at least "
   17723                 :            :                                 "two worker cores to run. "
   17724                 :            :                                 "Please use the correct coremask.\n");
   17725                 :          0 :                         return TEST_FAILED;
   17726                 :            :                 }
   17727                 :            :                 strcpy(temp_str, vdev_args);
   17728         [ #  # ]:          0 :                 ret = snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d", temp_str,
   17729                 :            :                         socket_id);
   17730         [ #  # ]:          0 :                 if (ret >= VDEV_ARGS_SIZE) {
   17731                 :          0 :                         RTE_LOG(ERR, USER1,
   17732                 :            :                                 "Cryptodev scheduler test vdev arg size exceeded\n");
   17733                 :          0 :                         return TEST_FAILED;
   17734                 :            :                 }
   17735                 :            : 
   17736                 :          0 :                 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
   17737                 :          0 :                 nb_devs = rte_cryptodev_device_count_by_driver(
   17738                 :          0 :                                 rte_cryptodev_driver_id_get(
   17739                 :            :                                 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
   17740         [ #  # ]:          0 :                 if (nb_devs < 1) {
   17741                 :          0 :                         ret = rte_vdev_init(
   17742                 :            :                                 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
   17743                 :            :                                         vdev_args);
   17744         [ #  # ]:          0 :                         TEST_ASSERT(ret == 0,
   17745                 :            :                                 "Failed to create instance %u of pmd : %s",
   17746                 :            :                                 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
   17747                 :            :                 }
   17748                 :            :         }
   17749                 :          0 :         return testsuite_setup();
   17750                 :            : }
   17751                 :            : 
   17752                 :            : static int
   17753                 :          0 : test_scheduler_attach_worker_op(void)
   17754                 :            : {
   17755                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   17756                 :          0 :         uint8_t sched_id = ts_params->valid_devs[0];
   17757                 :            :         uint32_t i, nb_devs_attached = 0;
   17758                 :            :         int ret;
   17759                 :            :         char vdev_name[32];
   17760                 :          0 :         unsigned int count = rte_cryptodev_count();
   17761                 :            : 
   17762                 :            :         /* create 2 AESNI_MB vdevs on top of existing devices */
   17763         [ #  # ]:          0 :         for (i = count; i < count + 2; i++) {
   17764                 :            :                 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
   17765                 :            :                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
   17766                 :            :                                 i);
   17767                 :          0 :                 ret = rte_vdev_init(vdev_name, NULL);
   17768                 :            : 
   17769         [ #  # ]:          0 :                 TEST_ASSERT(ret == 0,
   17770                 :            :                         "Failed to create instance %u of"
   17771                 :            :                         " pmd : %s",
   17772                 :            :                         i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
   17773                 :            : 
   17774                 :            :                 if (ret < 0) {
   17775                 :            :                         RTE_LOG(ERR, USER1,
   17776                 :            :                                 "Failed to create 2 AESNI MB PMDs.\n");
   17777                 :            :                         return TEST_SKIPPED;
   17778                 :            :                 }
   17779                 :            :         }
   17780                 :            : 
   17781                 :            :         /* attach 2 AESNI_MB cdevs */
   17782         [ #  # ]:          0 :         for (i = count; i < count + 2; i++) {
   17783                 :            :                 struct rte_cryptodev_info info;
   17784                 :            :                 unsigned int session_size;
   17785                 :            : 
   17786                 :          0 :                 rte_cryptodev_info_get(i, &info);
   17787         [ #  # ]:          0 :                 if (info.driver_id != rte_cryptodev_driver_id_get(
   17788                 :            :                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
   17789                 :          0 :                         continue;
   17790                 :            : 
   17791                 :          0 :                 session_size = rte_cryptodev_sym_get_private_session_size(i);
   17792                 :            :                 /*
   17793                 :            :                  * Create the session mempool again, since now there are new devices
   17794                 :            :                  * to use the mempool.
   17795                 :            :                  */
   17796         [ #  # ]:          0 :                 if (ts_params->session_mpool) {
   17797                 :          0 :                         rte_mempool_free(ts_params->session_mpool);
   17798                 :          0 :                         ts_params->session_mpool = NULL;
   17799                 :            :                 }
   17800                 :            : 
   17801         [ #  # ]:          0 :                 if (info.sym.max_nb_sessions != 0 &&
   17802                 :            :                                 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
   17803                 :          0 :                         RTE_LOG(ERR, USER1,
   17804                 :            :                                         "Device does not support "
   17805                 :            :                                         "at least %u sessions\n",
   17806                 :            :                                         MAX_NB_SESSIONS);
   17807                 :          0 :                         return TEST_FAILED;
   17808                 :            :                 }
   17809                 :            :                 /*
   17810                 :            :                  * Create mempool with maximum number of sessions,
   17811                 :            :                  * to include the session headers
   17812                 :            :                  */
   17813         [ #  # ]:          0 :                 if (ts_params->session_mpool == NULL) {
   17814                 :          0 :                         ts_params->session_mpool =
   17815                 :          0 :                                 rte_cryptodev_sym_session_pool_create(
   17816                 :            :                                                 "test_sess_mp",
   17817                 :            :                                                 MAX_NB_SESSIONS, session_size,
   17818                 :            :                                                 0, 0, SOCKET_ID_ANY);
   17819         [ #  # ]:          0 :                         TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
   17820                 :            :                                         "session mempool allocation failed");
   17821                 :            :                 }
   17822                 :            : 
   17823                 :          0 :                 ts_params->qp_conf.mp_session = ts_params->session_mpool;
   17824                 :            : 
   17825                 :          0 :                 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
   17826                 :            :                                 (uint8_t)i);
   17827                 :            : 
   17828         [ #  # ]:          0 :                 TEST_ASSERT(ret == 0,
   17829                 :            :                         "Failed to attach device %u of pmd : %s", i,
   17830                 :            :                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
   17831                 :            : 
   17832                 :          0 :                 aesni_ids[nb_devs_attached] = (uint8_t)i;
   17833                 :            : 
   17834                 :          0 :                 nb_devs_attached++;
   17835                 :            :         }
   17836                 :            : 
   17837                 :            :         return 0;
   17838                 :            : }
   17839                 :            : 
   17840                 :            : static int
   17841                 :          0 : test_scheduler_detach_worker_op(void)
   17842                 :            : {
   17843                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   17844                 :          0 :         uint8_t sched_id = ts_params->valid_devs[0];
   17845                 :            :         uint32_t i;
   17846                 :            :         int ret;
   17847                 :            : 
   17848         [ #  # ]:          0 :         for (i = 0; i < 2; i++) {
   17849                 :          0 :                 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
   17850                 :          0 :                                 aesni_ids[i]);
   17851         [ #  # ]:          0 :                 TEST_ASSERT(ret == 0,
   17852                 :            :                         "Failed to detach device %u", aesni_ids[i]);
   17853                 :            :         }
   17854                 :            : 
   17855                 :            :         return 0;
   17856                 :            : }
   17857                 :            : 
   17858                 :            : static int
   17859                 :            : test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
   17860                 :            : {
   17861                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   17862                 :          0 :         uint8_t sched_id = ts_params->valid_devs[0];
   17863                 :            :         /* set mode */
   17864                 :          0 :         return rte_cryptodev_scheduler_mode_set(sched_id,
   17865                 :            :                 scheduler_mode);
   17866                 :            : }
   17867                 :            : 
   17868                 :            : static int
   17869                 :          0 : test_scheduler_mode_roundrobin_op(void)
   17870                 :            : {
   17871         [ #  # ]:          0 :         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
   17872                 :            :                         0, "Failed to set roundrobin mode");
   17873                 :            :         return 0;
   17874                 :            : 
   17875                 :            : }
   17876                 :            : 
   17877                 :            : static int
   17878                 :          0 : test_scheduler_mode_multicore_op(void)
   17879                 :            : {
   17880         [ #  # ]:          0 :         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
   17881                 :            :                         0, "Failed to set multicore mode");
   17882                 :            : 
   17883                 :            :         return 0;
   17884                 :            : }
   17885                 :            : 
   17886                 :            : static int
   17887                 :          0 : test_scheduler_mode_failover_op(void)
   17888                 :            : {
   17889         [ #  # ]:          0 :         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
   17890                 :            :                         0, "Failed to set failover mode");
   17891                 :            : 
   17892                 :            :         return 0;
   17893                 :            : }
   17894                 :            : 
   17895                 :            : static int
   17896                 :          0 : test_scheduler_mode_pkt_size_distr_op(void)
   17897                 :            : {
   17898         [ #  # ]:          0 :         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
   17899                 :            :                         0, "Failed to set pktsize mode");
   17900                 :            : 
   17901                 :            :         return 0;
   17902                 :            : }
   17903                 :            : 
   17904                 :            : static int
   17905                 :          0 : scheduler_multicore_testsuite_setup(void)
   17906                 :            : {
   17907         [ #  # ]:          0 :         if (test_scheduler_attach_worker_op() < 0)
   17908                 :            :                 return TEST_SKIPPED;
   17909         [ #  # ]:          0 :         if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
   17910                 :          0 :                 return TEST_SKIPPED;
   17911                 :            :         return 0;
   17912                 :            : }
   17913                 :            : 
   17914                 :            : static int
   17915                 :          0 : scheduler_roundrobin_testsuite_setup(void)
   17916                 :            : {
   17917         [ #  # ]:          0 :         if (test_scheduler_attach_worker_op() < 0)
   17918                 :            :                 return TEST_SKIPPED;
   17919         [ #  # ]:          0 :         if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
   17920                 :          0 :                 return TEST_SKIPPED;
   17921                 :            :         return 0;
   17922                 :            : }
   17923                 :            : 
   17924                 :            : static int
   17925                 :          0 : scheduler_failover_testsuite_setup(void)
   17926                 :            : {
   17927         [ #  # ]:          0 :         if (test_scheduler_attach_worker_op() < 0)
   17928                 :            :                 return TEST_SKIPPED;
   17929         [ #  # ]:          0 :         if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
   17930                 :          0 :                 return TEST_SKIPPED;
   17931                 :            :         return 0;
   17932                 :            : }
   17933                 :            : 
   17934                 :            : static int
   17935                 :          0 : scheduler_pkt_size_distr_testsuite_setup(void)
   17936                 :            : {
   17937         [ #  # ]:          0 :         if (test_scheduler_attach_worker_op() < 0)
   17938                 :            :                 return TEST_SKIPPED;
   17939         [ #  # ]:          0 :         if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
   17940                 :          0 :                 return TEST_SKIPPED;
   17941                 :            :         return 0;
   17942                 :            : }
   17943                 :            : 
   17944                 :            : static void
   17945                 :          0 : scheduler_mode_testsuite_teardown(void)
   17946                 :            : {
   17947                 :          0 :         test_scheduler_detach_worker_op();
   17948                 :          0 : }
   17949                 :            : 
   17950                 :            : #endif /* RTE_CRYPTO_SCHEDULER */
   17951                 :            : 
   17952                 :            : static struct unit_test_suite end_testsuite = {
   17953                 :            :         .suite_name = NULL,
   17954                 :            :         .setup = NULL,
   17955                 :            :         .teardown = NULL,
   17956                 :            :         .unit_test_suites = NULL
   17957                 :            : };
   17958                 :            : 
   17959                 :            : #ifdef RTE_LIB_SECURITY
   17960                 :            : static struct unit_test_suite ipsec_proto_testsuite  = {
   17961                 :            :         .suite_name = "IPsec Proto Unit Test Suite",
   17962                 :            :         .setup = ipsec_proto_testsuite_setup,
   17963                 :            :         .unit_test_cases = {
   17964                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17965                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
   17966                 :            :                         ut_setup_security, ut_teardown,
   17967                 :            :                         test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
   17968                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17969                 :            :                         "Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
   17970                 :            :                         ut_setup_security, ut_teardown,
   17971                 :            :                         test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
   17972                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17973                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
   17974                 :            :                         ut_setup_security, ut_teardown,
   17975                 :            :                         test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
   17976                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17977                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
   17978                 :            :                         ut_setup_security, ut_teardown,
   17979                 :            :                         test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
   17980                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17981                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
   17982                 :            :                         ut_setup_security, ut_teardown,
   17983                 :            :                         test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
   17984                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17985                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
   17986                 :            :                         ut_setup_security, ut_teardown,
   17987                 :            :                         test_ipsec_proto_known_vec,
   17988                 :            :                         &pkt_aes_128_cbc_md5),
   17989                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17990                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA256 [16B ICV])",
   17991                 :            :                         ut_setup_security, ut_teardown,
   17992                 :            :                         test_ipsec_proto_known_vec,
   17993                 :            :                         &pkt_aes_128_ctr_hmac_sha256),
   17994                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17995                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA384 [16B ICV])",
   17996                 :            :                         ut_setup_security, ut_teardown,
   17997                 :            :                         test_ipsec_proto_known_vec,
   17998                 :            :                         &pkt_aes_128_ctr_hmac_sha384),
   17999                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18000                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA512 [16B ICV])",
   18001                 :            :                         ut_setup_security, ut_teardown,
   18002                 :            :                         test_ipsec_proto_known_vec,
   18003                 :            :                         &pkt_aes_128_ctr_hmac_sha512),
   18004                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18005                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA256 [16B ICV])",
   18006                 :            :                         ut_setup_security, ut_teardown,
   18007                 :            :                         test_ipsec_proto_known_vec_inb,
   18008                 :            :                         &pkt_aes_128_ctr_hmac_sha256),
   18009                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18010                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA384 [16B ICV])",
   18011                 :            :                         ut_setup_security, ut_teardown,
   18012                 :            :                         test_ipsec_proto_known_vec_inb,
   18013                 :            :                         &pkt_aes_128_ctr_hmac_sha384),
   18014                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18015                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA512 [16B ICV])",
   18016                 :            :                         ut_setup_security, ut_teardown,
   18017                 :            :                         test_ipsec_proto_known_vec_inb,
   18018                 :            :                         &pkt_aes_128_ctr_hmac_sha512),
   18019                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18020                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
   18021                 :            :                         ut_setup_security, ut_teardown,
   18022                 :            :                         test_ipsec_proto_known_vec,
   18023                 :            :                         &pkt_aes_128_cbc_hmac_sha256),
   18024                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18025                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
   18026                 :            :                         ut_setup_security, ut_teardown,
   18027                 :            :                         test_ipsec_proto_known_vec,
   18028                 :            :                         &pkt_aes_128_cbc_hmac_sha384),
   18029                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18030                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
   18031                 :            :                         ut_setup_security, ut_teardown,
   18032                 :            :                         test_ipsec_proto_known_vec,
   18033                 :            :                         &pkt_aes_128_cbc_hmac_sha512),
   18034                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18035                 :            :                         "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
   18036                 :            :                         ut_setup_security, ut_teardown,
   18037                 :            :                         test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
   18038                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18039                 :            :                         "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
   18040                 :            :                         ut_setup_security, ut_teardown,
   18041                 :            :                         test_ipsec_proto_known_vec,
   18042                 :            :                         &pkt_aes_128_cbc_hmac_sha256_v6),
   18043                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18044                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
   18045                 :            :                         ut_setup_security, ut_teardown,
   18046                 :            :                         test_ipsec_proto_known_vec,
   18047                 :            :                         &pkt_null_aes_xcbc),
   18048                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18049                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
   18050                 :            :                         ut_setup_security, ut_teardown,
   18051                 :            :                         test_ipsec_proto_known_vec,
   18052                 :            :                         &pkt_des_cbc_hmac_sha256),
   18053                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18054                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
   18055                 :            :                         ut_setup_security, ut_teardown,
   18056                 :            :                         test_ipsec_proto_known_vec,
   18057                 :            :                         &pkt_des_cbc_hmac_sha384),
   18058                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18059                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
   18060                 :            :                         ut_setup_security, ut_teardown,
   18061                 :            :                         test_ipsec_proto_known_vec,
   18062                 :            :                         &pkt_des_cbc_hmac_sha512),
   18063                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18064                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
   18065                 :            :                         ut_setup_security, ut_teardown,
   18066                 :            :                         test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
   18067                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18068                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
   18069                 :            :                         ut_setup_security, ut_teardown,
   18070                 :            :                         test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
   18071                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18072                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
   18073                 :            :                         ut_setup_security, ut_teardown,
   18074                 :            :                         test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
   18075                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18076                 :            :                         "Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
   18077                 :            :                         ut_setup_security, ut_teardown,
   18078                 :            :                         test_ipsec_proto_known_vec,
   18079                 :            :                         &pkt_des_cbc_hmac_sha256_v6),
   18080                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18081                 :            :                         "Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
   18082                 :            :                         ut_setup_security, ut_teardown,
   18083                 :            :                         test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
   18084                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18085                 :            :                         "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
   18086                 :            :                         ut_setup_security, ut_teardown,
   18087                 :            :                         test_ipsec_proto_known_vec,
   18088                 :            :                         &pkt_ah_tunnel_sha256),
   18089                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18090                 :            :                         "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
   18091                 :            :                         ut_setup_security, ut_teardown,
   18092                 :            :                         test_ipsec_proto_known_vec,
   18093                 :            :                         &pkt_ah_transport_sha256),
   18094                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18095                 :            :                         "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
   18096                 :            :                         ut_setup_security, ut_teardown,
   18097                 :            :                         test_ipsec_proto_known_vec,
   18098                 :            :                         &pkt_ah_ipv4_aes_gmac_128),
   18099                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18100                 :            :                         "Outbound fragmented packet",
   18101                 :            :                         ut_setup_security, ut_teardown,
   18102                 :            :                         test_ipsec_proto_known_vec_fragmented,
   18103                 :            :                         &pkt_aes_128_gcm_frag),
   18104                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18105                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
   18106                 :            :                         ut_setup_security, ut_teardown,
   18107                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
   18108                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18109                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
   18110                 :            :                         ut_setup_security, ut_teardown,
   18111                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
   18112                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18113                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
   18114                 :            :                         ut_setup_security, ut_teardown,
   18115                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
   18116                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18117                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
   18118                 :            :                         ut_setup_security, ut_teardown,
   18119                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
   18120                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18121                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
   18122                 :            :                         ut_setup_security, ut_teardown,
   18123                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
   18124                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18125                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
   18126                 :            :                         ut_setup_security, ut_teardown,
   18127                 :            :                         test_ipsec_proto_known_vec_inb,
   18128                 :            :                         &pkt_aes_128_cbc_md5),
   18129                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18130                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
   18131                 :            :                         ut_setup_security, ut_teardown,
   18132                 :            :                         test_ipsec_proto_known_vec_inb,
   18133                 :            :                         &pkt_aes_128_cbc_hmac_sha256),
   18134                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18135                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
   18136                 :            :                         ut_setup_security, ut_teardown,
   18137                 :            :                         test_ipsec_proto_known_vec_inb,
   18138                 :            :                         &pkt_aes_128_cbc_hmac_sha384),
   18139                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18140                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
   18141                 :            :                         ut_setup_security, ut_teardown,
   18142                 :            :                         test_ipsec_proto_known_vec_inb,
   18143                 :            :                         &pkt_aes_128_cbc_hmac_sha512),
   18144                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18145                 :            :                         "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
   18146                 :            :                         ut_setup_security, ut_teardown,
   18147                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
   18148                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18149                 :            :                         "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
   18150                 :            :                         ut_setup_security, ut_teardown,
   18151                 :            :                         test_ipsec_proto_known_vec_inb,
   18152                 :            :                         &pkt_aes_128_cbc_hmac_sha256_v6),
   18153                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18154                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
   18155                 :            :                         ut_setup_security, ut_teardown,
   18156                 :            :                         test_ipsec_proto_known_vec_inb,
   18157                 :            :                         &pkt_null_aes_xcbc),
   18158                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18159                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
   18160                 :            :                         ut_setup_security, ut_teardown,
   18161                 :            :                         test_ipsec_proto_known_vec_inb,
   18162                 :            :                         &pkt_des_cbc_hmac_sha256),
   18163                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18164                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
   18165                 :            :                         ut_setup_security, ut_teardown,
   18166                 :            :                         test_ipsec_proto_known_vec_inb,
   18167                 :            :                         &pkt_des_cbc_hmac_sha384),
   18168                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18169                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
   18170                 :            :                         ut_setup_security, ut_teardown,
   18171                 :            :                         test_ipsec_proto_known_vec_inb,
   18172                 :            :                         &pkt_des_cbc_hmac_sha512),
   18173                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18174                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
   18175                 :            :                         ut_setup_security, ut_teardown,
   18176                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
   18177                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18178                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
   18179                 :            :                         ut_setup_security, ut_teardown,
   18180                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
   18181                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18182                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
   18183                 :            :                         ut_setup_security, ut_teardown,
   18184                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
   18185                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18186                 :            :                         "Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
   18187                 :            :                         ut_setup_security, ut_teardown,
   18188                 :            :                         test_ipsec_proto_known_vec_inb,
   18189                 :            :                         &pkt_des_cbc_hmac_sha256_v6),
   18190                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18191                 :            :                         "Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
   18192                 :            :                         ut_setup_security, ut_teardown,
   18193                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
   18194                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18195                 :            :                         "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
   18196                 :            :                         ut_setup_security, ut_teardown,
   18197                 :            :                         test_ipsec_proto_known_vec_inb,
   18198                 :            :                         &pkt_ah_tunnel_sha256),
   18199                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18200                 :            :                         "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
   18201                 :            :                         ut_setup_security, ut_teardown,
   18202                 :            :                         test_ipsec_proto_known_vec_inb,
   18203                 :            :                         &pkt_ah_transport_sha256),
   18204                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18205                 :            :                         "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
   18206                 :            :                         ut_setup_security, ut_teardown,
   18207                 :            :                         test_ipsec_proto_known_vec_inb,
   18208                 :            :                         &pkt_ah_ipv4_aes_gmac_128),
   18209                 :            :                 TEST_CASE_NAMED_ST(
   18210                 :            :                         "Combined test alg list",
   18211                 :            :                         ut_setup_security, ut_teardown,
   18212                 :            :                         test_ipsec_proto_display_list),
   18213                 :            :                 TEST_CASE_NAMED_ST(
   18214                 :            :                         "Combined test alg list (AH)",
   18215                 :            :                         ut_setup_security, ut_teardown,
   18216                 :            :                         test_ipsec_proto_ah_tunnel_ipv4),
   18217                 :            :                 TEST_CASE_NAMED_ST(
   18218                 :            :                         "IV generation",
   18219                 :            :                         ut_setup_security, ut_teardown,
   18220                 :            :                         test_ipsec_proto_iv_gen),
   18221                 :            :                 TEST_CASE_NAMED_ST(
   18222                 :            :                         "UDP encapsulation",
   18223                 :            :                         ut_setup_security, ut_teardown,
   18224                 :            :                         test_ipsec_proto_udp_encap),
   18225                 :            :                 TEST_CASE_NAMED_ST(
   18226                 :            :                         "UDP encapsulation with custom ports",
   18227                 :            :                         ut_setup_security, ut_teardown,
   18228                 :            :                         test_ipsec_proto_udp_encap_custom_ports),
   18229                 :            :                 TEST_CASE_NAMED_ST(
   18230                 :            :                         "UDP encapsulation ports verification test",
   18231                 :            :                         ut_setup_security, ut_teardown,
   18232                 :            :                         test_ipsec_proto_udp_ports_verify),
   18233                 :            :                 TEST_CASE_NAMED_ST(
   18234                 :            :                         "SA expiry packets soft",
   18235                 :            :                         ut_setup_security, ut_teardown,
   18236                 :            :                         test_ipsec_proto_sa_exp_pkts_soft),
   18237                 :            :                 TEST_CASE_NAMED_ST(
   18238                 :            :                         "SA expiry packets hard",
   18239                 :            :                         ut_setup_security, ut_teardown,
   18240                 :            :                         test_ipsec_proto_sa_exp_pkts_hard),
   18241                 :            :                 TEST_CASE_NAMED_ST(
   18242                 :            :                         "Negative test: ICV corruption",
   18243                 :            :                         ut_setup_security, ut_teardown,
   18244                 :            :                         test_ipsec_proto_err_icv_corrupt),
   18245                 :            :                 TEST_CASE_NAMED_ST(
   18246                 :            :                         "Tunnel dst addr verification",
   18247                 :            :                         ut_setup_security, ut_teardown,
   18248                 :            :                         test_ipsec_proto_tunnel_dst_addr_verify),
   18249                 :            :                 TEST_CASE_NAMED_ST(
   18250                 :            :                         "Tunnel src and dst addr verification",
   18251                 :            :                         ut_setup_security, ut_teardown,
   18252                 :            :                         test_ipsec_proto_tunnel_src_dst_addr_verify),
   18253                 :            :                 TEST_CASE_NAMED_ST(
   18254                 :            :                         "Inner IP checksum",
   18255                 :            :                         ut_setup_security, ut_teardown,
   18256                 :            :                         test_ipsec_proto_inner_ip_csum),
   18257                 :            :                 TEST_CASE_NAMED_ST(
   18258                 :            :                         "Inner L4 checksum",
   18259                 :            :                         ut_setup_security, ut_teardown,
   18260                 :            :                         test_ipsec_proto_inner_l4_csum),
   18261                 :            :                 TEST_CASE_NAMED_ST(
   18262                 :            :                         "Tunnel IPv4 in IPv4",
   18263                 :            :                         ut_setup_security, ut_teardown,
   18264                 :            :                         test_ipsec_proto_tunnel_v4_in_v4),
   18265                 :            :                 TEST_CASE_NAMED_ST(
   18266                 :            :                         "Tunnel IPv6 in IPv6",
   18267                 :            :                         ut_setup_security, ut_teardown,
   18268                 :            :                         test_ipsec_proto_tunnel_v6_in_v6),
   18269                 :            :                 TEST_CASE_NAMED_ST(
   18270                 :            :                         "Tunnel IPv4 in IPv6",
   18271                 :            :                         ut_setup_security, ut_teardown,
   18272                 :            :                         test_ipsec_proto_tunnel_v4_in_v6),
   18273                 :            :                 TEST_CASE_NAMED_ST(
   18274                 :            :                         "Tunnel IPv6 in IPv4",
   18275                 :            :                         ut_setup_security, ut_teardown,
   18276                 :            :                         test_ipsec_proto_tunnel_v6_in_v4),
   18277                 :            :                 TEST_CASE_NAMED_ST(
   18278                 :            :                         "Transport IPv4",
   18279                 :            :                         ut_setup_security, ut_teardown,
   18280                 :            :                         test_ipsec_proto_transport_v4),
   18281                 :            :                 TEST_CASE_NAMED_ST(
   18282                 :            :                         "AH transport IPv4",
   18283                 :            :                         ut_setup_security, ut_teardown,
   18284                 :            :                         test_ipsec_proto_ah_transport_ipv4),
   18285                 :            :                 TEST_CASE_NAMED_ST(
   18286                 :            :                         "Transport l4 checksum",
   18287                 :            :                         ut_setup_security, ut_teardown,
   18288                 :            :                         test_ipsec_proto_transport_l4_csum),
   18289                 :            :                 TEST_CASE_NAMED_ST(
   18290                 :            :                         "Statistics: success",
   18291                 :            :                         ut_setup_security, ut_teardown,
   18292                 :            :                         test_ipsec_proto_stats),
   18293                 :            :                 TEST_CASE_NAMED_ST(
   18294                 :            :                         "Fragmented packet",
   18295                 :            :                         ut_setup_security, ut_teardown,
   18296                 :            :                         test_ipsec_proto_pkt_fragment),
   18297                 :            :                 TEST_CASE_NAMED_ST(
   18298                 :            :                         "Tunnel header copy DF (inner 0)",
   18299                 :            :                         ut_setup_security, ut_teardown,
   18300                 :            :                         test_ipsec_proto_copy_df_inner_0),
   18301                 :            :                 TEST_CASE_NAMED_ST(
   18302                 :            :                         "Tunnel header copy DF (inner 1)",
   18303                 :            :                         ut_setup_security, ut_teardown,
   18304                 :            :                         test_ipsec_proto_copy_df_inner_1),
   18305                 :            :                 TEST_CASE_NAMED_ST(
   18306                 :            :                         "Tunnel header set DF 0 (inner 1)",
   18307                 :            :                         ut_setup_security, ut_teardown,
   18308                 :            :                         test_ipsec_proto_set_df_0_inner_1),
   18309                 :            :                 TEST_CASE_NAMED_ST(
   18310                 :            :                         "Tunnel header set DF 1 (inner 0)",
   18311                 :            :                         ut_setup_security, ut_teardown,
   18312                 :            :                         test_ipsec_proto_set_df_1_inner_0),
   18313                 :            :                 TEST_CASE_NAMED_ST(
   18314                 :            :                         "Tunnel header IPv4 copy DSCP (inner 0)",
   18315                 :            :                         ut_setup_security, ut_teardown,
   18316                 :            :                         test_ipsec_proto_ipv4_copy_dscp_inner_0),
   18317                 :            :                 TEST_CASE_NAMED_ST(
   18318                 :            :                         "Tunnel header IPv4 copy DSCP (inner 1)",
   18319                 :            :                         ut_setup_security, ut_teardown,
   18320                 :            :                         test_ipsec_proto_ipv4_copy_dscp_inner_1),
   18321                 :            :                 TEST_CASE_NAMED_ST(
   18322                 :            :                         "Tunnel header IPv4 set DSCP 0 (inner 1)",
   18323                 :            :                         ut_setup_security, ut_teardown,
   18324                 :            :                         test_ipsec_proto_ipv4_set_dscp_0_inner_1),
   18325                 :            :                 TEST_CASE_NAMED_ST(
   18326                 :            :                         "Tunnel header IPv4 set DSCP 1 (inner 0)",
   18327                 :            :                         ut_setup_security, ut_teardown,
   18328                 :            :                         test_ipsec_proto_ipv4_set_dscp_1_inner_0),
   18329                 :            :                 TEST_CASE_NAMED_ST(
   18330                 :            :                         "Tunnel header IPv6 copy DSCP (inner 0)",
   18331                 :            :                         ut_setup_security, ut_teardown,
   18332                 :            :                         test_ipsec_proto_ipv6_copy_dscp_inner_0),
   18333                 :            :                 TEST_CASE_NAMED_ST(
   18334                 :            :                         "Tunnel header IPv6 copy DSCP (inner 1)",
   18335                 :            :                         ut_setup_security, ut_teardown,
   18336                 :            :                         test_ipsec_proto_ipv6_copy_dscp_inner_1),
   18337                 :            :                 TEST_CASE_NAMED_ST(
   18338                 :            :                         "Tunnel header IPv6 set DSCP 0 (inner 1)",
   18339                 :            :                         ut_setup_security, ut_teardown,
   18340                 :            :                         test_ipsec_proto_ipv6_set_dscp_0_inner_1),
   18341                 :            :                 TEST_CASE_NAMED_ST(
   18342                 :            :                         "Tunnel header IPv6 set DSCP 1 (inner 0)",
   18343                 :            :                         ut_setup_security, ut_teardown,
   18344                 :            :                         test_ipsec_proto_ipv6_set_dscp_1_inner_0),
   18345                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18346                 :            :                         "Antireplay with window size 1024",
   18347                 :            :                         ut_setup_security, ut_teardown,
   18348                 :            :                         test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
   18349                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18350                 :            :                         "Antireplay with window size 2048",
   18351                 :            :                         ut_setup_security, ut_teardown,
   18352                 :            :                         test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
   18353                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18354                 :            :                         "Antireplay with window size 4096",
   18355                 :            :                         ut_setup_security, ut_teardown,
   18356                 :            :                         test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
   18357                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18358                 :            :                         "ESN and Antireplay with window size 1024",
   18359                 :            :                         ut_setup_security, ut_teardown,
   18360                 :            :                         test_ipsec_proto_pkt_esn_antireplay1024,
   18361                 :            :                         &pkt_aes_128_gcm),
   18362                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18363                 :            :                         "ESN and Antireplay with window size 2048",
   18364                 :            :                         ut_setup_security, ut_teardown,
   18365                 :            :                         test_ipsec_proto_pkt_esn_antireplay2048,
   18366                 :            :                         &pkt_aes_128_gcm),
   18367                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18368                 :            :                         "ESN and Antireplay with window size 4096",
   18369                 :            :                         ut_setup_security, ut_teardown,
   18370                 :            :                         test_ipsec_proto_pkt_esn_antireplay4096,
   18371                 :            :                         &pkt_aes_128_gcm),
   18372                 :            :                 TEST_CASE_NAMED_ST(
   18373                 :            :                         "Tunnel header IPv4 decrement inner TTL",
   18374                 :            :                         ut_setup_security, ut_teardown,
   18375                 :            :                         test_ipsec_proto_ipv4_ttl_decrement),
   18376                 :            :                 TEST_CASE_NAMED_ST(
   18377                 :            :                         "Tunnel header IPv6 decrement inner hop limit",
   18378                 :            :                         ut_setup_security, ut_teardown,
   18379                 :            :                         test_ipsec_proto_ipv6_hop_limit_decrement),
   18380                 :            :                 TEST_CASE_NAMED_ST(
   18381                 :            :                         "Multi-segmented mode",
   18382                 :            :                         ut_setup_security, ut_teardown,
   18383                 :            :                         test_ipsec_proto_sgl),
   18384                 :            :                 TEST_CASE_NAMED_ST(
   18385                 :            :                         "Multi-segmented external mbuf mode",
   18386                 :            :                         ut_setup_security, ut_teardown,
   18387                 :            :                         test_ipsec_proto_sgl_ext_mbuf),
   18388                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18389                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
   18390                 :            :                         ut_setup_security_rx_inject, ut_teardown_rx_inject,
   18391                 :            :                         test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
   18392                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18393                 :            :         }
   18394                 :            : };
   18395                 :            : 
   18396                 :            : static struct unit_test_suite pdcp_proto_testsuite  = {
   18397                 :            :         .suite_name = "PDCP Proto Unit Test Suite",
   18398                 :            :         .setup = pdcp_proto_testsuite_setup,
   18399                 :            :         .unit_test_cases = {
   18400                 :            :                 TEST_CASE_ST(ut_setup_security, ut_teardown,
   18401                 :            :                         test_PDCP_PROTO_all),
   18402                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18403                 :            :         }
   18404                 :            : };
   18405                 :            : 
   18406                 :            : static struct unit_test_suite tls12_record_proto_testsuite  = {
   18407                 :            :         .suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
   18408                 :            :         .setup = tls_record_proto_testsuite_setup,
   18409                 :            :         .unit_test_cases = {
   18410                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18411                 :            :                         "Write record known vector AES-GCM-128 (vector 1)",
   18412                 :            :                         ut_setup_security, ut_teardown,
   18413                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
   18414                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18415                 :            :                         "Write record known vector AES-GCM-128 (vector 2)",
   18416                 :            :                         ut_setup_security, ut_teardown,
   18417                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
   18418                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18419                 :            :                         "Write record known vector AES-GCM-256",
   18420                 :            :                         ut_setup_security, ut_teardown,
   18421                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
   18422                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18423                 :            :                         "Write record known vector AES-CBC-128-SHA1",
   18424                 :            :                         ut_setup_security, ut_teardown,
   18425                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
   18426                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18427                 :            :                         "Write record known vector AES-128-CBC-SHA256",
   18428                 :            :                         ut_setup_security, ut_teardown,
   18429                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
   18430                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18431                 :            :                         "Write record known vector AES-256-CBC-SHA1",
   18432                 :            :                         ut_setup_security, ut_teardown,
   18433                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
   18434                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18435                 :            :                         "Write record known vector AES-256-CBC-SHA256",
   18436                 :            :                         ut_setup_security, ut_teardown,
   18437                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
   18438                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18439                 :            :                         "Write record known vector AES-256-CBC-SHA384",
   18440                 :            :                         ut_setup_security, ut_teardown,
   18441                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha384_hmac),
   18442                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18443                 :            :                         "Write record known vector 3DES-CBC-SHA1-HMAC",
   18444                 :            :                         ut_setup_security, ut_teardown,
   18445                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
   18446                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18447                 :            :                         "Write record known vector NULL-SHA1-HMAC",
   18448                 :            :                         ut_setup_security, ut_teardown,
   18449                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
   18450                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18451                 :            :                         "Write record known vector CHACHA20-POLY1305",
   18452                 :            :                         ut_setup_security, ut_teardown,
   18453                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
   18454                 :            : 
   18455                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18456                 :            :                         "Read record known vector AES-GCM-128 (vector 1)",
   18457                 :            :                         ut_setup_security, ut_teardown,
   18458                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
   18459                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18460                 :            :                         "Read record known vector AES-GCM-128 (vector 2)",
   18461                 :            :                         ut_setup_security, ut_teardown,
   18462                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
   18463                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18464                 :            :                         "Read record known vector AES-GCM-256",
   18465                 :            :                         ut_setup_security, ut_teardown,
   18466                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
   18467                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18468                 :            :                         "Read record known vector AES-128-CBC-SHA1",
   18469                 :            :                         ut_setup_security, ut_teardown,
   18470                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
   18471                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18472                 :            :                         "Read record known vector AES-128-CBC-SHA256",
   18473                 :            :                         ut_setup_security, ut_teardown,
   18474                 :            :                         test_tls_record_proto_known_vec_read,
   18475                 :            :                         &tls_test_data_aes_128_cbc_sha256_hmac),
   18476                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18477                 :            :                         "Read record known vector AES-256-CBC-SHA1",
   18478                 :            :                         ut_setup_security, ut_teardown,
   18479                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
   18480                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18481                 :            :                         "Read record known vector AES-256-CBC-SHA256",
   18482                 :            :                         ut_setup_security, ut_teardown,
   18483                 :            :                         test_tls_record_proto_known_vec_read,
   18484                 :            :                         &tls_test_data_aes_256_cbc_sha256_hmac),
   18485                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18486                 :            :                         "Read record known vector AES-256-CBC-SHA384",
   18487                 :            :                         ut_setup_security, ut_teardown,
   18488                 :            :                         test_tls_record_proto_known_vec_read,
   18489                 :            :                         &tls_test_data_aes_256_cbc_sha384_hmac),
   18490                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18491                 :            :                         "Read record known vector 3DES-CBC-SHA1-HMAC",
   18492                 :            :                         ut_setup_security, ut_teardown,
   18493                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
   18494                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18495                 :            :                         "Read record known vector NULL-SHA1-HMAC",
   18496                 :            :                         ut_setup_security, ut_teardown,
   18497                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
   18498                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18499                 :            :                         "Read record known vector CHACHA20-POLY1305",
   18500                 :            :                         ut_setup_security, ut_teardown,
   18501                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
   18502                 :            : 
   18503                 :            :                 TEST_CASE_NAMED_ST(
   18504                 :            :                         "Combined test alg list",
   18505                 :            :                         ut_setup_security, ut_teardown,
   18506                 :            :                         test_tls_1_2_record_proto_display_list),
   18507                 :            :                 TEST_CASE_NAMED_ST(
   18508                 :            :                         "Data walkthrough combined test alg list",
   18509                 :            :                         ut_setup_security, ut_teardown,
   18510                 :            :                         test_tls_1_2_record_proto_data_walkthrough),
   18511                 :            :                 TEST_CASE_NAMED_ST(
   18512                 :            :                         "Multi-segmented mode",
   18513                 :            :                         ut_setup_security, ut_teardown,
   18514                 :            :                         test_tls_1_2_record_proto_sgl),
   18515                 :            :                 TEST_CASE_NAMED_ST(
   18516                 :            :                         "Multi-segmented mode data walkthrough",
   18517                 :            :                         ut_setup_security, ut_teardown,
   18518                 :            :                         test_tls_1_2_record_proto_sgl_data_walkthrough),
   18519                 :            :                 TEST_CASE_NAMED_ST(
   18520                 :            :                         "Multi-segmented mode out of place",
   18521                 :            :                         ut_setup_security, ut_teardown,
   18522                 :            :                         test_tls_1_2_record_proto_sgl_oop),
   18523                 :            :                 TEST_CASE_NAMED_ST(
   18524                 :            :                         "TLS packet header corruption",
   18525                 :            :                         ut_setup_security, ut_teardown,
   18526                 :            :                         test_tls_record_proto_corrupt_pkt),
   18527                 :            :                 TEST_CASE_NAMED_ST(
   18528                 :            :                         "Custom content type",
   18529                 :            :                         ut_setup_security, ut_teardown,
   18530                 :            :                         test_tls_record_proto_custom_content_type),
   18531                 :            :                 TEST_CASE_NAMED_ST(
   18532                 :            :                         "Zero len TLS record with content type as app",
   18533                 :            :                         ut_setup_security, ut_teardown,
   18534                 :            :                         test_tls_record_proto_zero_len),
   18535                 :            :                 TEST_CASE_NAMED_ST(
   18536                 :            :                         "Zero len TLS record with content type as ctrl",
   18537                 :            :                         ut_setup_security, ut_teardown,
   18538                 :            :                         test_tls_record_proto_zero_len_non_app),
   18539                 :            :                 TEST_CASE_NAMED_ST(
   18540                 :            :                         "TLS record DM mode with optional padding < 2 blocks",
   18541                 :            :                         ut_setup_security, ut_teardown,
   18542                 :            :                         test_tls_record_proto_dm_opt_padding),
   18543                 :            :                 TEST_CASE_NAMED_ST(
   18544                 :            :                         "TLS record DM mode with optional padding > 2 blocks",
   18545                 :            :                         ut_setup_security, ut_teardown,
   18546                 :            :                         test_tls_record_proto_dm_opt_padding_1),
   18547                 :            :                 TEST_CASE_NAMED_ST(
   18548                 :            :                         "TLS record SG mode with optional padding < 2 blocks",
   18549                 :            :                         ut_setup_security, ut_teardown,
   18550                 :            :                         test_tls_record_proto_sg_opt_padding),
   18551                 :            :                 TEST_CASE_NAMED_ST(
   18552                 :            :                         "TLS record SG mode with optional padding > 2 blocks",
   18553                 :            :                         ut_setup_security, ut_teardown,
   18554                 :            :                         test_tls_record_proto_sg_opt_padding_1),
   18555                 :            :                 TEST_CASE_NAMED_ST(
   18556                 :            :                         "TLS record SG mode with optional padding > 2 blocks",
   18557                 :            :                         ut_setup_security, ut_teardown,
   18558                 :            :                         test_tls_record_proto_sg_opt_padding_2),
   18559                 :            :                 TEST_CASE_NAMED_ST(
   18560                 :            :                         "TLS record SG mode with optional padding > max range",
   18561                 :            :                         ut_setup_security, ut_teardown,
   18562                 :            :                         test_tls_record_proto_sg_opt_padding_max),
   18563                 :            :                 TEST_CASE_NAMED_ST(
   18564                 :            :                         "TLS record SG mode with padding corruption",
   18565                 :            :                         ut_setup_security, ut_teardown,
   18566                 :            :                         test_tls_record_proto_sg_opt_padding_corrupt),
   18567                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18568                 :            :         }
   18569                 :            : };
   18570                 :            : 
   18571                 :            : static struct unit_test_suite dtls12_record_proto_testsuite  = {
   18572                 :            :         .suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
   18573                 :            :         .setup = tls_record_proto_testsuite_setup,
   18574                 :            :         .unit_test_cases = {
   18575                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18576                 :            :                         "Write record known vector AES-GCM-128",
   18577                 :            :                         ut_setup_security, ut_teardown,
   18578                 :            :                         test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
   18579                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18580                 :            :                         "Write record known vector AES-GCM-256",
   18581                 :            :                         ut_setup_security, ut_teardown,
   18582                 :            :                         test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
   18583                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18584                 :            :                         "Write record known vector AES-128-CBC-SHA1",
   18585                 :            :                         ut_setup_security, ut_teardown,
   18586                 :            :                         test_tls_record_proto_known_vec,
   18587                 :            :                         &dtls_test_data_aes_128_cbc_sha1_hmac),
   18588                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18589                 :            :                         "Write record known vector AES-128-CBC-SHA256",
   18590                 :            :                         ut_setup_security, ut_teardown,
   18591                 :            :                         test_tls_record_proto_known_vec,
   18592                 :            :                         &dtls_test_data_aes_128_cbc_sha256_hmac),
   18593                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18594                 :            :                         "Write record known vector AES-256-CBC-SHA1",
   18595                 :            :                         ut_setup_security, ut_teardown,
   18596                 :            :                         test_tls_record_proto_known_vec,
   18597                 :            :                         &dtls_test_data_aes_256_cbc_sha1_hmac),
   18598                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18599                 :            :                         "Write record known vector AES-256-CBC-SHA256",
   18600                 :            :                         ut_setup_security, ut_teardown,
   18601                 :            :                         test_tls_record_proto_known_vec,
   18602                 :            :                         &dtls_test_data_aes_256_cbc_sha256_hmac),
   18603                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18604                 :            :                         "Write record known vector AES-256-CBC-SHA384",
   18605                 :            :                         ut_setup_security, ut_teardown,
   18606                 :            :                         test_tls_record_proto_known_vec,
   18607                 :            :                         &dtls_test_data_aes_256_cbc_sha384_hmac),
   18608                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18609                 :            :                         "Write record known vector 3DES-CBC-SHA1-HMAC",
   18610                 :            :                         ut_setup_security, ut_teardown,
   18611                 :            :                         test_tls_record_proto_known_vec,
   18612                 :            :                         &dtls_test_data_3des_cbc_sha1_hmac),
   18613                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18614                 :            :                         "Write record known vector NULL-SHA1-HMAC",
   18615                 :            :                         ut_setup_security, ut_teardown,
   18616                 :            :                         test_tls_record_proto_known_vec,
   18617                 :            :                         &dtls_test_data_null_cipher_sha1_hmac),
   18618                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18619                 :            :                         "Write record known vector CHACHA20-POLY1305",
   18620                 :            :                         ut_setup_security, ut_teardown,
   18621                 :            :                         test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
   18622                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18623                 :            :                         "Read record known vector AES-GCM-128",
   18624                 :            :                         ut_setup_security, ut_teardown,
   18625                 :            :                         test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
   18626                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18627                 :            :                         "Read record known vector AES-GCM-256",
   18628                 :            :                         ut_setup_security, ut_teardown,
   18629                 :            :                         test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
   18630                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18631                 :            :                         "Read record known vector AES-128-CBC-SHA1",
   18632                 :            :                         ut_setup_security, ut_teardown,
   18633                 :            :                         test_tls_record_proto_known_vec_read,
   18634                 :            :                         &dtls_test_data_aes_128_cbc_sha1_hmac),
   18635                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18636                 :            :                         "Read record known vector AES-128-CBC-SHA256",
   18637                 :            :                         ut_setup_security, ut_teardown,
   18638                 :            :                         test_tls_record_proto_known_vec_read,
   18639                 :            :                         &dtls_test_data_aes_128_cbc_sha256_hmac),
   18640                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18641                 :            :                         "Read record known vector AES-256-CBC-SHA1",
   18642                 :            :                         ut_setup_security, ut_teardown,
   18643                 :            :                         test_tls_record_proto_known_vec_read,
   18644                 :            :                         &dtls_test_data_aes_256_cbc_sha1_hmac),
   18645                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18646                 :            :                         "Read record known vector AES-256-CBC-SHA256",
   18647                 :            :                         ut_setup_security, ut_teardown,
   18648                 :            :                         test_tls_record_proto_known_vec_read,
   18649                 :            :                         &dtls_test_data_aes_256_cbc_sha256_hmac),
   18650                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18651                 :            :                         "Read record known vector AES-256-CBC-SHA384",
   18652                 :            :                         ut_setup_security, ut_teardown,
   18653                 :            :                         test_tls_record_proto_known_vec_read,
   18654                 :            :                         &dtls_test_data_aes_256_cbc_sha384_hmac),
   18655                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18656                 :            :                         "Read record known vector 3DES-CBC-SHA1-HMAC",
   18657                 :            :                         ut_setup_security, ut_teardown,
   18658                 :            :                         test_tls_record_proto_known_vec_read,
   18659                 :            :                         &dtls_test_data_3des_cbc_sha1_hmac),
   18660                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18661                 :            :                         "Read record known vector NULL-SHA1-HMAC",
   18662                 :            :                         ut_setup_security, ut_teardown,
   18663                 :            :                         test_tls_record_proto_known_vec_read,
   18664                 :            :                         &dtls_test_data_null_cipher_sha1_hmac),
   18665                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18666                 :            :                         "Read record known vector CHACHA20-POLY1305",
   18667                 :            :                         ut_setup_security, ut_teardown,
   18668                 :            :                         test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
   18669                 :            : 
   18670                 :            :                 TEST_CASE_NAMED_ST(
   18671                 :            :                         "Combined test alg list",
   18672                 :            :                         ut_setup_security, ut_teardown,
   18673                 :            :                         test_dtls_1_2_record_proto_display_list),
   18674                 :            :                 TEST_CASE_NAMED_ST(
   18675                 :            :                         "Data walkthrough combined test alg list",
   18676                 :            :                         ut_setup_security, ut_teardown,
   18677                 :            :                         test_dtls_1_2_record_proto_data_walkthrough),
   18678                 :            :                 TEST_CASE_NAMED_ST(
   18679                 :            :                         "Multi-segmented mode",
   18680                 :            :                         ut_setup_security, ut_teardown,
   18681                 :            :                         test_dtls_1_2_record_proto_sgl),
   18682                 :            :                 TEST_CASE_NAMED_ST(
   18683                 :            :                         "Multi-segmented mode data walkthrough",
   18684                 :            :                         ut_setup_security, ut_teardown,
   18685                 :            :                         test_dtls_1_2_record_proto_sgl_data_walkthrough),
   18686                 :            :                 TEST_CASE_NAMED_ST(
   18687                 :            :                         "Multi-segmented mode out of place",
   18688                 :            :                         ut_setup_security, ut_teardown,
   18689                 :            :                         test_dtls_1_2_record_proto_sgl_oop),
   18690                 :            :                 TEST_CASE_NAMED_ST(
   18691                 :            :                         "Packet corruption",
   18692                 :            :                         ut_setup_security, ut_teardown,
   18693                 :            :                         test_dtls_1_2_record_proto_corrupt_pkt),
   18694                 :            :                 TEST_CASE_NAMED_ST(
   18695                 :            :                         "Custom content type",
   18696                 :            :                         ut_setup_security, ut_teardown,
   18697                 :            :                         test_dtls_1_2_record_proto_custom_content_type),
   18698                 :            :                 TEST_CASE_NAMED_ST(
   18699                 :            :                         "Zero len DTLS record with content type as app",
   18700                 :            :                         ut_setup_security, ut_teardown,
   18701                 :            :                         test_dtls_1_2_record_proto_zero_len),
   18702                 :            :                 TEST_CASE_NAMED_ST(
   18703                 :            :                         "Zero len DTLS record with content type as ctrl",
   18704                 :            :                         ut_setup_security, ut_teardown,
   18705                 :            :                         test_dtls_1_2_record_proto_zero_len_non_app),
   18706                 :            :                 TEST_CASE_NAMED_ST(
   18707                 :            :                         "Antireplay with window size 64",
   18708                 :            :                         ut_setup_security, ut_teardown,
   18709                 :            :                         test_dtls_1_2_record_proto_antireplay64),
   18710                 :            :                 TEST_CASE_NAMED_ST(
   18711                 :            :                         "Antireplay with window size 128",
   18712                 :            :                         ut_setup_security, ut_teardown,
   18713                 :            :                         test_dtls_1_2_record_proto_antireplay128),
   18714                 :            :                 TEST_CASE_NAMED_ST(
   18715                 :            :                         "Antireplay with window size 256",
   18716                 :            :                         ut_setup_security, ut_teardown,
   18717                 :            :                         test_dtls_1_2_record_proto_antireplay256),
   18718                 :            :                 TEST_CASE_NAMED_ST(
   18719                 :            :                         "Antireplay with window size 512",
   18720                 :            :                         ut_setup_security, ut_teardown,
   18721                 :            :                         test_dtls_1_2_record_proto_antireplay512),
   18722                 :            :                 TEST_CASE_NAMED_ST(
   18723                 :            :                         "Antireplay with window size 1024",
   18724                 :            :                         ut_setup_security, ut_teardown,
   18725                 :            :                         test_dtls_1_2_record_proto_antireplay1024),
   18726                 :            :                 TEST_CASE_NAMED_ST(
   18727                 :            :                         "Antireplay with window size 2048",
   18728                 :            :                         ut_setup_security, ut_teardown,
   18729                 :            :                         test_dtls_1_2_record_proto_antireplay2048),
   18730                 :            :                 TEST_CASE_NAMED_ST(
   18731                 :            :                         "Antireplay with window size 4096",
   18732                 :            :                         ut_setup_security, ut_teardown,
   18733                 :            :                         test_dtls_1_2_record_proto_antireplay4096),
   18734                 :            :                 TEST_CASE_NAMED_ST(
   18735                 :            :                         "DTLS record DM mode with optional padding < 2 blocks",
   18736                 :            :                         ut_setup_security, ut_teardown,
   18737                 :            :                         test_dtls_1_2_record_proto_dm_opt_padding),
   18738                 :            :                 TEST_CASE_NAMED_ST(
   18739                 :            :                         "DTLS record DM mode with optional padding > 2 blocks",
   18740                 :            :                         ut_setup_security, ut_teardown,
   18741                 :            :                         test_dtls_1_2_record_proto_dm_opt_padding_1),
   18742                 :            :                 TEST_CASE_NAMED_ST(
   18743                 :            :                         "DTLS record SG mode with optional padding < 2 blocks",
   18744                 :            :                         ut_setup_security, ut_teardown,
   18745                 :            :                         test_dtls_1_2_record_proto_sg_opt_padding),
   18746                 :            :                 TEST_CASE_NAMED_ST(
   18747                 :            :                         "DTLS record SG mode with optional padding > 2 blocks",
   18748                 :            :                         ut_setup_security, ut_teardown,
   18749                 :            :                         test_dtls_1_2_record_proto_sg_opt_padding_1),
   18750                 :            :                 TEST_CASE_NAMED_ST(
   18751                 :            :                         "DTLS record SG mode with optional padding > 2 blocks",
   18752                 :            :                         ut_setup_security, ut_teardown,
   18753                 :            :                         test_dtls_1_2_record_proto_sg_opt_padding_2),
   18754                 :            :                 TEST_CASE_NAMED_ST(
   18755                 :            :                         "DTLS record SG mode with optional padding > max range",
   18756                 :            :                         ut_setup_security, ut_teardown,
   18757                 :            :                         test_dtls_1_2_record_proto_sg_opt_padding_max),
   18758                 :            :                 TEST_CASE_NAMED_ST(
   18759                 :            :                         "DTLS record SG mode with padding corruption",
   18760                 :            :                         ut_setup_security, ut_teardown,
   18761                 :            :                         test_dtls_1_2_record_proto_sg_opt_padding_corrupt),
   18762                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18763                 :            :         }
   18764                 :            : };
   18765                 :            : 
   18766                 :            : static struct unit_test_suite tls13_record_proto_testsuite  = {
   18767                 :            :         .suite_name = "TLS 1.3 Record Protocol Unit Test Suite",
   18768                 :            :         .setup = tls_record_proto_testsuite_setup,
   18769                 :            :         .unit_test_cases = {
   18770                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18771                 :            :                         "Write record known vector AES-GCM-128",
   18772                 :            :                         ut_setup_security, ut_teardown,
   18773                 :            :                         test_tls_record_proto_known_vec, &tls13_test_data_aes_128_gcm),
   18774                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18775                 :            :                         "Write record known vector AES-GCM-256",
   18776                 :            :                         ut_setup_security, ut_teardown,
   18777                 :            :                         test_tls_record_proto_known_vec, &tls13_test_data_aes_256_gcm),
   18778                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18779                 :            :                         "Write record known vector CHACHA20-POLY1305",
   18780                 :            :                         ut_setup_security, ut_teardown,
   18781                 :            :                         test_tls_record_proto_known_vec, &tls13_test_data_chacha20_poly1305),
   18782                 :            : 
   18783                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18784                 :            :                         "Read record known vector AES-GCM-128",
   18785                 :            :                         ut_setup_security, ut_teardown,
   18786                 :            :                         test_tls_record_proto_known_vec_read, &tls13_test_data_aes_128_gcm),
   18787                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18788                 :            :                         "Read record known vector AES-GCM-256",
   18789                 :            :                         ut_setup_security, ut_teardown,
   18790                 :            :                         test_tls_record_proto_known_vec_read, &tls13_test_data_aes_256_gcm),
   18791                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18792                 :            :                         "Read record known vector CHACHA20-POLY1305",
   18793                 :            :                         ut_setup_security, ut_teardown,
   18794                 :            :                         test_tls_record_proto_known_vec_read, &tls13_test_data_chacha20_poly1305),
   18795                 :            :                 TEST_CASE_NAMED_ST(
   18796                 :            :                         "TLS-1.3 record header corruption",
   18797                 :            :                         ut_setup_security, ut_teardown,
   18798                 :            :                         test_tls_1_3_record_proto_corrupt_pkt),
   18799                 :            :                 TEST_CASE_NAMED_ST(
   18800                 :            :                         "TLS-1.3 record header with custom content type",
   18801                 :            :                         ut_setup_security, ut_teardown,
   18802                 :            :                         test_tls_1_3_record_proto_custom_content_type),
   18803                 :            :                 TEST_CASE_NAMED_ST(
   18804                 :            :                         "TLS-1.3 record with zero len and content type as app",
   18805                 :            :                         ut_setup_security, ut_teardown,
   18806                 :            :                         test_tls_1_3_record_proto_zero_len),
   18807                 :            :                 TEST_CASE_NAMED_ST(
   18808                 :            :                         "TLS-1.3 record with zero len and content type as ctrl",
   18809                 :            :                         ut_setup_security, ut_teardown,
   18810                 :            :                         test_tls_1_3_record_proto_zero_len_non_app),
   18811                 :            :                 TEST_CASE_NAMED_ST(
   18812                 :            :                         "TLS-1.3 record DM mode with optional padding",
   18813                 :            :                         ut_setup_security, ut_teardown,
   18814                 :            :                         test_tls_1_3_record_proto_dm_opt_padding),
   18815                 :            :                 TEST_CASE_NAMED_ST(
   18816                 :            :                         "TLS-1.3 record SG mode with optional padding - 1",
   18817                 :            :                         ut_setup_security, ut_teardown,
   18818                 :            :                         test_tls_1_3_record_proto_sg_opt_padding),
   18819                 :            :                 TEST_CASE_NAMED_ST(
   18820                 :            :                         "TLS-1.3 record SG mode with optional padding",
   18821                 :            :                         ut_setup_security, ut_teardown,
   18822                 :            :                         test_tls_1_3_record_proto_sg_opt_padding_1),
   18823                 :            :                 TEST_CASE_NAMED_ST(
   18824                 :            :                         "Combined test alg list",
   18825                 :            :                         ut_setup_security, ut_teardown,
   18826                 :            :                         test_tls_1_3_record_proto_display_list),
   18827                 :            :                 TEST_CASE_NAMED_ST(
   18828                 :            :                         "Data walkthrough combined test alg list",
   18829                 :            :                         ut_setup_security, ut_teardown,
   18830                 :            :                         test_tls_1_3_record_proto_data_walkthrough),
   18831                 :            :                 TEST_CASE_NAMED_ST(
   18832                 :            :                         "Multi-segmented mode",
   18833                 :            :                         ut_setup_security, ut_teardown,
   18834                 :            :                         test_tls_1_3_record_proto_sgl),
   18835                 :            :                 TEST_CASE_NAMED_ST(
   18836                 :            :                         "Multi-segmented mode data walkthrough",
   18837                 :            :                         ut_setup_security, ut_teardown,
   18838                 :            :                         test_tls_1_3_record_proto_sgl_data_walkthrough),
   18839                 :            :                 TEST_CASE_NAMED_ST(
   18840                 :            :                         "Multi-segmented mode out of place",
   18841                 :            :                         ut_setup_security, ut_teardown,
   18842                 :            :                         test_tls_1_3_record_proto_sgl_oop),
   18843                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18844                 :            :         }
   18845                 :            : };
   18846                 :            : 
   18847                 :            : #define ADD_UPLINK_TESTCASE(data)                                               \
   18848                 :            :         TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security,    \
   18849                 :            :         ut_teardown, test_docsis_proto_uplink, (const void *) &data),               \
   18850                 :            : 
   18851                 :            : #define ADD_DOWNLINK_TESTCASE(data)                                             \
   18852                 :            :         TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security,  \
   18853                 :            :         ut_teardown, test_docsis_proto_downlink, (const void *) &data),             \
   18854                 :            : 
   18855                 :            : static struct unit_test_suite docsis_proto_testsuite  = {
   18856                 :            :         .suite_name = "DOCSIS Proto Unit Test Suite",
   18857                 :            :         .setup = docsis_proto_testsuite_setup,
   18858                 :            :         .unit_test_cases = {
   18859                 :            :                 /* Uplink */
   18860                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_1)
   18861                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_2)
   18862                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_3)
   18863                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_4)
   18864                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_5)
   18865                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_6)
   18866                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_7)
   18867                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_8)
   18868                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_9)
   18869                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_10)
   18870                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_11)
   18871                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_12)
   18872                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_13)
   18873                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_14)
   18874                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_15)
   18875                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_16)
   18876                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_17)
   18877                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_18)
   18878                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_19)
   18879                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_20)
   18880                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_21)
   18881                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_22)
   18882                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_23)
   18883                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_24)
   18884                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_25)
   18885                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_26)
   18886                 :            :                 /* Downlink */
   18887                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
   18888                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
   18889                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
   18890                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
   18891                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
   18892                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
   18893                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
   18894                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
   18895                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
   18896                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
   18897                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
   18898                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
   18899                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
   18900                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
   18901                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
   18902                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
   18903                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
   18904                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
   18905                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
   18906                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
   18907                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
   18908                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
   18909                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
   18910                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
   18911                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
   18912                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
   18913                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18914                 :            :         }
   18915                 :            : };
   18916                 :            : #endif
   18917                 :            : 
   18918                 :            : static struct unit_test_suite cryptodev_gen_testsuite  = {
   18919                 :            :         .suite_name = "Crypto General Unit Test Suite",
   18920                 :            :         .setup = crypto_gen_testsuite_setup,
   18921                 :            :         .unit_test_cases = {
   18922                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18923                 :            :                                 test_device_reconfigure),
   18924                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18925                 :            :                                 test_device_configure_invalid_dev_id),
   18926                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18927                 :            :                                 test_queue_pair_descriptor_setup),
   18928                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18929                 :            :                                 test_device_configure_invalid_queue_pair_ids),
   18930                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18931                 :            :                                 test_queue_pair_descriptor_count),
   18932                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
   18933                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
   18934                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
   18935                 :            :                 TEST_CASE_NAMED_WITH_DATA("Verify cryptodev error recover", ut_setup, ut_teardown,
   18936                 :            :                                           test_cryptodev_verify_error_recover, &aes_test_data_4),
   18937                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18938                 :            :         }
   18939                 :            : };
   18940                 :            : 
   18941                 :            : static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
   18942                 :            :         .suite_name = "Negative HMAC SHA1 Unit Test Suite",
   18943                 :            :         .setup = negative_hmac_sha1_testsuite_setup,
   18944                 :            :         .unit_test_cases = {
   18945                 :            :                 /** Negative tests */
   18946                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18947                 :            :                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
   18948                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18949                 :            :                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
   18950                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18951                 :            :                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
   18952                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18953                 :            :                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
   18954                 :            : 
   18955                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18956                 :            :         }
   18957                 :            : };
   18958                 :            : 
   18959                 :            : static struct unit_test_suite cryptodev_multi_session_testsuite = {
   18960                 :            :         .suite_name = "Multi Session Unit Test Suite",
   18961                 :            :         .setup = multi_session_testsuite_setup,
   18962                 :            :         .unit_test_cases = {
   18963                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
   18964                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18965                 :            :                                 test_multi_session_random_usage),
   18966                 :            : 
   18967                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18968                 :            :         }
   18969                 :            : };
   18970                 :            : 
   18971                 :            : static struct unit_test_suite cryptodev_null_testsuite  = {
   18972                 :            :         .suite_name = "NULL Test Suite",
   18973                 :            :         .setup = null_testsuite_setup,
   18974                 :            :         .unit_test_cases = {
   18975                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18976                 :            :                         test_null_invalid_operation),
   18977                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
   18978                 :            :                 TEST_CASES_END()
   18979                 :            :         }
   18980                 :            : };
   18981                 :            : 
   18982                 :            : static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite  = {
   18983                 :            :         .suite_name = "AES CCM Authenticated Test Suite",
   18984                 :            :         .setup = aes_ccm_auth_testsuite_setup,
   18985                 :            :         .unit_test_cases = {
   18986                 :            :                 /** AES CCM Authenticated Encryption 128 bits key*/
   18987                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18988                 :            :                         test_AES_CCM_authenticated_encryption_test_case_128_1),
   18989                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18990                 :            :                         test_AES_CCM_authenticated_encryption_test_case_128_2),
   18991                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18992                 :            :                         test_AES_CCM_authenticated_encryption_test_case_128_3),
   18993                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18994                 :            :                         test_AES_CCM_authenticated_encryption_test_case_128_4),
   18995                 :            : 
   18996                 :            :                 /** AES CCM Authenticated Decryption 128 bits key*/
   18997                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18998                 :            :                         test_AES_CCM_authenticated_decryption_test_case_128_1),
   18999                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19000                 :            :                         test_AES_CCM_authenticated_decryption_test_case_128_2),
   19001                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19002                 :            :                         test_AES_CCM_authenticated_decryption_test_case_128_3),
   19003                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19004                 :            :                         test_AES_CCM_authenticated_decryption_test_case_128_4),
   19005                 :            : 
   19006                 :            :                 /** AES CCM Authenticated Encryption 192 bits key */
   19007                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19008                 :            :                         test_AES_CCM_authenticated_encryption_test_case_192_1),
   19009                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19010                 :            :                         test_AES_CCM_authenticated_encryption_test_case_192_2),
   19011                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19012                 :            :                         test_AES_CCM_authenticated_encryption_test_case_192_3),
   19013                 :            : 
   19014                 :            :                 /** AES CCM Authenticated Decryption 192 bits key*/
   19015                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19016                 :            :                         test_AES_CCM_authenticated_decryption_test_case_192_1),
   19017                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19018                 :            :                         test_AES_CCM_authenticated_decryption_test_case_192_2),
   19019                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19020                 :            :                         test_AES_CCM_authenticated_decryption_test_case_192_3),
   19021                 :            : 
   19022                 :            :                 /** AES CCM Authenticated Encryption 256 bits key */
   19023                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19024                 :            :                         test_AES_CCM_authenticated_encryption_test_case_256_1),
   19025                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19026                 :            :                         test_AES_CCM_authenticated_encryption_test_case_256_2),
   19027                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19028                 :            :                         test_AES_CCM_authenticated_encryption_test_case_256_3),
   19029                 :            : 
   19030                 :            :                 /** AES CCM Authenticated Decryption 256 bits key*/
   19031                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19032                 :            :                         test_AES_CCM_authenticated_decryption_test_case_256_1),
   19033                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19034                 :            :                         test_AES_CCM_authenticated_decryption_test_case_256_2),
   19035                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19036                 :            :                         test_AES_CCM_authenticated_decryption_test_case_256_3),
   19037                 :            :                 TEST_CASES_END()
   19038                 :            :         }
   19039                 :            : };
   19040                 :            : 
   19041                 :            : static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite  = {
   19042                 :            :         .suite_name = "AES GCM Authenticated Test Suite",
   19043                 :            :         .setup = aes_gcm_auth_testsuite_setup,
   19044                 :            :         .unit_test_cases = {
   19045                 :            :                 /** AES GCM Authenticated Encryption */
   19046                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19047                 :            :                         test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
   19048                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19049                 :            :                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
   19050                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19051                 :            :                         test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
   19052                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19053                 :            :                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
   19054                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19055                 :            :                         test_AES_GCM_authenticated_encryption_test_case_1),
   19056                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19057                 :            :                         test_AES_GCM_authenticated_encryption_test_case_2),
   19058                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19059                 :            :                         test_AES_GCM_authenticated_encryption_test_case_3),
   19060                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19061                 :            :                         test_AES_GCM_authenticated_encryption_test_case_4),
   19062                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19063                 :            :                         test_AES_GCM_authenticated_encryption_test_case_5),
   19064                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19065                 :            :                         test_AES_GCM_authenticated_encryption_test_case_6),
   19066                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19067                 :            :                         test_AES_GCM_authenticated_encryption_test_case_7),
   19068                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19069                 :            :                         test_AES_GCM_authenticated_encryption_test_case_8),
   19070                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19071                 :            :                         test_AES_GCM_J0_authenticated_encryption_test_case_1),
   19072                 :            : 
   19073                 :            :                 /** AES GCM Authenticated Decryption */
   19074                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19075                 :            :                         test_AES_GCM_authenticated_decryption_test_case_1),
   19076                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19077                 :            :                         test_AES_GCM_authenticated_decryption_test_case_2),
   19078                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19079                 :            :                         test_AES_GCM_authenticated_decryption_test_case_3),
   19080                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19081                 :            :                         test_AES_GCM_authenticated_decryption_test_case_4),
   19082                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19083                 :            :                         test_AES_GCM_authenticated_decryption_test_case_5),
   19084                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19085                 :            :                         test_AES_GCM_authenticated_decryption_test_case_6),
   19086                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19087                 :            :                         test_AES_GCM_authenticated_decryption_test_case_7),
   19088                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19089                 :            :                         test_AES_GCM_authenticated_decryption_test_case_8),
   19090                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19091                 :            :                         test_AES_GCM_J0_authenticated_decryption_test_case_1),
   19092                 :            : 
   19093                 :            :                 /** AES GCM Authenticated Encryption 192 bits key */
   19094                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19095                 :            :                         test_AES_GCM_auth_encryption_test_case_192_1),
   19096                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19097                 :            :                         test_AES_GCM_auth_encryption_test_case_192_2),
   19098                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19099                 :            :                         test_AES_GCM_auth_encryption_test_case_192_3),
   19100                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19101                 :            :                         test_AES_GCM_auth_encryption_test_case_192_4),
   19102                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19103                 :            :                         test_AES_GCM_auth_encryption_test_case_192_5),
   19104                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19105                 :            :                         test_AES_GCM_auth_encryption_test_case_192_6),
   19106                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19107                 :            :                         test_AES_GCM_auth_encryption_test_case_192_7),
   19108                 :            : 
   19109                 :            :                 /** AES GCM Authenticated Decryption 192 bits key */
   19110                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19111                 :            :                         test_AES_GCM_auth_decryption_test_case_192_1),
   19112                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19113                 :            :                         test_AES_GCM_auth_decryption_test_case_192_2),
   19114                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19115                 :            :                         test_AES_GCM_auth_decryption_test_case_192_3),
   19116                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19117                 :            :                         test_AES_GCM_auth_decryption_test_case_192_4),
   19118                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19119                 :            :                         test_AES_GCM_auth_decryption_test_case_192_5),
   19120                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19121                 :            :                         test_AES_GCM_auth_decryption_test_case_192_6),
   19122                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19123                 :            :                         test_AES_GCM_auth_decryption_test_case_192_7),
   19124                 :            : 
   19125                 :            :                 /** AES GCM Authenticated Encryption 256 bits key */
   19126                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19127                 :            :                         test_AES_GCM_auth_encryption_test_case_256_1),
   19128                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19129                 :            :                         test_AES_GCM_auth_encryption_test_case_256_2),
   19130                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19131                 :            :                         test_AES_GCM_auth_encryption_test_case_256_3),
   19132                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19133                 :            :                         test_AES_GCM_auth_encryption_test_case_256_4),
   19134                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19135                 :            :                         test_AES_GCM_auth_encryption_test_case_256_5),
   19136                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19137                 :            :                         test_AES_GCM_auth_encryption_test_case_256_6),
   19138                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19139                 :            :                         test_AES_GCM_auth_encryption_test_case_256_7),
   19140                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19141                 :            :                         test_AES_GCM_auth_encryption_test_case_256_8),
   19142                 :            : 
   19143                 :            :                 /** AES GCM Authenticated Decryption 256 bits key */
   19144                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19145                 :            :                         test_AES_GCM_auth_decryption_test_case_256_1),
   19146                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19147                 :            :                         test_AES_GCM_auth_decryption_test_case_256_2),
   19148                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19149                 :            :                         test_AES_GCM_auth_decryption_test_case_256_3),
   19150                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19151                 :            :                         test_AES_GCM_auth_decryption_test_case_256_4),
   19152                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19153                 :            :                         test_AES_GCM_auth_decryption_test_case_256_5),
   19154                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19155                 :            :                         test_AES_GCM_auth_decryption_test_case_256_6),
   19156                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19157                 :            :                         test_AES_GCM_auth_decryption_test_case_256_7),
   19158                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19159                 :            :                         test_AES_GCM_auth_decryption_test_case_256_8),
   19160                 :            : 
   19161                 :            :                 /** AES GCM Authenticated Encryption big aad size */
   19162                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19163                 :            :                         test_AES_GCM_auth_encryption_test_case_aad_1),
   19164                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19165                 :            :                         test_AES_GCM_auth_encryption_test_case_aad_2),
   19166                 :            : 
   19167                 :            :                 /** AES GCM Authenticated Decryption big aad size */
   19168                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19169                 :            :                         test_AES_GCM_auth_decryption_test_case_aad_1),
   19170                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19171                 :            :                         test_AES_GCM_auth_decryption_test_case_aad_2),
   19172                 :            : 
   19173                 :            :                 /** Out of place tests */
   19174                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19175                 :            :                         test_AES_GCM_authenticated_encryption_oop_test_case_1),
   19176                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19177                 :            :                         test_AES_GCM_authenticated_decryption_oop_test_case_1),
   19178                 :            : 
   19179                 :            :                 /** Session-less tests */
   19180                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19181                 :            :                         test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
   19182                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19183                 :            :                         test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
   19184                 :            : 
   19185                 :            :                 /** AES GCM external mbuf tests */
   19186                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19187                 :            :                         test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
   19188                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19189                 :            :                         test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
   19190                 :            : 
   19191                 :            :                 TEST_CASES_END()
   19192                 :            :         }
   19193                 :            : };
   19194                 :            : 
   19195                 :            : static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite  = {
   19196                 :            :         .suite_name = "AES GMAC Authentication Test Suite",
   19197                 :            :         .setup = aes_gmac_auth_testsuite_setup,
   19198                 :            :         .unit_test_cases = {
   19199                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19200                 :            :                         test_AES_GMAC_authentication_test_case_1),
   19201                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19202                 :            :                         test_AES_GMAC_authentication_verify_test_case_1),
   19203                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19204                 :            :                         test_AES_GMAC_authentication_test_case_2),
   19205                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19206                 :            :                         test_AES_GMAC_authentication_verify_test_case_2),
   19207                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19208                 :            :                         test_AES_GMAC_authentication_test_case_3),
   19209                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19210                 :            :                         test_AES_GMAC_authentication_verify_test_case_3),
   19211                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19212                 :            :                         test_AES_GMAC_authentication_test_case_4),
   19213                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19214                 :            :                         test_AES_GMAC_authentication_verify_test_case_4),
   19215                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19216                 :            :                         test_AES_GMAC_authentication_SGL_40B),
   19217                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19218                 :            :                         test_AES_GMAC_authentication_SGL_80B),
   19219                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19220                 :            :                         test_AES_GMAC_authentication_SGL_2048B),
   19221                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19222                 :            :                         test_AES_GMAC_authentication_SGL_2047B),
   19223                 :            : 
   19224                 :            :                 TEST_CASES_END()
   19225                 :            :         }
   19226                 :            : };
   19227                 :            : 
   19228                 :            : static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite  = {
   19229                 :            :         .suite_name = "Chacha20-Poly1305 Test Suite",
   19230                 :            :         .setup = chacha20_poly1305_testsuite_setup,
   19231                 :            :         .unit_test_cases = {
   19232                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19233                 :            :                         test_chacha20_poly1305_encrypt_test_case_rfc8439),
   19234                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19235                 :            :                         test_chacha20_poly1305_decrypt_test_case_rfc8439),
   19236                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19237                 :            :                         test_chacha20_poly1305_encrypt_SGL_out_of_place),
   19238                 :            :                 TEST_CASES_END()
   19239                 :            :         }
   19240                 :            : };
   19241                 :            : 
   19242                 :            : static struct unit_test_suite cryptodev_snow3g_testsuite  = {
   19243                 :            :         .suite_name = "SNOW 3G Test Suite",
   19244                 :            :         .setup = snow3g_testsuite_setup,
   19245                 :            :         .unit_test_cases = {
   19246                 :            :                 /** SNOW 3G encrypt only (UEA2) */
   19247                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19248                 :            :                         test_snow3g_encryption_test_case_1),
   19249                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19250                 :            :                         test_snow3g_encryption_test_case_2),
   19251                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19252                 :            :                         test_snow3g_encryption_test_case_3),
   19253                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19254                 :            :                         test_snow3g_encryption_test_case_4),
   19255                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19256                 :            :                         test_snow3g_encryption_test_case_5),
   19257                 :            : 
   19258                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19259                 :            :                         test_snow3g_encryption_test_case_1_oop),
   19260                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19261                 :            :                         test_snow3g_encryption_test_case_1_oop_sgl),
   19262                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19263                 :            :                         test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
   19264                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19265                 :            :                         test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
   19266                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19267                 :            :                         test_snow3g_encryption_test_case_1_offset_oop),
   19268                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19269                 :            :                         test_snow3g_decryption_test_case_1_oop),
   19270                 :            : 
   19271                 :            :                 /** SNOW 3G generate auth, then encrypt (UEA2) */
   19272                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19273                 :            :                         test_snow3g_auth_cipher_test_case_1),
   19274                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19275                 :            :                         test_snow3g_auth_cipher_test_case_2),
   19276                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19277                 :            :                         test_snow3g_auth_cipher_test_case_2_oop),
   19278                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19279                 :            :                         test_snow3g_auth_cipher_part_digest_enc),
   19280                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19281                 :            :                         test_snow3g_auth_cipher_part_digest_enc_oop),
   19282                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19283                 :            :                         test_snow3g_auth_cipher_test_case_3_sgl),
   19284                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19285                 :            :                         test_snow3g_auth_cipher_test_case_3_oop_sgl),
   19286                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19287                 :            :                         test_snow3g_auth_cipher_part_digest_enc_sgl),
   19288                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19289                 :            :                         test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
   19290                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19291                 :            :                         test_snow3g_auth_cipher_total_digest_enc_1),
   19292                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19293                 :            :                         test_snow3g_auth_cipher_total_digest_enc_1_oop),
   19294                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19295                 :            :                         test_snow3g_auth_cipher_total_digest_enc_1_sgl),
   19296                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19297                 :            :                         test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
   19298                 :            : 
   19299                 :            :                 /** SNOW 3G decrypt (UEA2), then verify auth */
   19300                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19301                 :            :                         test_snow3g_auth_cipher_verify_test_case_1),
   19302                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19303                 :            :                         test_snow3g_auth_cipher_verify_test_case_2),
   19304                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19305                 :            :                         test_snow3g_auth_cipher_verify_test_case_2_oop),
   19306                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19307                 :            :                         test_snow3g_auth_cipher_verify_part_digest_enc),
   19308                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19309                 :            :                         test_snow3g_auth_cipher_verify_part_digest_enc_oop),
   19310                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19311                 :            :                         test_snow3g_auth_cipher_verify_test_case_3_sgl),
   19312                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19313                 :            :                         test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
   19314                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19315                 :            :                         test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
   19316                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19317                 :            :                         test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
   19318                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19319                 :            :                         test_snow3g_auth_cipher_verify_total_digest_enc_1),
   19320                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19321                 :            :                         test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
   19322                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19323                 :            :                         test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
   19324                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19325                 :            :                         test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
   19326                 :            : 
   19327                 :            :                 /** SNOW 3G decrypt only (UEA2) */
   19328                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19329                 :            :                         test_snow3g_decryption_test_case_1),
   19330                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19331                 :            :                         test_snow3g_decryption_test_case_2),
   19332                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19333                 :            :                         test_snow3g_decryption_test_case_3),
   19334                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19335                 :            :                         test_snow3g_decryption_test_case_4),
   19336                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19337                 :            :                         test_snow3g_decryption_test_case_5),
   19338                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19339                 :            :                         test_snow3g_decryption_with_digest_test_case_1),
   19340                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19341                 :            :                         test_snow3g_hash_generate_test_case_1),
   19342                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19343                 :            :                         test_snow3g_hash_generate_test_case_2),
   19344                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19345                 :            :                         test_snow3g_hash_generate_test_case_3),
   19346                 :            : 
   19347                 :            :                 /* Tests with buffers which length is not byte-aligned */
   19348                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19349                 :            :                         test_snow3g_hash_generate_test_case_4),
   19350                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19351                 :            :                         test_snow3g_hash_generate_test_case_5),
   19352                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19353                 :            :                         test_snow3g_hash_generate_test_case_6),
   19354                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19355                 :            :                         test_snow3g_hash_verify_test_case_1),
   19356                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19357                 :            :                         test_snow3g_hash_verify_test_case_2),
   19358                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19359                 :            :                         test_snow3g_hash_verify_test_case_3),
   19360                 :            : 
   19361                 :            :                 /* Tests with buffers which length is not byte-aligned */
   19362                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19363                 :            :                         test_snow3g_hash_verify_test_case_4),
   19364                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19365                 :            :                         test_snow3g_hash_verify_test_case_5),
   19366                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19367                 :            :                         test_snow3g_hash_verify_test_case_6),
   19368                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19369                 :            :                         test_snow3g_cipher_auth_test_case_1),
   19370                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19371                 :            :                         test_snow3g_auth_cipher_with_digest_test_case_1),
   19372                 :            :                 TEST_CASES_END()
   19373                 :            :         }
   19374                 :            : };
   19375                 :            : 
   19376                 :            : static struct unit_test_suite cryptodev_zuc_testsuite  = {
   19377                 :            :         .suite_name = "ZUC Test Suite",
   19378                 :            :         .setup = zuc_testsuite_setup,
   19379                 :            :         .unit_test_cases = {
   19380                 :            :                 /** ZUC encrypt only (EEA3) */
   19381                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19382                 :            :                         test_zuc_encryption_test_case_1),
   19383                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19384                 :            :                         test_zuc_encryption_test_case_2),
   19385                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19386                 :            :                         test_zuc_encryption_test_case_3),
   19387                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19388                 :            :                         test_zuc_encryption_test_case_4),
   19389                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19390                 :            :                         test_zuc_encryption_test_case_5),
   19391                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19392                 :            :                         test_zuc_encryption_test_case_6_sgl),
   19393                 :            : 
   19394                 :            :                 /** ZUC decrypt only (EEA3) */
   19395                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19396                 :            :                         test_zuc_decryption_test_case_1),
   19397                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19398                 :            :                         test_zuc_decryption_test_case_2),
   19399                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19400                 :            :                         test_zuc_decryption_test_case_3),
   19401                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19402                 :            :                         test_zuc_decryption_test_case_4),
   19403                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19404                 :            :                         test_zuc_decryption_test_case_5),
   19405                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19406                 :            :                         test_zuc_decryption_test_case_6_sgl),
   19407                 :            : 
   19408                 :            :                 /** ZUC authenticate (EIA3) */
   19409                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19410                 :            :                         test_zuc_hash_generate_test_case_1),
   19411                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19412                 :            :                         test_zuc_hash_generate_test_case_2),
   19413                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19414                 :            :                         test_zuc_hash_generate_test_case_3),
   19415                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19416                 :            :                         test_zuc_hash_generate_test_case_4),
   19417                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19418                 :            :                         test_zuc_hash_generate_test_case_5),
   19419                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19420                 :            :                         test_zuc_hash_generate_test_case_6),
   19421                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19422                 :            :                         test_zuc_hash_generate_test_case_7),
   19423                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19424                 :            :                         test_zuc_hash_generate_test_case_8),
   19425                 :            : 
   19426                 :            :                 /** ZUC verify (EIA3) */
   19427                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19428                 :            :                         test_zuc_hash_verify_test_case_1),
   19429                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19430                 :            :                         test_zuc_hash_verify_test_case_2),
   19431                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19432                 :            :                         test_zuc_hash_verify_test_case_3),
   19433                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19434                 :            :                         test_zuc_hash_verify_test_case_4),
   19435                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19436                 :            :                         test_zuc_hash_verify_test_case_5),
   19437                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19438                 :            :                         test_zuc_hash_verify_test_case_6),
   19439                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19440                 :            :                         test_zuc_hash_verify_test_case_7),
   19441                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19442                 :            :                         test_zuc_hash_verify_test_case_8),
   19443                 :            : 
   19444                 :            :                 /** ZUC alg-chain (EEA3/EIA3) */
   19445                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19446                 :            :                         test_zuc_cipher_auth_test_case_1),
   19447                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19448                 :            :                         test_zuc_cipher_auth_test_case_2),
   19449                 :            : 
   19450                 :            :                 /** ZUC generate auth, then encrypt (EEA3) */
   19451                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19452                 :            :                         test_zuc_auth_cipher_test_case_1),
   19453                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19454                 :            :                         test_zuc_auth_cipher_test_case_1_oop),
   19455                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19456                 :            :                         test_zuc_auth_cipher_test_case_1_sgl),
   19457                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19458                 :            :                         test_zuc_auth_cipher_test_case_1_oop_sgl),
   19459                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19460                 :            :                         test_zuc_auth_cipher_test_case_2),
   19461                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19462                 :            :                         test_zuc_auth_cipher_test_case_2_oop),
   19463                 :            : 
   19464                 :            :                 /** ZUC decrypt (EEA3), then verify auth */
   19465                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19466                 :            :                         test_zuc_auth_cipher_verify_test_case_1),
   19467                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19468                 :            :                         test_zuc_auth_cipher_verify_test_case_1_oop),
   19469                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19470                 :            :                         test_zuc_auth_cipher_verify_test_case_1_sgl),
   19471                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19472                 :            :                         test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
   19473                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19474                 :            :                         test_zuc_auth_cipher_verify_test_case_2),
   19475                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19476                 :            :                         test_zuc_auth_cipher_verify_test_case_2_oop),
   19477                 :            : 
   19478                 :            :                 /** ZUC-256 encrypt only **/
   19479                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19480                 :            :                         test_zuc256_encryption_test_case_1),
   19481                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19482                 :            :                         test_zuc256_encryption_test_case_2),
   19483                 :            : 
   19484                 :            :                 /** ZUC-256 decrypt only **/
   19485                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19486                 :            :                         test_zuc256_decryption_test_case_1),
   19487                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19488                 :            :                         test_zuc256_decryption_test_case_2),
   19489                 :            : 
   19490                 :            :                 /** ZUC-256 authentication only **/
   19491                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19492                 :            :                         test_zuc256_hash_generate_4b_tag_test_case_1),
   19493                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19494                 :            :                         test_zuc256_hash_generate_4b_tag_test_case_2),
   19495                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19496                 :            :                         test_zuc256_hash_generate_4b_tag_test_case_3),
   19497                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19498                 :            :                         test_zuc256_hash_generate_8b_tag_test_case_1),
   19499                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19500                 :            :                         test_zuc256_hash_generate_16b_tag_test_case_1),
   19501                 :            : 
   19502                 :            :                 /** ZUC-256 authentication verify only **/
   19503                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19504                 :            :                         test_zuc256_hash_verify_4b_tag_test_case_1),
   19505                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19506                 :            :                         test_zuc256_hash_verify_4b_tag_test_case_2),
   19507                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19508                 :            :                         test_zuc256_hash_verify_4b_tag_test_case_3),
   19509                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19510                 :            :                         test_zuc256_hash_verify_8b_tag_test_case_1),
   19511                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19512                 :            :                         test_zuc256_hash_verify_16b_tag_test_case_1),
   19513                 :            : 
   19514                 :            :                 /** ZUC-256 encrypt and authenticate **/
   19515                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19516                 :            :                         test_zuc256_cipher_auth_4b_tag_test_case_1),
   19517                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19518                 :            :                         test_zuc256_cipher_auth_4b_tag_test_case_2),
   19519                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19520                 :            :                         test_zuc256_cipher_auth_8b_tag_test_case_1),
   19521                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19522                 :            :                         test_zuc256_cipher_auth_16b_tag_test_case_1),
   19523                 :            : 
   19524                 :            :                 /** ZUC-256 generate auth, then encrypt */
   19525                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19526                 :            :                         test_zuc256_auth_cipher_4b_tag_test_case_1),
   19527                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19528                 :            :                         test_zuc256_auth_cipher_4b_tag_test_case_2),
   19529                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19530                 :            :                         test_zuc256_auth_cipher_8b_tag_test_case_1),
   19531                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19532                 :            :                         test_zuc256_auth_cipher_16b_tag_test_case_1),
   19533                 :            : 
   19534                 :            :                 /** ZUC-256 decrypt, then verify auth */
   19535                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19536                 :            :                         test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
   19537                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19538                 :            :                         test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
   19539                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19540                 :            :                         test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
   19541                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19542                 :            :                         test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
   19543                 :            : 
   19544                 :            :                 TEST_CASES_END()
   19545                 :            :         }
   19546                 :            : };
   19547                 :            : 
   19548                 :            : static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite  = {
   19549                 :            :         .suite_name = "HMAC_MD5 Authentication Test Suite",
   19550                 :            :         .setup = hmac_md5_auth_testsuite_setup,
   19551                 :            :         .unit_test_cases = {
   19552                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19553                 :            :                         test_MD5_HMAC_generate_case_1),
   19554                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19555                 :            :                         test_MD5_HMAC_verify_case_1),
   19556                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19557                 :            :                         test_MD5_HMAC_generate_case_2),
   19558                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19559                 :            :                         test_MD5_HMAC_verify_case_2),
   19560                 :            :                 TEST_CASES_END()
   19561                 :            :         }
   19562                 :            : };
   19563                 :            : 
   19564                 :            : static struct unit_test_suite cryptodev_kasumi_testsuite  = {
   19565                 :            :         .suite_name = "Kasumi Test Suite",
   19566                 :            :         .setup = kasumi_testsuite_setup,
   19567                 :            :         .unit_test_cases = {
   19568                 :            :                 /** KASUMI hash only (UIA1) */
   19569                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19570                 :            :                         test_kasumi_hash_generate_test_case_1),
   19571                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19572                 :            :                         test_kasumi_hash_generate_test_case_2),
   19573                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19574                 :            :                         test_kasumi_hash_generate_test_case_3),
   19575                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19576                 :            :                         test_kasumi_hash_generate_test_case_4),
   19577                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19578                 :            :                         test_kasumi_hash_generate_test_case_5),
   19579                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19580                 :            :                         test_kasumi_hash_generate_test_case_6),
   19581                 :            : 
   19582                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19583                 :            :                         test_kasumi_hash_verify_test_case_1),
   19584                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19585                 :            :                         test_kasumi_hash_verify_test_case_2),
   19586                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19587                 :            :                         test_kasumi_hash_verify_test_case_3),
   19588                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19589                 :            :                         test_kasumi_hash_verify_test_case_4),
   19590                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19591                 :            :                         test_kasumi_hash_verify_test_case_5),
   19592                 :            : 
   19593                 :            :                 /** KASUMI encrypt only (UEA1) */
   19594                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19595                 :            :                         test_kasumi_encryption_test_case_1),
   19596                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19597                 :            :                         test_kasumi_encryption_test_case_1_sgl),
   19598                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19599                 :            :                         test_kasumi_encryption_test_case_1_oop),
   19600                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19601                 :            :                         test_kasumi_encryption_test_case_1_oop_sgl),
   19602                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19603                 :            :                         test_kasumi_encryption_test_case_2),
   19604                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19605                 :            :                         test_kasumi_encryption_test_case_3),
   19606                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19607                 :            :                         test_kasumi_encryption_test_case_4),
   19608                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19609                 :            :                         test_kasumi_encryption_test_case_5),
   19610                 :            : 
   19611                 :            :                 /** KASUMI decrypt only (UEA1) */
   19612                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19613                 :            :                         test_kasumi_decryption_test_case_1),
   19614                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19615                 :            :                         test_kasumi_decryption_test_case_2),
   19616                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19617                 :            :                         test_kasumi_decryption_test_case_3),
   19618                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19619                 :            :                         test_kasumi_decryption_test_case_4),
   19620                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19621                 :            :                         test_kasumi_decryption_test_case_5),
   19622                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19623                 :            :                         test_kasumi_decryption_test_case_1_oop),
   19624                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19625                 :            :                         test_kasumi_cipher_auth_test_case_1),
   19626                 :            : 
   19627                 :            :                 /** KASUMI generate auth, then encrypt (F8) */
   19628                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19629                 :            :                         test_kasumi_auth_cipher_test_case_1),
   19630                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19631                 :            :                         test_kasumi_auth_cipher_test_case_2),
   19632                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19633                 :            :                         test_kasumi_auth_cipher_test_case_2_oop),
   19634                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19635                 :            :                         test_kasumi_auth_cipher_test_case_2_sgl),
   19636                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19637                 :            :                         test_kasumi_auth_cipher_test_case_2_oop_sgl),
   19638                 :            : 
   19639                 :            :                 /** KASUMI decrypt (F8), then verify auth */
   19640                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19641                 :            :                         test_kasumi_auth_cipher_verify_test_case_1),
   19642                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19643                 :            :                         test_kasumi_auth_cipher_verify_test_case_2),
   19644                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19645                 :            :                         test_kasumi_auth_cipher_verify_test_case_2_oop),
   19646                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19647                 :            :                         test_kasumi_auth_cipher_verify_test_case_2_sgl),
   19648                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19649                 :            :                         test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
   19650                 :            : 
   19651                 :            :                 TEST_CASES_END()
   19652                 :            :         }
   19653                 :            : };
   19654                 :            : 
   19655                 :            : static struct unit_test_suite cryptodev_esn_testsuite  = {
   19656                 :            :         .suite_name = "ESN Test Suite",
   19657                 :            :         .setup = esn_testsuite_setup,
   19658                 :            :         .unit_test_cases = {
   19659                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19660                 :            :                         auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
   19661                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19662                 :            :                         auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
   19663                 :            :                 TEST_CASES_END()
   19664                 :            :         }
   19665                 :            : };
   19666                 :            : 
   19667                 :            : static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite  = {
   19668                 :            :         .suite_name = "Negative AES GCM Test Suite",
   19669                 :            :         .setup = negative_aes_gcm_testsuite_setup,
   19670                 :            :         .unit_test_cases = {
   19671                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19672                 :            :                         test_AES_GCM_auth_encryption_fail_iv_corrupt),
   19673                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19674                 :            :                         test_AES_GCM_auth_encryption_fail_in_data_corrupt),
   19675                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19676                 :            :                         test_AES_GCM_auth_encryption_fail_out_data_corrupt),
   19677                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19678                 :            :                         test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
   19679                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19680                 :            :                         test_AES_GCM_auth_encryption_fail_aad_corrupt),
   19681                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19682                 :            :                         test_AES_GCM_auth_encryption_fail_tag_corrupt),
   19683                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19684                 :            :                         test_AES_GCM_auth_decryption_fail_iv_corrupt),
   19685                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19686                 :            :                         test_AES_GCM_auth_decryption_fail_in_data_corrupt),
   19687                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19688                 :            :                         test_AES_GCM_auth_decryption_fail_out_data_corrupt),
   19689                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19690                 :            :                         test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
   19691                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19692                 :            :                         test_AES_GCM_auth_decryption_fail_aad_corrupt),
   19693                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19694                 :            :                         test_AES_GCM_auth_decryption_fail_tag_corrupt),
   19695                 :            : 
   19696                 :            :                 TEST_CASES_END()
   19697                 :            :         }
   19698                 :            : };
   19699                 :            : 
   19700                 :            : static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite  = {
   19701                 :            :         .suite_name = "Negative AES GMAC Test Suite",
   19702                 :            :         .setup = negative_aes_gmac_testsuite_setup,
   19703                 :            :         .unit_test_cases = {
   19704                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19705                 :            :                         authentication_verify_AES128_GMAC_fail_data_corrupt),
   19706                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19707                 :            :                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
   19708                 :            : 
   19709                 :            :                 TEST_CASES_END()
   19710                 :            :         }
   19711                 :            : };
   19712                 :            : 
   19713                 :            : static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite  = {
   19714                 :            :         .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
   19715                 :            :         .setup = mixed_cipher_hash_testsuite_setup,
   19716                 :            :         .unit_test_cases = {
   19717                 :            :                 /** AUTH AES CMAC + CIPHER AES CTR */
   19718                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19719                 :            :                         test_aes_cmac_aes_ctr_digest_enc_test_case_1),
   19720                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19721                 :            :                         test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
   19722                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19723                 :            :                         test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
   19724                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19725                 :            :                         test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
   19726                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19727                 :            :                         test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
   19728                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19729                 :            :                         test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
   19730                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19731                 :            :                         test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
   19732                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19733                 :            :                         test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
   19734                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19735                 :            :                         test_aes_cmac_aes_ctr_digest_enc_test_case_2),
   19736                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19737                 :            :                         test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
   19738                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19739                 :            :                         test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
   19740                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19741                 :            :                         test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
   19742                 :            : 
   19743                 :            :                 /** AUTH ZUC + CIPHER SNOW3G */
   19744                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19745                 :            :                         test_auth_zuc_cipher_snow_test_case_1),
   19746                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19747                 :            :                         test_verify_auth_zuc_cipher_snow_test_case_1),
   19748                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19749                 :            :                         test_auth_zuc_cipher_snow_test_case_1_inplace),
   19750                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19751                 :            :                         test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
   19752                 :            :                 /** AUTH AES CMAC + CIPHER SNOW3G */
   19753                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19754                 :            :                         test_auth_aes_cmac_cipher_snow_test_case_1),
   19755                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19756                 :            :                         test_verify_auth_aes_cmac_cipher_snow_test_case_1),
   19757                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19758                 :            :                         test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
   19759                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19760                 :            :                         test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
   19761                 :            :                 /** AUTH ZUC + CIPHER AES CTR */
   19762                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19763                 :            :                         test_auth_zuc_cipher_aes_ctr_test_case_1),
   19764                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19765                 :            :                         test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
   19766                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19767                 :            :                         test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
   19768                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19769                 :            :                         test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
   19770                 :            :                 /** AUTH SNOW3G + CIPHER AES CTR */
   19771                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19772                 :            :                         test_auth_snow_cipher_aes_ctr_test_case_1),
   19773                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19774                 :            :                         test_verify_auth_snow_cipher_aes_ctr_test_case_1),
   19775                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19776                 :            :                         test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
   19777                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19778                 :            :                         test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
   19779                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19780                 :            :                         test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
   19781                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19782                 :            :                         test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
   19783                 :            :                 /** AUTH SNOW3G + CIPHER ZUC */
   19784                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19785                 :            :                         test_auth_snow_cipher_zuc_test_case_1),
   19786                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19787                 :            :                         test_verify_auth_snow_cipher_zuc_test_case_1),
   19788                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19789                 :            :                         test_auth_snow_cipher_zuc_test_case_1_inplace),
   19790                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19791                 :            :                         test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
   19792                 :            :                 /** AUTH AES CMAC + CIPHER ZUC */
   19793                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19794                 :            :                         test_auth_aes_cmac_cipher_zuc_test_case_1),
   19795                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19796                 :            :                         test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
   19797                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19798                 :            :                         test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
   19799                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19800                 :            :                         test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
   19801                 :            : 
   19802                 :            :                 /** AUTH NULL + CIPHER SNOW3G */
   19803                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19804                 :            :                         test_auth_null_cipher_snow_test_case_1),
   19805                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19806                 :            :                         test_verify_auth_null_cipher_snow_test_case_1),
   19807                 :            :                 /** AUTH NULL + CIPHER ZUC */
   19808                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19809                 :            :                         test_auth_null_cipher_zuc_test_case_1),
   19810                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19811                 :            :                         test_verify_auth_null_cipher_zuc_test_case_1),
   19812                 :            :                 /** AUTH SNOW3G + CIPHER NULL */
   19813                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19814                 :            :                         test_auth_snow_cipher_null_test_case_1),
   19815                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19816                 :            :                         test_verify_auth_snow_cipher_null_test_case_1),
   19817                 :            :                 /** AUTH ZUC + CIPHER NULL */
   19818                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19819                 :            :                         test_auth_zuc_cipher_null_test_case_1),
   19820                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19821                 :            :                         test_verify_auth_zuc_cipher_null_test_case_1),
   19822                 :            :                 /** AUTH NULL + CIPHER AES CTR */
   19823                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19824                 :            :                         test_auth_null_cipher_aes_ctr_test_case_1),
   19825                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19826                 :            :                         test_verify_auth_null_cipher_aes_ctr_test_case_1),
   19827                 :            :                 /** AUTH AES CMAC + CIPHER NULL */
   19828                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19829                 :            :                         test_auth_aes_cmac_cipher_null_test_case_1),
   19830                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19831                 :            :                         test_verify_auth_aes_cmac_cipher_null_test_case_1),
   19832                 :            :                 TEST_CASES_END()
   19833                 :            :         }
   19834                 :            : };
   19835                 :            : 
   19836                 :            : static struct unit_test_suite cryptodev_sm4_gcm_testsuite  = {
   19837                 :            :         .suite_name = "SM4 GCM Test Suite",
   19838                 :            :         .setup = sm4_gcm_testsuite_setup,
   19839                 :            :         .unit_test_cases = {
   19840                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19841                 :            :                         test_SM4_GCM_case_1),
   19842                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19843                 :            :                         test_SM4_GCM_case_2),
   19844                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19845                 :            :                         test_SM4_GCM_case_3),
   19846                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19847                 :            :                         test_SM4_GCM_case_4),
   19848                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19849                 :            :                         test_SM4_GCM_case_5),
   19850                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19851                 :            :                         test_SM4_GCM_case_6),
   19852                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19853                 :            :                         test_SM4_GCM_case_7),
   19854                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19855                 :            :                         test_SM4_GCM_case_8),
   19856                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19857                 :            :                         test_SM4_GCM_case_9),
   19858                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19859                 :            :                         test_SM4_GCM_case_10),
   19860                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19861                 :            :                         test_SM4_GCM_case_11),
   19862                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19863                 :            :                         test_SM4_GCM_case_12),
   19864                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19865                 :            :                         test_SM4_GCM_case_13),
   19866                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19867                 :            :                         test_SM4_GCM_case_14),
   19868                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19869                 :            :                         test_SM4_GCM_case_15),
   19870                 :            :                 TEST_CASES_END()
   19871                 :            :         }
   19872                 :            : };
   19873                 :            : 
   19874                 :            : static int
   19875                 :          9 : nxan_testsuite_setup(enum rte_crypto_sym_xform_type xform_type)
   19876                 :            : {
   19877                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   19878                 :          9 :         uint8_t dev_id = ts_params->valid_devs[0];
   19879                 :            :         struct rte_cryptodev_info dev_info;
   19880                 :          9 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
   19881                 :            :                 RTE_CRYPTO_CIPHER_SNOW5G_NEA4,
   19882                 :            :                 RTE_CRYPTO_CIPHER_AES_NEA5,
   19883                 :            :                 RTE_CRYPTO_CIPHER_ZUC_NEA6
   19884                 :            :         };
   19885                 :          9 :         const enum rte_crypto_auth_algorithm auths[] = {
   19886                 :            :                 RTE_CRYPTO_AUTH_SNOW5G_NIA4,
   19887                 :            :                 RTE_CRYPTO_AUTH_AES_NIA5,
   19888                 :            :                 RTE_CRYPTO_AUTH_ZUC_NIA6
   19889                 :            :         };
   19890                 :          9 :         const enum rte_crypto_aead_algorithm aeads[] = {
   19891                 :            :                 RTE_CRYPTO_AEAD_SNOW5G_NCA4,
   19892                 :            :                 RTE_CRYPTO_AEAD_AES_NCA5,
   19893                 :            :                 RTE_CRYPTO_AEAD_ZUC_NCA6
   19894                 :            :         };
   19895                 :            : 
   19896                 :          9 :         rte_cryptodev_info_get(dev_id, &dev_info);
   19897                 :            : 
   19898         [ +  - ]:          9 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
   19899         [ -  + ]:          9 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   19900         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   19901                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for NxA4/5/6 "
   19902                 :            :                                 "testsuite not met\n");
   19903                 :          0 :                 return TEST_SKIPPED;
   19904                 :            :         }
   19905                 :            : 
   19906   [ +  +  -  + ]:         12 :         if ((xform_type == RTE_CRYPTO_SYM_XFORM_CIPHER &&
   19907         [ +  + ]:          6 :                 check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) ||
   19908         [ -  + ]:          3 :                 (xform_type == RTE_CRYPTO_SYM_XFORM_AUTH &&
   19909         [ +  - ]:          3 :                 check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) ||
   19910         [ +  - ]:          3 :                 (xform_type == RTE_CRYPTO_SYM_XFORM_AEAD &&
   19911                 :            :                 check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0)) {
   19912                 :          9 :                 RTE_LOG(INFO, USER1, "Capability requirements for NxA4/5/6 "
   19913                 :            :                                 "testsuite not met\n");
   19914                 :          9 :                 return TEST_SKIPPED;
   19915                 :            :         }
   19916                 :            : 
   19917                 :            :         return 0;
   19918                 :            : }
   19919                 :            : 
   19920                 :            : static int
   19921                 :          3 : nea_testsuite_setup(void)
   19922                 :            : {
   19923                 :          3 :         return nxan_testsuite_setup(RTE_CRYPTO_SYM_XFORM_CIPHER);
   19924                 :            : }
   19925                 :            : 
   19926                 :            : static int
   19927                 :          3 : nia_testsuite_setup(void)
   19928                 :            : {
   19929                 :          3 :         return nxan_testsuite_setup(RTE_CRYPTO_SYM_XFORM_AUTH);
   19930                 :            : }
   19931                 :            : 
   19932                 :            : static int
   19933                 :          3 : nca_testsuite_setup(void)
   19934                 :            : {
   19935                 :          3 :         return nxan_testsuite_setup(RTE_CRYPTO_SYM_XFORM_AEAD);
   19936                 :            : }
   19937                 :            : 
   19938                 :            : static int
   19939                 :          0 : test_NEA_helper(
   19940                 :            :         const struct nxa_256_test_data *tdata,
   19941                 :            :         enum rte_crypto_cipher_operation op)
   19942                 :            : {
   19943                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   19944                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   19945                 :            : 
   19946                 :            :         int retval;
   19947                 :            :         uint8_t *input, *output;
   19948                 :            :         uint32_t pad_len;
   19949                 :            :         uint32_t len;
   19950                 :            :         bool is_enc = (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT);
   19951                 :            : 
   19952         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   19953                 :            :                 return TEST_SKIPPED;
   19954                 :            : 
   19955                 :            :         /* Create session */
   19956                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
   19957                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
   19958                 :          0 :                                         tdata->cipher_algo, tdata->key, 32, 16);
   19959         [ #  # ]:          0 :         if (retval != 0)
   19960                 :            :                 return retval;
   19961                 :            : 
   19962         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   19963                 :            : 
   19964                 :            :         /* Clear mbuf payload */
   19965         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   19966                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
   19967                 :            : 
   19968         [ #  # ]:          0 :         len = ceil_byte_length(tdata->msg_size);
   19969                 :            :         /* Append data which is padded to a multiple */
   19970                 :            :         /* of the algorithms block size */
   19971                 :          0 :         pad_len = RTE_ALIGN_CEIL(len, 8);
   19972                 :          0 :         input = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   19973                 :            :                                 pad_len);
   19974         [ #  # ]:          0 :         memcpy(input, is_enc ? tdata->plaintext : tdata->ciphertext, len);
   19975                 :          0 :         debug_hexdump(stdout, "input:", input, len);
   19976                 :            : 
   19977                 :            :         /* Create operation */
   19978                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->iv,
   19979                 :          0 :                                 16, RTE_ALIGN_CEIL(tdata->msg_size, 8), 0);
   19980         [ #  # ]:          0 :         if (retval != 0)
   19981                 :            :                 return retval;
   19982                 :            : 
   19983         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   19984                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
   19985                 :            :                                                16);
   19986         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   19987                 :            :                         return retval;
   19988                 :            :         } else
   19989                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
   19990                 :            :                                 ut_params->op);
   19991         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
   19992                 :            : 
   19993                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
   19994         [ #  # ]:          0 :         if (ut_params->obuf)
   19995                 :          0 :                 output = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
   19996                 :            :         else
   19997                 :            :                 output = input;
   19998                 :            : 
   19999                 :          0 :         debug_hexdump(stdout, "output:", output, len);
   20000                 :            :         const uint8_t *reference_output =
   20001         [ #  # ]:          0 :                 is_enc ? tdata->ciphertext : tdata->plaintext;
   20002                 :            :         /* Validate obuf */
   20003   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
   20004                 :            :                 output,
   20005                 :            :                 reference_output,
   20006                 :            :                 tdata->msg_size,
   20007                 :            :                 "Output data not as expected");
   20008                 :            :         return 0;
   20009                 :            : }
   20010                 :            : 
   20011                 :            : static int
   20012                 :          0 : test_NIA_helper(const void *td)
   20013                 :            : {
   20014                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   20015                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   20016                 :            :         const struct nxa_256_test_data *tdata = td;
   20017                 :            : 
   20018                 :            :         int retval;
   20019                 :            :         uint32_t plaintext_pad_len;
   20020                 :            :         uint32_t plaintext_len;
   20021                 :            :         uint8_t *plaintext;
   20022                 :            : 
   20023         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   20024                 :            :                 return TEST_SKIPPED;
   20025                 :            : 
   20026                 :            :         /* Create auth session */
   20027                 :          0 :         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
   20028                 :          0 :                                 tdata->key, 32,
   20029                 :          0 :                                 16, tdata->tag_size >> 3,
   20030                 :            :                                 RTE_CRYPTO_AUTH_OP_VERIFY,
   20031                 :          0 :                                 tdata->auth_algo);
   20032         [ #  # ]:          0 :         if (retval != 0)
   20033                 :            :                 return retval;
   20034                 :            :         /* alloc mbuf and set payload */
   20035         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   20036                 :            : 
   20037         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   20038                 :            :         rte_pktmbuf_tailroom(ut_params->ibuf));
   20039                 :            : 
   20040         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->msg_size);
   20041                 :            :         /* Append data which is padded to a multiple */
   20042                 :            :         /* of the algorithms block size */
   20043                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
   20044                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   20045                 :            :                                 plaintext_pad_len);
   20046                 :          0 :         memcpy(plaintext, tdata->plaintext, plaintext_len);
   20047                 :            : 
   20048                 :            :         /* Create auth operation */
   20049                 :          0 :         retval = create_wireless_algo_hash_operation(tdata->tag,
   20050                 :          0 :                         tdata->tag_size >> 3,
   20051                 :          0 :                         tdata->iv, 16,
   20052                 :            :                         plaintext_pad_len,
   20053                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY,
   20054                 :          0 :                         tdata->msg_size,
   20055                 :            :                         0);
   20056         [ #  # ]:          0 :         if (retval != 0)
   20057                 :            :                 return retval;
   20058                 :            : 
   20059         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   20060                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
   20061                 :            :                                                0);
   20062         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   20063                 :            :                         return retval;
   20064                 :            :         } else
   20065                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
   20066                 :            :                                 ut_params->op);
   20067         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "Crypto request failed");
   20068                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
   20069                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
   20070                 :            :                                                     uint8_t *,
   20071                 :            :                                                     plaintext_pad_len);
   20072                 :            : 
   20073                 :            :         /* Validate obuf */
   20074         [ #  # ]:          0 :         if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
   20075                 :            :                 return 0;
   20076                 :            :         else
   20077                 :          0 :                 return -1;
   20078                 :            : 
   20079                 :            :         return 0;
   20080                 :            : }
   20081                 :            : 
   20082                 :            : static int
   20083                 :          0 : test_NCA_helper(
   20084                 :            :         const struct nxa_256_test_data *tdata,
   20085                 :            :         enum rte_crypto_cipher_operation op)
   20086                 :            : {
   20087                 :          0 :         struct aead_test_data aead_tdata = {
   20088                 :          0 :                 .algo = tdata->aead_algo,
   20089                 :            :                 .key = {
   20090                 :            :                         .len = 32,
   20091                 :            :                 },
   20092                 :            :                 .iv = {
   20093                 :            :                         .len = 16,
   20094                 :            :                 },
   20095                 :            :                 .aad = {
   20096                 :          0 :                         .data = (uint8_t *)(uintptr_t)tdata->aad,
   20097                 :          0 :                         .len = tdata->aad_size >> 3,
   20098                 :            :                 },
   20099                 :            :                 .plaintext = {
   20100                 :          0 :                         .len = tdata->msg_size >> 3,
   20101                 :            :                 },
   20102                 :            :                 .ciphertext = {
   20103                 :            :                         .len = tdata->msg_size >> 3,
   20104                 :            :                 },
   20105                 :            :                 .auth_tag = {
   20106                 :          0 :                         .len = tdata->tag_size >> 3,
   20107                 :            :                 },
   20108                 :            :         };
   20109                 :            : 
   20110         [ #  # ]:          0 :         memcpy(aead_tdata.key.data, tdata->key, 32);
   20111                 :            :         memcpy(aead_tdata.iv.data, tdata->iv, 16);
   20112                 :          0 :         memcpy(aead_tdata.plaintext.data, tdata->plaintext,
   20113                 :            :                 tdata->msg_size >> 3);
   20114                 :          0 :         memcpy(aead_tdata.ciphertext.data, tdata->ciphertext,
   20115                 :            :                 tdata->msg_size >> 3);
   20116                 :          0 :         memcpy(aead_tdata.auth_tag.data, tdata->tag,
   20117                 :            :                 tdata->tag_size >> 3);
   20118                 :            : 
   20119         [ #  # ]:          0 :         if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
   20120                 :          0 :                 return test_authenticated_encryption_helper(&aead_tdata, false);
   20121                 :            :         else
   20122                 :          0 :                 return test_authenticated_decryption_helper(&aead_tdata, false);
   20123                 :            : }
   20124                 :            : 
   20125                 :            : 
   20126                 :          0 : static int test_case_NEA_encrypt(const void *tdata)
   20127                 :            : {
   20128                 :          0 :         return test_NEA_helper(tdata, RTE_CRYPTO_CIPHER_OP_ENCRYPT);
   20129                 :            : }
   20130                 :            : 
   20131                 :          0 : static int test_case_NEA_decrypt(const void *tdata)
   20132                 :            : {
   20133                 :          0 :         return test_NEA_helper(tdata, RTE_CRYPTO_CIPHER_OP_DECRYPT);
   20134                 :            : }
   20135                 :            : 
   20136                 :            : static struct unit_test_suite cryptodev_256_NEA4_testsuite  = {
   20137                 :            :         .suite_name = "256 NEA4 (SNOW 5G) Test Suite",
   20138                 :            :         .setup = nea_testsuite_setup,
   20139                 :            :         .unit_test_cases = {
   20140                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20141                 :            :                         test_case_NEA_encrypt, &nea4_test_1),
   20142                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20143                 :            :                         test_case_NEA_decrypt, &nea4_test_1),
   20144                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20145                 :            :                         test_case_NEA_encrypt, &nea4_test_2),
   20146                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20147                 :            :                         test_case_NEA_decrypt, &nea4_test_2),
   20148                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20149                 :            :                         test_case_NEA_encrypt, &nea4_test_3),
   20150                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20151                 :            :                         test_case_NEA_decrypt, &nea4_test_3),
   20152                 :            : 
   20153                 :            :                 TEST_CASES_END()
   20154                 :            :         }
   20155                 :            : };
   20156                 :            : 
   20157                 :            : static struct unit_test_suite cryptodev_256_NEA5_testsuite  = {
   20158                 :            :         .suite_name = "256 NEA5 (AES 256) Test Suite",
   20159                 :            :         .setup = nea_testsuite_setup,
   20160                 :            :         .unit_test_cases = {
   20161                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20162                 :            :                         test_case_NEA_encrypt, &nea5_test_1),
   20163                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20164                 :            :                         test_case_NEA_decrypt, &nea5_test_1),
   20165                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20166                 :            :                         test_case_NEA_encrypt, &nea5_test_2),
   20167                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20168                 :            :                         test_case_NEA_decrypt, &nea5_test_2),
   20169                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20170                 :            :                         test_case_NEA_encrypt, &nea5_test_3),
   20171                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20172                 :            :                         test_case_NEA_decrypt, &nea5_test_3),
   20173                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20174                 :            :                         test_case_NEA_encrypt, &nea5_test_4),
   20175                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20176                 :            :                         test_case_NEA_decrypt, &nea5_test_4),
   20177                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20178                 :            :                         test_case_NEA_encrypt, &nea5_test_5),
   20179                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20180                 :            :                         test_case_NEA_decrypt, &nea5_test_5),
   20181                 :            : 
   20182                 :            :                 TEST_CASES_END()
   20183                 :            :         }
   20184                 :            : };
   20185                 :            : 
   20186                 :            : static struct unit_test_suite cryptodev_256_NEA6_testsuite  = {
   20187                 :            :         .suite_name = "256 NEA6 (ZUC 256) Test Suite",
   20188                 :            :         .setup = nea_testsuite_setup,
   20189                 :            :         .unit_test_cases = {
   20190                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20191                 :            :                         test_case_NEA_encrypt, &nea6_test_1),
   20192                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20193                 :            :                         test_case_NEA_decrypt, &nea6_test_1),
   20194                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20195                 :            :                         test_case_NEA_encrypt, &nea6_test_2),
   20196                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20197                 :            :                         test_case_NEA_decrypt, &nea6_test_2),
   20198                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20199                 :            :                         test_case_NEA_encrypt, &nea6_test_3),
   20200                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20201                 :            :                         test_case_NEA_decrypt, &nea6_test_3),
   20202                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20203                 :            :                         test_case_NEA_encrypt, &nea6_test_4),
   20204                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20205                 :            :                         test_case_NEA_decrypt, &nea6_test_4),
   20206                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20207                 :            :                         test_case_NEA_encrypt, &nea6_test_5),
   20208                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20209                 :            :                         test_case_NEA_decrypt, &nea6_test_5),
   20210                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20211                 :            :                         test_case_NEA_encrypt, &nea6_test_6),
   20212                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20213                 :            :                         test_case_NEA_decrypt, &nea6_test_6),
   20214                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20215                 :            :                         test_case_NEA_encrypt, &nea6_test_7),
   20216                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20217                 :            :                         test_case_NEA_decrypt, &nea6_test_7),
   20218                 :            : 
   20219                 :            :                 TEST_CASES_END()
   20220                 :            :         }
   20221                 :            : };
   20222                 :            : 
   20223                 :            : 
   20224                 :            : static struct unit_test_suite cryptodev_256_NIA4_testsuite  = {
   20225                 :            :         .suite_name = "256 NIA4 (SNOW 5G) Test Suite",
   20226                 :            :         .setup = nia_testsuite_setup,
   20227                 :            :         .unit_test_cases = {
   20228                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20229                 :            :                         test_NIA_helper, &nia4_test_1),
   20230                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20231                 :            :                         test_NIA_helper, &nia4_test_2),
   20232                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20233                 :            :                         test_NIA_helper, &nia4_test_3),
   20234                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20235                 :            :                         test_NIA_helper, &nia4_test_4),
   20236                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20237                 :            :                         test_NIA_helper, &nia4_test_5),
   20238                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20239                 :            :                         test_NIA_helper, &nia4_test_6),
   20240                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20241                 :            :                         test_NIA_helper, &nia4_test_7),
   20242                 :            : 
   20243                 :            :                 TEST_CASES_END()
   20244                 :            :         }
   20245                 :            : };
   20246                 :            : 
   20247                 :            : static struct unit_test_suite cryptodev_256_NIA5_testsuite  = {
   20248                 :            :         .suite_name = "256 NIA5 (AES 256) Test Suite",
   20249                 :            :         .setup = nia_testsuite_setup,
   20250                 :            :         .unit_test_cases = {
   20251                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20252                 :            :                         test_NIA_helper, &nia5_test_1),
   20253                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20254                 :            :                         test_NIA_helper, &nia5_test_2),
   20255                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20256                 :            :                         test_NIA_helper, &nia5_test_3),
   20257                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20258                 :            :                         test_NIA_helper, &nia5_test_4),
   20259                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20260                 :            :                         test_NIA_helper, &nia5_test_5),
   20261                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20262                 :            :                         test_NIA_helper, &nia5_test_6),
   20263                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20264                 :            :                         test_NIA_helper, &nia5_test_7),
   20265                 :            : 
   20266                 :            :                 TEST_CASES_END()
   20267                 :            :         }
   20268                 :            : };
   20269                 :            : 
   20270                 :            : static struct unit_test_suite cryptodev_256_NIA6_testsuite  = {
   20271                 :            :         .suite_name = "256 NIA6 (ZUC 256) Test Suite",
   20272                 :            :         .setup = nia_testsuite_setup,
   20273                 :            :         .unit_test_cases = {
   20274                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20275                 :            :                         test_NIA_helper, &nia6_test_1),
   20276                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20277                 :            :                         test_NIA_helper, &nia6_test_2),
   20278                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20279                 :            :                         test_NIA_helper, &nia6_test_3),
   20280                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20281                 :            :                         test_NIA_helper, &nia6_test_4),
   20282                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20283                 :            :                         test_NIA_helper, &nia6_test_5),
   20284                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20285                 :            :                         test_NIA_helper, &nia6_test_6),
   20286                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20287                 :            :                         test_NIA_helper, &nia6_test_7),
   20288                 :            : 
   20289                 :            :                 TEST_CASES_END()
   20290                 :            :         }
   20291                 :            : };
   20292                 :            : 
   20293                 :            : 
   20294                 :          0 : static int test_case_NCA_encrypt(const void *tdata)
   20295                 :            : {
   20296                 :          0 :         return test_NCA_helper(tdata, RTE_CRYPTO_CIPHER_OP_ENCRYPT);
   20297                 :            : }
   20298                 :            : 
   20299                 :          0 : static int test_case_NCA_decrypt(const void *tdata)
   20300                 :            : {
   20301                 :          0 :         return test_NCA_helper(tdata, RTE_CRYPTO_CIPHER_OP_DECRYPT);
   20302                 :            : }
   20303                 :            : 
   20304                 :            : static struct unit_test_suite cryptodev_256_NCA4_testsuite  = {
   20305                 :            :         .suite_name = "256 NCA4 (SNOW 5G) Test Suite",
   20306                 :            :         .setup = nca_testsuite_setup,
   20307                 :            :         .unit_test_cases = {
   20308                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20309                 :            :                         test_case_NCA_encrypt, &nca4_test_1),
   20310                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20311                 :            :                         test_case_NCA_decrypt, &nca4_test_1),
   20312                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20313                 :            :                         test_case_NCA_encrypt, &nca4_test_2),
   20314                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20315                 :            :                         test_case_NCA_decrypt, &nca4_test_2),
   20316                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20317                 :            :                         test_case_NCA_encrypt, &nca4_test_3),
   20318                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20319                 :            :                         test_case_NCA_decrypt, &nca4_test_3),
   20320                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20321                 :            :                         test_case_NCA_encrypt, &nca4_test_4),
   20322                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20323                 :            :                         test_case_NCA_decrypt, &nca4_test_4),
   20324                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20325                 :            :                         test_case_NCA_encrypt, &nca4_test_5),
   20326                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20327                 :            :                         test_case_NCA_decrypt, &nca4_test_5),
   20328                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20329                 :            :                         test_case_NCA_encrypt, &nca4_test_6),
   20330                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20331                 :            :                         test_case_NCA_decrypt, &nca4_test_6),
   20332                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20333                 :            :                         test_case_NCA_encrypt, &nca4_test_7),
   20334                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20335                 :            :                         test_case_NCA_decrypt, &nca4_test_7),
   20336                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20337                 :            :                         test_case_NCA_encrypt, &nca4_test_8),
   20338                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20339                 :            :                         test_case_NCA_decrypt, &nca4_test_8),
   20340                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20341                 :            :                         test_case_NCA_encrypt, &nca4_test_9),
   20342                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20343                 :            :                         test_case_NCA_decrypt, &nca4_test_9),
   20344                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20345                 :            :                         test_case_NCA_encrypt, &nca4_test_10),
   20346                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20347                 :            :                         test_case_NCA_decrypt, &nca4_test_10),
   20348                 :            : 
   20349                 :            :                 TEST_CASES_END()
   20350                 :            :         }
   20351                 :            : };
   20352                 :            : 
   20353                 :            : static struct unit_test_suite cryptodev_256_NCA5_testsuite  = {
   20354                 :            :         .suite_name = "256 NCA5 (AES 256) Test Suite",
   20355                 :            :         .setup = nca_testsuite_setup,
   20356                 :            :         .unit_test_cases = {
   20357                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20358                 :            :                         test_case_NCA_encrypt, &nca5_test_1),
   20359                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20360                 :            :                         test_case_NCA_decrypt, &nca5_test_1),
   20361                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20362                 :            :                         test_case_NCA_encrypt, &nca5_test_2),
   20363                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20364                 :            :                         test_case_NCA_decrypt, &nca5_test_2),
   20365                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20366                 :            :                         test_case_NCA_encrypt, &nca5_test_3),
   20367                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20368                 :            :                         test_case_NCA_decrypt, &nca5_test_3),
   20369                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20370                 :            :                         test_case_NCA_encrypt, &nca5_test_4),
   20371                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20372                 :            :                         test_case_NCA_decrypt, &nca5_test_4),
   20373                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20374                 :            :                         test_case_NCA_encrypt, &nca5_test_5),
   20375                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20376                 :            :                         test_case_NCA_decrypt, &nca5_test_5),
   20377                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20378                 :            :                         test_case_NCA_encrypt, &nca5_test_6),
   20379                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20380                 :            :                         test_case_NCA_decrypt, &nca5_test_6),
   20381                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20382                 :            :                         test_case_NCA_encrypt, &nca5_test_7),
   20383                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20384                 :            :                         test_case_NCA_decrypt, &nca5_test_7),
   20385                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20386                 :            :                         test_case_NCA_encrypt, &nca5_test_8),
   20387                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20388                 :            :                         test_case_NCA_decrypt, &nca5_test_8),
   20389                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20390                 :            :                         test_case_NCA_encrypt, &nca5_test_9),
   20391                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20392                 :            :                         test_case_NCA_decrypt, &nca5_test_9),
   20393                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20394                 :            :                         test_case_NCA_encrypt, &nca5_test_10),
   20395                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20396                 :            :                         test_case_NCA_decrypt, &nca5_test_10),
   20397                 :            : 
   20398                 :            :                 TEST_CASES_END()
   20399                 :            :         }
   20400                 :            : };
   20401                 :            : 
   20402                 :            : static struct unit_test_suite cryptodev_256_NCA6_testsuite  = {
   20403                 :            :         .suite_name = "256 NCA6 (ZUC 256) Test Suite",
   20404                 :            :         .setup = nca_testsuite_setup,
   20405                 :            :         .unit_test_cases = {
   20406                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20407                 :            :                         test_case_NCA_encrypt, &nca6_test_1),
   20408                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20409                 :            :                         test_case_NCA_decrypt, &nca6_test_1),
   20410                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20411                 :            :                         test_case_NCA_encrypt, &nca6_test_2),
   20412                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20413                 :            :                         test_case_NCA_decrypt, &nca6_test_2),
   20414                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20415                 :            :                         test_case_NCA_encrypt, &nca6_test_3),
   20416                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20417                 :            :                         test_case_NCA_decrypt, &nca6_test_3),
   20418                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20419                 :            :                         test_case_NCA_encrypt, &nca6_test_4),
   20420                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20421                 :            :                         test_case_NCA_decrypt, &nca6_test_4),
   20422                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20423                 :            :                         test_case_NCA_encrypt, &nca6_test_5),
   20424                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20425                 :            :                         test_case_NCA_decrypt, &nca6_test_5),
   20426                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20427                 :            :                         test_case_NCA_encrypt, &nca6_test_6),
   20428                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20429                 :            :                         test_case_NCA_decrypt, &nca6_test_6),
   20430                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20431                 :            :                         test_case_NCA_encrypt, &nca6_test_7),
   20432                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20433                 :            :                         test_case_NCA_decrypt, &nca6_test_7),
   20434                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20435                 :            :                         test_case_NCA_encrypt, &nca6_test_8),
   20436                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20437                 :            :                         test_case_NCA_decrypt, &nca6_test_8),
   20438                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20439                 :            :                         test_case_NCA_encrypt, &nca6_test_9),
   20440                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20441                 :            :                         test_case_NCA_decrypt, &nca6_test_9),
   20442                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20443                 :            :                         test_case_NCA_encrypt, &nca6_test_10),
   20444                 :            :                 TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
   20445                 :            :                         test_case_NCA_decrypt, &nca6_test_10),
   20446                 :            : 
   20447                 :            :                 TEST_CASES_END()
   20448                 :            :         }
   20449                 :            : };
   20450                 :            : 
   20451                 :            : static int
   20452                 :          1 : run_cryptodev_testsuite(const char *pmd_name)
   20453                 :            : {
   20454                 :            :         uint8_t ret, j, i = 0, blk_start_idx = 0;
   20455                 :          1 :         const enum blockcipher_test_type blk_suites[] = {
   20456                 :            :                 BLKCIPHER_AES_CHAIN_TYPE,
   20457                 :            :                 BLKCIPHER_AES_CIPHERONLY_TYPE,
   20458                 :            :                 BLKCIPHER_AES_DOCSIS_TYPE,
   20459                 :            :                 BLKCIPHER_3DES_CHAIN_TYPE,
   20460                 :            :                 BLKCIPHER_3DES_CIPHERONLY_TYPE,
   20461                 :            :                 BLKCIPHER_DES_CIPHERONLY_TYPE,
   20462                 :            :                 BLKCIPHER_DES_DOCSIS_TYPE,
   20463                 :            :                 BLKCIPHER_SM4_CHAIN_TYPE,
   20464                 :            :                 BLKCIPHER_SM4_CIPHERONLY_TYPE,
   20465                 :            :                 BLKCIPHER_AUTHONLY_TYPE};
   20466                 :          1 :         struct unit_test_suite *static_suites[] = {
   20467                 :            :                 &cryptodev_multi_session_testsuite,
   20468                 :            :                 &cryptodev_null_testsuite,
   20469                 :            :                 &cryptodev_aes_ccm_auth_testsuite,
   20470                 :            :                 &cryptodev_aes_gcm_auth_testsuite,
   20471                 :            :                 &cryptodev_aes_gmac_auth_testsuite,
   20472                 :            :                 &cryptodev_snow3g_testsuite,
   20473                 :            :                 &cryptodev_chacha20_poly1305_testsuite,
   20474                 :            :                 &cryptodev_zuc_testsuite,
   20475                 :            :                 &cryptodev_hmac_md5_auth_testsuite,
   20476                 :            :                 &cryptodev_kasumi_testsuite,
   20477                 :            :                 &cryptodev_esn_testsuite,
   20478                 :            :                 &cryptodev_negative_aes_gcm_testsuite,
   20479                 :            :                 &cryptodev_negative_aes_gmac_testsuite,
   20480                 :            :                 &cryptodev_mixed_cipher_hash_testsuite,
   20481                 :            :                 &cryptodev_negative_hmac_sha1_testsuite,
   20482                 :            :                 &cryptodev_gen_testsuite,
   20483                 :            :                 &cryptodev_sm4_gcm_testsuite,
   20484                 :            :                 &cryptodev_256_NEA4_testsuite,
   20485                 :            :                 &cryptodev_256_NEA5_testsuite,
   20486                 :            :                 &cryptodev_256_NEA6_testsuite,
   20487                 :            :                 &cryptodev_256_NIA4_testsuite,
   20488                 :            :                 &cryptodev_256_NIA5_testsuite,
   20489                 :            :                 &cryptodev_256_NIA6_testsuite,
   20490                 :            :                 &cryptodev_256_NCA4_testsuite,
   20491                 :            :                 &cryptodev_256_NCA5_testsuite,
   20492                 :            :                 &cryptodev_256_NCA6_testsuite,
   20493                 :            : #ifdef RTE_LIB_SECURITY
   20494                 :            :                 &ipsec_proto_testsuite,
   20495                 :            :                 &pdcp_proto_testsuite,
   20496                 :            :                 &docsis_proto_testsuite,
   20497                 :            :                 &tls12_record_proto_testsuite,
   20498                 :            :                 &dtls12_record_proto_testsuite,
   20499                 :            :                 &tls13_record_proto_testsuite,
   20500                 :            : #endif
   20501                 :            :                 &end_testsuite
   20502                 :            :         };
   20503                 :            :         static struct unit_test_suite ts = {
   20504                 :            :                 .suite_name = "Cryptodev Unit Test Suite",
   20505                 :            :                 .setup = testsuite_setup,
   20506                 :            :                 .teardown = testsuite_teardown,
   20507                 :            :                 .unit_test_cases = {TEST_CASES_END()}
   20508                 :            :         };
   20509                 :            : 
   20510                 :          1 :         gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
   20511                 :            : 
   20512         [ -  + ]:          1 :         if (gbl_driver_id == -1) {
   20513                 :          0 :                 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
   20514                 :          0 :                 return TEST_SKIPPED;
   20515                 :            :         }
   20516                 :            : 
   20517                 :          1 :         ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
   20518                 :            :                         (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
   20519                 :            : 
   20520         [ +  + ]:         11 :         ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
   20521         [ +  + ]:         34 :         ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
   20522                 :          1 :         ret = unit_test_suite_runner(&ts);
   20523                 :            : 
   20524         [ +  + ]:         11 :         FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
   20525                 :          1 :         free(ts.unit_test_suites);
   20526                 :          1 :         return ret;
   20527                 :            : }
   20528                 :            : 
   20529                 :            : static int
   20530                 :          0 : require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
   20531                 :            : {
   20532                 :            :         struct rte_cryptodev_info dev_info;
   20533                 :            :         uint8_t i, nb_devs;
   20534                 :            :         int driver_id;
   20535                 :            : 
   20536                 :          0 :         driver_id = rte_cryptodev_driver_id_get(pmd_name);
   20537         [ #  # ]:          0 :         if (driver_id == -1) {
   20538                 :          0 :                 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
   20539                 :          0 :                 return TEST_SKIPPED;
   20540                 :            :         }
   20541                 :            : 
   20542                 :          0 :         nb_devs = rte_cryptodev_count();
   20543         [ #  # ]:          0 :         if (nb_devs < 1) {
   20544                 :          0 :                 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
   20545                 :          0 :                 return TEST_SKIPPED;
   20546                 :            :         }
   20547                 :            : 
   20548         [ #  # ]:          0 :         for (i = 0; i < nb_devs; i++) {
   20549                 :          0 :                 rte_cryptodev_info_get(i, &dev_info);
   20550         [ #  # ]:          0 :                 if (dev_info.driver_id == driver_id) {
   20551         [ #  # ]:          0 :                         if (!(dev_info.feature_flags & flag)) {
   20552                 :          0 :                                 RTE_LOG(INFO, USER1, "%s not supported\n",
   20553                 :            :                                                 flag_name);
   20554                 :          0 :                                 return TEST_SKIPPED;
   20555                 :            :                         }
   20556                 :            :                         return 0; /* found */
   20557                 :            :                 }
   20558                 :            :         }
   20559                 :            : 
   20560                 :          0 :         RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
   20561                 :          0 :         return TEST_SKIPPED;
   20562                 :            : }
   20563                 :            : 
   20564                 :            : static int
   20565                 :          0 : test_cryptodev_qat(void)
   20566                 :            : {
   20567                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
   20568                 :            : }
   20569                 :            : 
   20570                 :            : static int
   20571                 :          0 : test_cryptodev_uadk(void)
   20572                 :            : {
   20573                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
   20574                 :            : }
   20575                 :            : 
   20576                 :            : static int
   20577                 :          0 : test_cryptodev_virtio(void)
   20578                 :            : {
   20579                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
   20580                 :            : }
   20581                 :            : 
   20582                 :            : static int
   20583                 :          0 : test_cryptodev_virtio_user(void)
   20584                 :            : {
   20585                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_USER_PMD));
   20586                 :            : }
   20587                 :            : 
   20588                 :            : static int
   20589                 :          0 : test_cryptodev_aesni_mb(void)
   20590                 :            : {
   20591                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
   20592                 :            : }
   20593                 :            : 
   20594                 :            : static int
   20595                 :          0 : test_cryptodev_cpu_aesni_mb(void)
   20596                 :            : {
   20597                 :            :         int32_t rc;
   20598                 :          0 :         enum rte_security_session_action_type at = gbl_action_type;
   20599                 :          0 :         gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
   20600                 :          0 :         rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
   20601                 :          0 :         gbl_action_type = at;
   20602                 :          0 :         return rc;
   20603                 :            : }
   20604                 :            : 
   20605                 :            : static int
   20606                 :          0 : test_cryptodev_chacha_poly_mb(void)
   20607                 :            : {
   20608                 :            :         int32_t rc;
   20609                 :          0 :         enum rte_security_session_action_type at = gbl_action_type;
   20610                 :          0 :         rc = run_cryptodev_testsuite(
   20611                 :            :                         RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
   20612                 :          0 :         gbl_action_type = at;
   20613                 :          0 :         return rc;
   20614                 :            : }
   20615                 :            : 
   20616                 :            : static int
   20617                 :          1 : test_cryptodev_openssl(void)
   20618                 :            : {
   20619                 :          1 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
   20620                 :            : }
   20621                 :            : 
   20622                 :            : static int
   20623                 :          0 : test_cryptodev_aesni_gcm(void)
   20624                 :            : {
   20625                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
   20626                 :            : }
   20627                 :            : 
   20628                 :            : static int
   20629                 :          0 : test_cryptodev_cpu_aesni_gcm(void)
   20630                 :            : {
   20631                 :            :         int32_t rc;
   20632                 :          0 :         enum rte_security_session_action_type at = gbl_action_type;
   20633                 :          0 :         gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
   20634                 :          0 :         rc  = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
   20635                 :          0 :         gbl_action_type = at;
   20636                 :          0 :         return rc;
   20637                 :            : }
   20638                 :            : 
   20639                 :            : static int
   20640                 :          0 : test_cryptodev_mlx5(void)
   20641                 :            : {
   20642                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
   20643                 :            : }
   20644                 :            : 
   20645                 :            : static int
   20646                 :          0 : test_cryptodev_null(void)
   20647                 :            : {
   20648                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
   20649                 :            : }
   20650                 :            : 
   20651                 :            : static int
   20652                 :          0 : test_cryptodev_sw_snow3g(void)
   20653                 :            : {
   20654                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
   20655                 :            : }
   20656                 :            : 
   20657                 :            : static int
   20658                 :          0 : test_cryptodev_sw_kasumi(void)
   20659                 :            : {
   20660                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
   20661                 :            : }
   20662                 :            : 
   20663                 :            : static int
   20664                 :          0 : test_cryptodev_sw_zuc(void)
   20665                 :            : {
   20666                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
   20667                 :            : }
   20668                 :            : 
   20669                 :            : static int
   20670                 :          0 : test_cryptodev_armv8(void)
   20671                 :            : {
   20672                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
   20673                 :            : }
   20674                 :            : 
   20675                 :            : static int
   20676                 :          0 : test_cryptodev_mrvl(void)
   20677                 :            : {
   20678                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
   20679                 :            : }
   20680                 :            : 
   20681                 :            : #ifdef RTE_CRYPTO_SCHEDULER
   20682                 :            : 
   20683                 :            : static int
   20684                 :          0 : test_cryptodev_scheduler(void)
   20685                 :            : {
   20686                 :            :         uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
   20687                 :          0 :         const enum blockcipher_test_type blk_suites[] = {
   20688                 :            :                 BLKCIPHER_AES_CHAIN_TYPE,
   20689                 :            :                 BLKCIPHER_AES_CIPHERONLY_TYPE,
   20690                 :            :                 BLKCIPHER_AUTHONLY_TYPE
   20691                 :            :         };
   20692                 :            :         static struct unit_test_suite scheduler_multicore = {
   20693                 :            :                 .suite_name = "Scheduler Multicore Unit Test Suite",
   20694                 :            :                 .setup = scheduler_multicore_testsuite_setup,
   20695                 :            :                 .teardown = scheduler_mode_testsuite_teardown,
   20696                 :            :                 .unit_test_cases = {TEST_CASES_END()}
   20697                 :            :         };
   20698                 :            :         static struct unit_test_suite scheduler_round_robin = {
   20699                 :            :                 .suite_name = "Scheduler Round Robin Unit Test Suite",
   20700                 :            :                 .setup = scheduler_roundrobin_testsuite_setup,
   20701                 :            :                 .teardown = scheduler_mode_testsuite_teardown,
   20702                 :            :                 .unit_test_cases = {TEST_CASES_END()}
   20703                 :            :         };
   20704                 :            :         static struct unit_test_suite scheduler_failover = {
   20705                 :            :                 .suite_name = "Scheduler Failover Unit Test Suite",
   20706                 :            :                 .setup = scheduler_failover_testsuite_setup,
   20707                 :            :                 .teardown = scheduler_mode_testsuite_teardown,
   20708                 :            :                 .unit_test_cases = {TEST_CASES_END()}
   20709                 :            :         };
   20710                 :            :         static struct unit_test_suite scheduler_pkt_size_distr = {
   20711                 :            :                 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
   20712                 :            :                 .setup = scheduler_pkt_size_distr_testsuite_setup,
   20713                 :            :                 .teardown = scheduler_mode_testsuite_teardown,
   20714                 :            :                 .unit_test_cases = {TEST_CASES_END()}
   20715                 :            :         };
   20716                 :          0 :         struct unit_test_suite *sched_mode_suites[] = {
   20717                 :            :                 &scheduler_multicore,
   20718                 :            :                 &scheduler_round_robin,
   20719                 :            :                 &scheduler_failover,
   20720                 :            :                 &scheduler_pkt_size_distr
   20721                 :            :         };
   20722                 :            :         static struct unit_test_suite scheduler_config = {
   20723                 :            :                 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
   20724                 :            :                 .unit_test_cases = {
   20725                 :            :                         TEST_CASE(test_scheduler_attach_worker_op),
   20726                 :            :                         TEST_CASE(test_scheduler_mode_multicore_op),
   20727                 :            :                         TEST_CASE(test_scheduler_mode_roundrobin_op),
   20728                 :            :                         TEST_CASE(test_scheduler_mode_failover_op),
   20729                 :            :                         TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
   20730                 :            :                         TEST_CASE(test_scheduler_detach_worker_op),
   20731                 :            : 
   20732                 :            :                         TEST_CASES_END() /**< NULL terminate array */
   20733                 :            :                 }
   20734                 :            :         };
   20735                 :          0 :         struct unit_test_suite *static_suites[] = {
   20736                 :            :                 &scheduler_config,
   20737                 :            :                 &end_testsuite
   20738                 :            :         };
   20739                 :          0 :         struct unit_test_suite *sched_mode_static_suites[] = {
   20740                 :            : #ifdef RTE_LIB_SECURITY
   20741                 :            :                 &docsis_proto_testsuite,
   20742                 :            : #endif
   20743                 :            :                 &end_testsuite
   20744                 :            :         };
   20745                 :            :         static struct unit_test_suite ts = {
   20746                 :            :                 .suite_name = "Scheduler Unit Test Suite",
   20747                 :            :                 .setup = scheduler_testsuite_setup,
   20748                 :            :                 .teardown = testsuite_teardown,
   20749                 :            :                 .unit_test_cases = {TEST_CASES_END()}
   20750                 :            :         };
   20751                 :            : 
   20752                 :          0 :         gbl_driver_id = rte_cryptodev_driver_id_get(
   20753                 :            :                         RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
   20754                 :            : 
   20755         [ #  # ]:          0 :         if (gbl_driver_id == -1) {
   20756                 :          0 :                 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
   20757                 :          0 :                 return TEST_SKIPPED;
   20758                 :            :         }
   20759                 :            : 
   20760         [ #  # ]:          0 :         if (rte_cryptodev_driver_id_get(
   20761                 :            :                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
   20762                 :          0 :                 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
   20763                 :          0 :                 return TEST_SKIPPED;
   20764                 :            :         }
   20765                 :            : 
   20766         [ #  # ]:          0 :         for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
   20767                 :            :                 uint8_t blk_i = 0;
   20768                 :          0 :                 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
   20769                 :            :                                 (struct unit_test_suite *) *
   20770                 :            :                                 (RTE_DIM(blk_suites) +
   20771                 :            :                                 RTE_DIM(sched_mode_static_suites) + 1));
   20772         [ #  # ]:          0 :                 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
   20773                 :            :                                 blk_suites, RTE_DIM(blk_suites));
   20774         [ #  # ]:          0 :                 ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
   20775                 :            :                                 sched_mode_static_suites,
   20776                 :            :                                 RTE_DIM(sched_mode_static_suites));
   20777                 :          0 :                 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
   20778                 :            :         }
   20779                 :            : 
   20780                 :          0 :         ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
   20781                 :            :                         (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
   20782         [ #  # ]:          0 :         ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
   20783                 :            :                         RTE_DIM(sched_mode_suites));
   20784         [ #  # ]:          0 :         ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
   20785                 :          0 :         ret = unit_test_suite_runner(&ts);
   20786                 :            : 
   20787         [ #  # ]:          0 :         for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
   20788         [ #  # ]:          0 :                 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
   20789                 :            :                                 (*sched_mode_suites[sched_i]),
   20790                 :            :                                 RTE_DIM(blk_suites));
   20791                 :          0 :                 free(sched_mode_suites[sched_i]->unit_test_suites);
   20792                 :            :         }
   20793                 :          0 :         free(ts.unit_test_suites);
   20794                 :          0 :         return ret;
   20795                 :            : }
   20796                 :            : 
   20797                 :        276 : REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
   20798                 :            : 
   20799                 :            : #endif
   20800                 :            : 
   20801                 :            : static int
   20802                 :          0 : test_cryptodev_dpaa2_sec(void)
   20803                 :            : {
   20804                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
   20805                 :            : }
   20806                 :            : 
   20807                 :            : static int
   20808                 :          0 : test_cryptodev_dpaa_sec(void)
   20809                 :            : {
   20810                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
   20811                 :            : }
   20812                 :            : 
   20813                 :            : static int
   20814                 :          0 : test_cryptodev_ccp(void)
   20815                 :            : {
   20816                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
   20817                 :            : }
   20818                 :            : 
   20819                 :            : static int
   20820                 :          0 : test_cryptodev_octeontx(void)
   20821                 :            : {
   20822                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
   20823                 :            : }
   20824                 :            : 
   20825                 :            : static int
   20826                 :          0 : test_cryptodev_caam_jr(void)
   20827                 :            : {
   20828                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
   20829                 :            : }
   20830                 :            : 
   20831                 :            : static int
   20832                 :          0 : test_cryptodev_nitrox(void)
   20833                 :            : {
   20834                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
   20835                 :            : }
   20836                 :            : 
   20837                 :            : static int
   20838                 :          0 : test_cryptodev_bcmfs(void)
   20839                 :            : {
   20840                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
   20841                 :            : }
   20842                 :            : 
   20843                 :            : static int
   20844                 :          0 : run_cryptodev_raw_testsuite(const char *pmd_name)
   20845                 :            : {
   20846                 :            :         int ret;
   20847                 :            : 
   20848                 :          0 :         ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
   20849         [ #  # ]:          0 :         if (ret)
   20850                 :            :                 return ret;
   20851                 :            : 
   20852                 :          0 :         global_api_test_type = CRYPTODEV_RAW_API_TEST;
   20853                 :          0 :         ret = run_cryptodev_testsuite(pmd_name);
   20854                 :          0 :         global_api_test_type = CRYPTODEV_API_TEST;
   20855                 :            : 
   20856                 :          0 :         return ret;
   20857                 :            : }
   20858                 :            : 
   20859                 :            : static int
   20860                 :          0 : test_cryptodev_qat_raw_api(void)
   20861                 :            : {
   20862                 :          0 :         return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
   20863                 :            : }
   20864                 :            : 
   20865                 :            : static int
   20866                 :          0 : test_cryptodev_cn9k(void)
   20867                 :            : {
   20868                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
   20869                 :            : }
   20870                 :            : 
   20871                 :            : static int
   20872                 :          0 : test_cryptodev_cn10k(void)
   20873                 :            : {
   20874                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
   20875                 :            : }
   20876                 :            : 
   20877                 :            : static int
   20878                 :          0 : test_cryptodev_cn10k_raw_api(void)
   20879                 :            : {
   20880                 :          0 :         return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
   20881                 :            : }
   20882                 :            : 
   20883                 :            : static int
   20884                 :          0 : test_cryptodev_dpaa2_sec_raw_api(void)
   20885                 :            : {
   20886                 :          0 :         return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
   20887                 :            : }
   20888                 :            : 
   20889                 :            : static int
   20890                 :          0 : test_cryptodev_dpaa_sec_raw_api(void)
   20891                 :            : {
   20892                 :          0 :         return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
   20893                 :            : }
   20894                 :            : 
   20895                 :            : static int
   20896                 :          0 : test_cryptodev_zsda(void)
   20897                 :            : {
   20898                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZSDA_SYM_PMD));
   20899                 :            : }
   20900                 :            : 
   20901                 :        276 : REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
   20902                 :            :                 test_cryptodev_cn10k_raw_api);
   20903                 :        276 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
   20904                 :            :                 test_cryptodev_dpaa2_sec_raw_api);
   20905                 :        276 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
   20906                 :            :                 test_cryptodev_dpaa_sec_raw_api);
   20907                 :        276 : REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
   20908                 :            :                 test_cryptodev_qat_raw_api);
   20909                 :        276 : REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
   20910                 :        276 : REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
   20911                 :        276 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
   20912                 :            :         test_cryptodev_cpu_aesni_mb);
   20913                 :        276 : REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
   20914                 :            :         test_cryptodev_chacha_poly_mb);
   20915                 :        276 : REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
   20916                 :        276 : REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
   20917                 :        276 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
   20918                 :            :         test_cryptodev_cpu_aesni_gcm);
   20919                 :        276 : REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
   20920                 :        276 : REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
   20921                 :        276 : REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
   20922                 :        276 : REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
   20923                 :        276 : REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
   20924                 :        276 : REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
   20925                 :        276 : REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
   20926                 :        276 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
   20927                 :        276 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
   20928                 :        276 : REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
   20929                 :        276 : REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
   20930                 :        276 : REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
   20931                 :        276 : REGISTER_DRIVER_TEST(cryptodev_virtio_user_autotest, test_cryptodev_virtio_user);
   20932                 :        276 : REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
   20933                 :        276 : REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
   20934                 :        276 : REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
   20935                 :        276 : REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
   20936                 :        276 : REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
   20937                 :        276 : REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
   20938                 :        276 : REGISTER_DRIVER_TEST(cryptodev_zsda_autotest, test_cryptodev_zsda);

Generated by: LCOV version 1.14