LCOV - code coverage report
Current view: top level - app/test - test_cryptodev.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 2094 6566 31.9 %
Date: 2024-12-01 18:57:19 Functions: 281 684 41.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 697 3935 17.7 %

           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                 :            : #ifdef RTE_LIB_SECURITY
      52                 :            : #include "test_cryptodev_security_ipsec.h"
      53                 :            : #include "test_cryptodev_security_ipsec_test_vectors.h"
      54                 :            : #include "test_cryptodev_security_pdcp_test_vectors.h"
      55                 :            : #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
      56                 :            : #include "test_cryptodev_security_pdcp_test_func.h"
      57                 :            : #include "test_cryptodev_security_docsis_test_vectors.h"
      58                 :            : #include "test_cryptodev_security_tls_record.h"
      59                 :            : #include "test_security_proto.h"
      60                 :            : 
      61                 :            : #define SDAP_DISABLED   0
      62                 :            : #define SDAP_ENABLED    1
      63                 :            : #endif
      64                 :            : 
      65                 :            : #define VDEV_ARGS_SIZE 100
      66                 :            : #define MAX_NB_SESSIONS 4
      67                 :            : 
      68                 :            : #define MAX_RAW_DEQUEUE_COUNT   65535
      69                 :            : 
      70                 :            : #define IN_PLACE 0
      71                 :            : #define OUT_OF_PLACE 1
      72                 :            : 
      73                 :            : #define QP_DRAIN_TIMEOUT 100
      74                 :            : #define HW_ERR_RECOVER_TIMEOUT 500
      75                 :            : 
      76                 :            : static int gbl_driver_id;
      77                 :            : 
      78                 :            : static enum rte_security_session_action_type gbl_action_type =
      79                 :            :         RTE_SECURITY_ACTION_TYPE_NONE;
      80                 :            : 
      81                 :            : enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
      82                 :            : 
      83                 :            : struct crypto_unittest_params {
      84                 :            :         struct rte_crypto_sym_xform cipher_xform;
      85                 :            :         struct rte_crypto_sym_xform auth_xform;
      86                 :            :         struct rte_crypto_sym_xform aead_xform;
      87                 :            : #ifdef RTE_LIB_SECURITY
      88                 :            :         struct rte_security_docsis_xform docsis_xform;
      89                 :            : #endif
      90                 :            : 
      91                 :            :         union {
      92                 :            :                 void *sess;
      93                 :            : #ifdef RTE_LIB_SECURITY
      94                 :            :                 void *sec_session;
      95                 :            : #endif
      96                 :            :         };
      97                 :            : #ifdef RTE_LIB_SECURITY
      98                 :            :         enum rte_security_session_action_type type;
      99                 :            : #endif
     100                 :            :         struct rte_crypto_op *op;
     101                 :            : 
     102                 :            :         struct rte_mbuf *obuf, *ibuf;
     103                 :            : 
     104                 :            :         uint8_t *digest;
     105                 :            : };
     106                 :            : 
     107                 :            : #define ALIGN_POW2_ROUNDUP(num, align) \
     108                 :            :         (((num) + (align) - 1) & ~((align) - 1))
     109                 :            : 
     110                 :            : #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts)  \
     111                 :            :         for (j = 0; j < num_child_ts; index++, j++)                  \
     112                 :            :                 parent_ts.unit_test_suites[index] = child_ts[j]
     113                 :            : 
     114                 :            : #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types)   \
     115                 :            :         for (j = 0; j < num_blk_types; index++, j++)                         \
     116                 :            :                 parent_ts.unit_test_suites[index] =                             \
     117                 :            :                                 build_blockcipher_test_suite(blk_types[j])
     118                 :            : 
     119                 :            : #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types)             \
     120                 :            :         for (j = index; j < index + num_blk_types; j++)                              \
     121                 :            :                 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
     122                 :            : 
     123                 :            : /*
     124                 :            :  * Forward declarations.
     125                 :            :  */
     126                 :            : static int
     127                 :            : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
     128                 :            :                 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
     129                 :            :                 uint8_t *hmac_key);
     130                 :            : 
     131                 :            : static int
     132                 :            : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
     133                 :            :                 struct crypto_unittest_params *ut_params,
     134                 :            :                 struct crypto_testsuite_params *ts_param,
     135                 :            :                 const uint8_t *cipher,
     136                 :            :                 const uint8_t *digest,
     137                 :            :                 const uint8_t *iv);
     138                 :            : 
     139                 :            : static int
     140                 :            : security_proto_supported(enum rte_security_session_action_type action,
     141                 :            :         enum rte_security_session_protocol proto);
     142                 :            : 
     143                 :            : static int
     144                 :            : dev_configure_and_start(uint64_t ff_disable);
     145                 :            : 
     146                 :            : static int
     147                 :            : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
     148                 :            :                         const enum rte_crypto_cipher_algorithm cipher_algo,
     149                 :            :                         const uint16_t key_size, const uint16_t iv_size);
     150                 :            : 
     151                 :            : static int
     152                 :            : check_auth_capability(const struct crypto_testsuite_params *ts_params,
     153                 :            :                         const enum rte_crypto_auth_algorithm auth_algo,
     154                 :            :                         const uint16_t key_size, const uint16_t iv_size,
     155                 :            :                         const uint16_t tag_size);
     156                 :            : 
     157                 :            : static struct rte_mbuf *
     158                 :          7 : setup_test_string(struct rte_mempool *mpool,
     159                 :            :                 const char *string, size_t len, uint8_t blocksize)
     160                 :            : {
     161                 :          7 :         struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
     162         [ -  + ]:          7 :         size_t t_len = len - (blocksize ? (len % blocksize) : 0);
     163                 :            : 
     164         [ +  - ]:          7 :         if (m) {
     165                 :            :                 char *dst;
     166                 :            : 
     167                 :          7 :                 memset(m->buf_addr, 0, m->buf_len);
     168                 :          7 :                 dst = rte_pktmbuf_append(m, t_len);
     169         [ -  + ]:          7 :                 if (!dst) {
     170                 :          0 :                         rte_pktmbuf_free(m);
     171                 :          0 :                         return NULL;
     172                 :            :                 }
     173         [ +  - ]:          7 :                 if (string != NULL)
     174                 :            :                         rte_memcpy(dst, string, t_len);
     175                 :            :                 else
     176                 :            :                         memset(dst, 0, t_len);
     177                 :            :         }
     178                 :            : 
     179                 :            :         return m;
     180                 :            : }
     181                 :            : 
     182                 :            : /* Get number of bytes in X bits (rounding up) */
     183                 :            : static uint32_t
     184                 :            : ceil_byte_length(uint32_t num_bits)
     185                 :            : {
     186                 :          4 :         if (num_bits % 8)
     187                 :          0 :                 return ((num_bits >> 3) + 1);
     188                 :            :         else
     189                 :          4 :                 return (num_bits >> 3);
     190                 :            : }
     191                 :            : 
     192                 :            : static void
     193                 :          0 : post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
     194                 :            :                 uint8_t is_op_success)
     195                 :            : {
     196                 :            :         struct rte_crypto_op *op = user_data;
     197         [ #  # ]:          0 :         op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
     198                 :            :                         RTE_CRYPTO_OP_STATUS_ERROR;
     199                 :          0 : }
     200                 :            : 
     201                 :            : static struct crypto_testsuite_params testsuite_params = { NULL };
     202                 :            : struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
     203                 :            : static struct crypto_unittest_params unittest_params;
     204                 :            : static bool enq_cb_called;
     205                 :            : static bool deq_cb_called;
     206                 :            : 
     207                 :            : enum cryptodev_err_state {
     208                 :            :         CRYPTODEV_ERR_CLEARED,
     209                 :            :         CRYPTODEV_ERR_TRIGGERED,
     210                 :            :         CRYPTODEV_ERR_UNRECOVERABLE,
     211                 :            : };
     212                 :            : 
     213                 :            : static enum cryptodev_err_state crypto_err = CRYPTODEV_ERR_CLEARED;
     214                 :            : 
     215                 :            : static void
     216                 :          0 : test_cryptodev_error_cb(uint8_t dev_id, enum rte_cryptodev_event_type event, void *cb_arg)
     217                 :            : {
     218                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     219                 :            :         uint16_t qp_id;
     220                 :            :         int ticks = 0;
     221                 :            :         int ret = 0;
     222                 :            : 
     223                 :            :         RTE_SET_USED(event);
     224                 :            :         RTE_SET_USED(cb_arg);
     225                 :            : 
     226         [ #  # ]:          0 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
     227                 :          0 :                 ret = rte_cryptodev_queue_pair_event_error_query(dev_id, qp_id);
     228         [ #  # ]:          0 :                 if (ret)
     229                 :            :                         break;
     230                 :            :         }
     231         [ #  # ]:          0 :         if (ret == 1) {
     232                 :            :                 /* Wait for the queue to be completely drained */
     233   [ #  #  #  # ]:          0 :                 while (rte_cryptodev_qp_depth_used(dev_id, qp_id) != 0) {
     234                 :            :                         rte_delay_ms(10);
     235                 :          0 :                         ticks++;
     236         [ #  # ]:          0 :                         if (ticks > QP_DRAIN_TIMEOUT) {
     237                 :          0 :                                 crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
     238                 :          0 :                                 return;
     239                 :            :                         }
     240                 :            :                 }
     241         [ #  # ]:          0 :                 if (rte_cryptodev_queue_pair_reset(dev_id, qp_id, NULL, 0)) {
     242                 :          0 :                         crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
     243                 :          0 :                         return;
     244                 :            :                 }
     245                 :            :         }
     246                 :            : 
     247                 :          0 :         crypto_err = CRYPTODEV_ERR_CLEARED;
     248                 :            : }
     249                 :            : 
     250                 :            : static struct rte_mbuf *
     251                 :          0 : create_mbuf_from_heap(int pkt_len, uint8_t pattern)
     252                 :            : {
     253                 :            :         struct rte_mbuf *m = NULL;
     254                 :            :         uint8_t *dst;
     255                 :            : 
     256                 :          0 :         m = calloc(1, MBUF_SIZE);
     257         [ #  # ]:          0 :         if (m == NULL) {
     258                 :            :                 printf("Cannot create mbuf from heap");
     259                 :          0 :                 return NULL;
     260                 :            :         }
     261                 :            : 
     262                 :            :         /* Set the default values to the mbuf */
     263                 :          0 :         m->nb_segs = 1;
     264                 :          0 :         m->port = RTE_MBUF_PORT_INVALID;
     265                 :          0 :         m->buf_len = MBUF_SIZE - sizeof(struct rte_mbuf) - RTE_PKTMBUF_HEADROOM;
     266                 :            :         rte_pktmbuf_reset_headroom(m);
     267                 :            :         __rte_mbuf_sanity_check(m, 1);
     268                 :            : 
     269                 :          0 :         m->buf_addr = (char *)m + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM;
     270                 :            : 
     271                 :          0 :         memset(m->buf_addr, pattern, m->buf_len);
     272                 :          0 :         dst = (uint8_t *)rte_pktmbuf_append(m, pkt_len);
     273         [ #  # ]:          0 :         if (dst == NULL) {
     274                 :            :                 printf("Cannot append %d bytes to the mbuf\n", pkt_len);
     275                 :          0 :                 free(m);
     276                 :          0 :                 return NULL;
     277                 :            :         }
     278                 :            : 
     279                 :            :         return m;
     280                 :            : }
     281                 :            : 
     282                 :            : int
     283                 :          0 : process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
     284                 :            :                 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
     285                 :            :                 uint8_t len_in_bits, uint8_t cipher_iv_len)
     286                 :            : {
     287                 :          0 :         struct rte_crypto_sym_op *sop = op->sym;
     288                 :          0 :         struct rte_crypto_op *ret_op = NULL;
     289                 :            :         struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
     290                 :            :         struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
     291                 :            :         union rte_crypto_sym_ofs ofs;
     292                 :            :         struct rte_crypto_sym_vec vec;
     293                 :            :         struct rte_crypto_sgl sgl, dest_sgl;
     294                 :            :         uint32_t max_len;
     295                 :            :         union rte_cryptodev_session_ctx sess;
     296                 :            :         uint64_t auth_end_iova;
     297                 :            :         uint32_t count = 0;
     298                 :            :         struct rte_crypto_raw_dp_ctx *ctx;
     299                 :            :         uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
     300                 :            :                         auth_len = 0;
     301                 :            :         int32_t n;
     302                 :            :         uint32_t n_success;
     303                 :            :         int ctx_service_size;
     304                 :          0 :         int32_t status = 0;
     305                 :            :         int enqueue_status, dequeue_status;
     306                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
     307                 :          0 :         int is_sgl = sop->m_src->nb_segs > 1;
     308                 :            :         int ret = TEST_SUCCESS, is_oop = 0;
     309                 :            : 
     310                 :          0 :         ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
     311         [ #  # ]:          0 :         if (ctx_service_size < 0)
     312                 :            :                 return TEST_SKIPPED;
     313                 :            : 
     314                 :          0 :         ctx = malloc(ctx_service_size);
     315         [ #  # ]:          0 :         if (ctx == NULL)
     316                 :            :                 return TEST_FAILED;
     317                 :            : 
     318                 :            :         /* Both are enums, setting crypto_sess will suit any session type */
     319                 :          0 :         sess.crypto_sess = op->sym->session;
     320                 :            : 
     321                 :          0 :         ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
     322         [ #  # ]:          0 :         if (ret == -ENOTSUP) {
     323                 :            :                 ret = TEST_SKIPPED;
     324                 :          0 :                 goto exit;
     325         [ #  # ]:          0 :         } else if (ret) {
     326                 :            :                 ret = TEST_FAILED;
     327                 :          0 :                 goto exit;
     328                 :            :         }
     329                 :            : 
     330                 :          0 :         cipher_iv.iova = 0;
     331                 :          0 :         cipher_iv.va = NULL;
     332                 :          0 :         aad_auth_iv.iova = 0;
     333                 :          0 :         aad_auth_iv.va = NULL;
     334                 :          0 :         digest.iova = 0;
     335                 :          0 :         digest.va = NULL;
     336                 :          0 :         sgl.vec = data_vec;
     337                 :          0 :         vec.num = 1;
     338                 :          0 :         vec.src_sgl = &sgl;
     339                 :          0 :         vec.iv = &cipher_iv;
     340                 :          0 :         vec.digest = &digest;
     341                 :          0 :         vec.aad = &aad_auth_iv;
     342                 :          0 :         vec.status = &status;
     343                 :            : 
     344                 :          0 :         ofs.raw = 0;
     345                 :            : 
     346   [ #  #  #  # ]:          0 :         if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
     347                 :            :                 is_oop = 1;
     348                 :            : 
     349         [ #  # ]:          0 :         if (is_cipher && is_auth) {
     350                 :          0 :                 cipher_offset = sop->cipher.data.offset;
     351                 :          0 :                 cipher_len = sop->cipher.data.length;
     352                 :          0 :                 auth_offset = sop->auth.data.offset;
     353                 :          0 :                 auth_len = sop->auth.data.length;
     354                 :          0 :                 max_len = RTE_MAX(cipher_offset + cipher_len,
     355                 :            :                                 auth_offset + auth_len);
     356         [ #  # ]:          0 :                 if (len_in_bits) {
     357                 :          0 :                         max_len = max_len >> 3;
     358                 :          0 :                         cipher_offset = cipher_offset >> 3;
     359                 :          0 :                         auth_offset = auth_offset >> 3;
     360                 :          0 :                         cipher_len = cipher_len >> 3;
     361                 :          0 :                         auth_len = auth_len >> 3;
     362                 :            :                 }
     363                 :          0 :                 ofs.ofs.cipher.head = cipher_offset;
     364                 :          0 :                 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
     365                 :          0 :                 ofs.ofs.auth.head = auth_offset;
     366                 :          0 :                 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
     367                 :          0 :                 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
     368                 :          0 :                 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
     369                 :          0 :                 aad_auth_iv.va = rte_crypto_op_ctod_offset(
     370                 :            :                                 op, void *, IV_OFFSET + cipher_iv_len);
     371                 :          0 :                 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
     372                 :            :                                 cipher_iv_len);
     373                 :          0 :                 digest.va = (void *)sop->auth.digest.data;
     374                 :          0 :                 digest.iova = sop->auth.digest.phys_addr;
     375                 :            : 
     376         [ #  # ]:          0 :                 if (is_sgl) {
     377                 :          0 :                         uint32_t remaining_off = auth_offset + auth_len;
     378                 :          0 :                         struct rte_mbuf *sgl_buf = sop->m_src;
     379         [ #  # ]:          0 :                         if (is_oop)
     380                 :            :                                 sgl_buf = sop->m_dst;
     381                 :            : 
     382                 :          0 :                         while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
     383   [ #  #  #  # ]:          0 :                                         && sgl_buf->next != NULL) {
     384                 :          0 :                                 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
     385                 :            :                                 sgl_buf = sgl_buf->next;
     386                 :            :                         }
     387                 :            : 
     388                 :          0 :                         auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
     389                 :            :                                 sgl_buf, remaining_off);
     390                 :            :                 } else {
     391                 :          0 :                         auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
     392                 :          0 :                                                          auth_offset + auth_len;
     393                 :            :                 }
     394                 :            :                 /* Then check if digest-encrypted conditions are met */
     395   [ #  #  #  # ]:          0 :                 if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
     396         [ #  # ]:          0 :                                 (digest.iova == auth_end_iova) && is_sgl)
     397                 :          0 :                         max_len = RTE_MAX(max_len,
     398                 :            :                                 auth_offset + auth_len +
     399                 :            :                                 ut_params->auth_xform.auth.digest_length);
     400                 :            : 
     401         [ #  # ]:          0 :         } else if (is_cipher) {
     402                 :          0 :                 cipher_offset = sop->cipher.data.offset;
     403                 :          0 :                 cipher_len = sop->cipher.data.length;
     404                 :          0 :                 max_len = cipher_len + cipher_offset;
     405         [ #  # ]:          0 :                 if (len_in_bits) {
     406                 :          0 :                         max_len = max_len >> 3;
     407                 :          0 :                         cipher_offset = cipher_offset >> 3;
     408                 :          0 :                         cipher_len = cipher_len >> 3;
     409                 :            :                 }
     410                 :          0 :                 ofs.ofs.cipher.head = cipher_offset;
     411                 :          0 :                 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
     412                 :          0 :                 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
     413                 :          0 :                 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
     414                 :            : 
     415         [ #  # ]:          0 :         } else if (is_auth) {
     416                 :          0 :                 auth_offset = sop->auth.data.offset;
     417                 :          0 :                 auth_len = sop->auth.data.length;
     418                 :          0 :                 max_len = auth_len + auth_offset;
     419         [ #  # ]:          0 :                 if (len_in_bits) {
     420                 :          0 :                         max_len = max_len >> 3;
     421                 :          0 :                         auth_offset = auth_offset >> 3;
     422                 :          0 :                         auth_len = auth_len >> 3;
     423                 :            :                 }
     424                 :          0 :                 ofs.ofs.auth.head = auth_offset;
     425                 :          0 :                 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
     426                 :          0 :                 aad_auth_iv.va = rte_crypto_op_ctod_offset(
     427                 :            :                                 op, void *, IV_OFFSET + cipher_iv_len);
     428                 :          0 :                 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
     429                 :            :                                 cipher_iv_len);
     430                 :          0 :                 digest.va = (void *)sop->auth.digest.data;
     431                 :          0 :                 digest.iova = sop->auth.digest.phys_addr;
     432                 :            : 
     433                 :            :         } else { /* aead */
     434                 :          0 :                 cipher_offset = sop->aead.data.offset;
     435                 :          0 :                 cipher_len = sop->aead.data.length;
     436                 :          0 :                 max_len = cipher_len + cipher_offset;
     437         [ #  # ]:          0 :                 if (len_in_bits) {
     438                 :          0 :                         max_len = max_len >> 3;
     439                 :          0 :                         cipher_offset = cipher_offset >> 3;
     440                 :          0 :                         cipher_len = cipher_len >> 3;
     441                 :            :                 }
     442                 :          0 :                 ofs.ofs.cipher.head = cipher_offset;
     443                 :          0 :                 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
     444                 :          0 :                 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
     445                 :          0 :                 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
     446                 :          0 :                 aad_auth_iv.va = (void *)sop->aead.aad.data;
     447                 :          0 :                 aad_auth_iv.iova = sop->aead.aad.phys_addr;
     448                 :          0 :                 digest.va = (void *)sop->aead.digest.data;
     449                 :          0 :                 digest.iova = sop->aead.digest.phys_addr;
     450                 :            :         }
     451                 :            : 
     452                 :          0 :         n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
     453                 :            :                         data_vec, RTE_DIM(data_vec));
     454   [ #  #  #  # ]:          0 :         if (n < 0 || n > sop->m_src->nb_segs) {
     455                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     456                 :          0 :                 goto exit;
     457                 :            :         }
     458                 :            : 
     459                 :          0 :         sgl.num = n;
     460                 :            :         /* Out of place */
     461         [ #  # ]:          0 :         if (is_oop) {
     462                 :          0 :                 dest_sgl.vec = dest_data_vec;
     463                 :          0 :                 vec.dest_sgl = &dest_sgl;
     464                 :          0 :                 n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
     465                 :            :                                 dest_data_vec, RTE_DIM(dest_data_vec));
     466   [ #  #  #  # ]:          0 :                 if (n < 0 || n > sop->m_dst->nb_segs) {
     467                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     468                 :          0 :                         goto exit;
     469                 :            :                 }
     470                 :          0 :                 dest_sgl.num = n;
     471                 :            :         } else
     472                 :          0 :                 vec.dest_sgl = NULL;
     473                 :            : 
     474         [ #  # ]:          0 :         if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
     475                 :            :                         &enqueue_status) < 1) {
     476                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     477                 :          0 :                 goto exit;
     478                 :            :         }
     479                 :            : 
     480         [ #  # ]:          0 :         if (enqueue_status == 0) {
     481                 :          0 :                 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
     482         [ #  # ]:          0 :                 if (status < 0) {
     483                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     484                 :          0 :                         goto exit;
     485                 :            :                 }
     486         [ #  # ]:          0 :         } else if (enqueue_status < 0) {
     487                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     488                 :          0 :                 goto exit;
     489                 :            :         }
     490                 :            : 
     491                 :          0 :         n = n_success = 0;
     492   [ #  #  #  # ]:          0 :         while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
     493                 :          0 :                 n = rte_cryptodev_raw_dequeue_burst(ctx,
     494                 :            :                         NULL, 1, post_process_raw_dp_op,
     495                 :            :                                 (void **)&ret_op, 0, &n_success,
     496                 :            :                                 &dequeue_status);
     497         [ #  # ]:          0 :                 if (dequeue_status < 0) {
     498                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     499                 :          0 :                         goto exit;
     500                 :            :                 }
     501         [ #  # ]:          0 :                 if (n == 0)
     502                 :            :                         rte_pause();
     503                 :            :         }
     504                 :            : 
     505   [ #  #  #  # ]:          0 :         if (n == 1 && dequeue_status == 0) {
     506         [ #  # ]:          0 :                 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
     507                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     508                 :          0 :                         goto exit;
     509                 :            :                 }
     510                 :            :         }
     511                 :            : 
     512   [ #  #  #  # ]:          0 :         op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
     513         [ #  # ]:          0 :                         ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
     514         [ #  # ]:          0 :                         n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
     515                 :            :                                         RTE_CRYPTO_OP_STATUS_SUCCESS;
     516                 :            : 
     517                 :          0 : exit:
     518                 :          0 :         free(ctx);
     519                 :          0 :         return ret;
     520                 :            : }
     521                 :            : 
     522                 :            : static void
     523                 :          0 : process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
     524                 :            : {
     525                 :            :         int32_t n, st;
     526                 :            :         struct rte_crypto_sym_op *sop;
     527                 :            :         union rte_crypto_sym_ofs ofs;
     528                 :            :         struct rte_crypto_sgl sgl;
     529                 :            :         struct rte_crypto_sym_vec symvec;
     530                 :            :         struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
     531                 :            :         struct rte_crypto_vec vec[UINT8_MAX];
     532                 :            : 
     533                 :            :         sop = op->sym;
     534                 :            : 
     535                 :          0 :         n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
     536                 :            :                 sop->aead.data.length, vec, RTE_DIM(vec));
     537                 :            : 
     538   [ #  #  #  # ]:          0 :         if (n < 0 || n != sop->m_src->nb_segs) {
     539                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     540                 :          0 :                 return;
     541                 :            :         }
     542                 :            : 
     543                 :          0 :         sgl.vec = vec;
     544                 :          0 :         sgl.num = n;
     545                 :          0 :         symvec.src_sgl = &sgl;
     546                 :          0 :         symvec.iv = &iv_ptr;
     547                 :          0 :         symvec.digest = &digest_ptr;
     548                 :          0 :         symvec.aad = &aad_ptr;
     549                 :          0 :         symvec.status = &st;
     550                 :          0 :         symvec.num = 1;
     551                 :            : 
     552                 :            :         /* for CPU crypto the IOVA address is not required */
     553                 :          0 :         iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
     554                 :          0 :         digest_ptr.va = (void *)sop->aead.digest.data;
     555                 :          0 :         aad_ptr.va = (void *)sop->aead.aad.data;
     556                 :            : 
     557                 :          0 :         ofs.raw = 0;
     558                 :            : 
     559                 :          0 :         n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
     560                 :            :                 &symvec);
     561                 :            : 
     562         [ #  # ]:          0 :         if (n != 1)
     563                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
     564                 :            :         else
     565                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
     566                 :            : }
     567                 :            : 
     568                 :            : static void
     569                 :          0 : process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
     570                 :            : {
     571                 :            :         int32_t n, st;
     572                 :            :         struct rte_crypto_sym_op *sop;
     573                 :            :         union rte_crypto_sym_ofs ofs;
     574                 :            :         struct rte_crypto_sgl sgl;
     575                 :            :         struct rte_crypto_sym_vec symvec;
     576                 :            :         struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
     577                 :            :         struct rte_crypto_vec vec[UINT8_MAX];
     578                 :            : 
     579                 :            :         sop = op->sym;
     580                 :            : 
     581                 :          0 :         n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
     582                 :            :                 sop->auth.data.length, vec, RTE_DIM(vec));
     583                 :            : 
     584   [ #  #  #  # ]:          0 :         if (n < 0 || n != sop->m_src->nb_segs) {
     585                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
     586                 :          0 :                 return;
     587                 :            :         }
     588                 :            : 
     589                 :          0 :         sgl.vec = vec;
     590                 :          0 :         sgl.num = n;
     591                 :          0 :         symvec.src_sgl = &sgl;
     592                 :          0 :         symvec.iv = &iv_ptr;
     593                 :          0 :         symvec.digest = &digest_ptr;
     594                 :          0 :         symvec.status = &st;
     595                 :          0 :         symvec.num = 1;
     596                 :            : 
     597                 :          0 :         iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
     598                 :          0 :         digest_ptr.va = (void *)sop->auth.digest.data;
     599                 :            : 
     600                 :          0 :         ofs.raw = 0;
     601                 :          0 :         ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
     602                 :          0 :         ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
     603                 :          0 :                 (sop->cipher.data.offset + sop->cipher.data.length);
     604                 :            : 
     605                 :          0 :         n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
     606                 :            :                 &symvec);
     607                 :            : 
     608         [ #  # ]:          0 :         if (n != 1)
     609                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
     610                 :            :         else
     611                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
     612                 :            : }
     613                 :            : 
     614                 :            : static struct rte_crypto_op *
     615                 :        116 : process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
     616                 :            : {
     617                 :            : 
     618         [ -  + ]:        116 :         RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
     619                 :            : 
     620         [ -  + ]:        116 :         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
     621                 :          0 :                 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
     622                 :          0 :                 return NULL;
     623                 :            :         }
     624                 :            : 
     625                 :        116 :         op = NULL;
     626                 :            : 
     627         [ -  + ]:        116 :         while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
     628                 :            :                 rte_pause();
     629                 :            : 
     630         [ +  + ]:        116 :         if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
     631                 :         11 :                 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
     632                 :         11 :                 return NULL;
     633                 :            :         }
     634                 :            : 
     635                 :            :         return op;
     636                 :            : }
     637                 :            : 
     638                 :            : static int
     639                 :          1 : testsuite_setup(void)
     640                 :            : {
     641                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     642                 :            :         struct rte_cryptodev_info info;
     643                 :            :         uint32_t i = 0, nb_devs, dev_id;
     644                 :            :         uint16_t qp_id;
     645                 :            : 
     646                 :            :         memset(ts_params, 0, sizeof(*ts_params));
     647                 :            : 
     648                 :          1 :         ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
     649         [ +  - ]:          1 :         if (ts_params->mbuf_pool == NULL) {
     650                 :            :                 /* Not already created so create */
     651                 :          1 :                 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
     652                 :            :                                 "CRYPTO_MBUFPOOL",
     653                 :            :                                 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
     654                 :          1 :                                 rte_socket_id());
     655         [ -  + ]:          1 :                 if (ts_params->mbuf_pool == NULL) {
     656                 :          0 :                         RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
     657                 :          0 :                         return TEST_FAILED;
     658                 :            :                 }
     659                 :            :         }
     660                 :            : 
     661                 :          1 :         ts_params->large_mbuf_pool = rte_mempool_lookup(
     662                 :            :                         "CRYPTO_LARGE_MBUFPOOL");
     663         [ +  - ]:          1 :         if (ts_params->large_mbuf_pool == NULL) {
     664                 :            :                 /* Not already created so create */
     665                 :          1 :                 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
     666                 :            :                                 "CRYPTO_LARGE_MBUFPOOL",
     667                 :            :                                 1, 0, 0, LARGE_MBUF_SIZE,
     668                 :          1 :                                 rte_socket_id());
     669         [ -  + ]:          1 :                 if (ts_params->large_mbuf_pool == NULL) {
     670                 :          0 :                         RTE_LOG(ERR, USER1,
     671                 :            :                                 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
     672                 :          0 :                         return TEST_FAILED;
     673                 :            :                 }
     674                 :            :         }
     675                 :            : 
     676                 :          1 :         ts_params->op_mpool = rte_crypto_op_pool_create(
     677                 :            :                         "MBUF_CRYPTO_SYM_OP_POOL",
     678                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC,
     679                 :            :                         NUM_MBUFS, MBUF_CACHE_SIZE,
     680                 :            :                         DEFAULT_NUM_XFORMS *
     681                 :            :                         sizeof(struct rte_crypto_sym_xform) +
     682                 :            :                         MAXIMUM_IV_LENGTH,
     683                 :          1 :                         rte_socket_id());
     684         [ -  + ]:          1 :         if (ts_params->op_mpool == NULL) {
     685                 :          0 :                 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
     686                 :          0 :                 return TEST_FAILED;
     687                 :            :         }
     688                 :            : 
     689                 :          1 :         nb_devs = rte_cryptodev_count();
     690         [ -  + ]:          1 :         if (nb_devs < 1) {
     691                 :          0 :                 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
     692                 :          0 :                 return TEST_SKIPPED;
     693                 :            :         }
     694                 :            : 
     695         [ -  + ]:          1 :         if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
     696                 :          0 :                 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
     697                 :            :                                 rte_cryptodev_driver_name_get(gbl_driver_id));
     698                 :          0 :                 return TEST_SKIPPED;
     699                 :            :         }
     700                 :            : 
     701                 :            :         /* Create list of valid crypto devs */
     702         [ +  + ]:          2 :         for (i = 0; i < nb_devs; i++) {
     703                 :          1 :                 rte_cryptodev_info_get(i, &info);
     704         [ +  - ]:          1 :                 if (info.driver_id == gbl_driver_id)
     705                 :          1 :                         ts_params->valid_devs[ts_params->valid_dev_count++] = i;
     706                 :            :         }
     707                 :            : 
     708         [ +  - ]:          1 :         if (ts_params->valid_dev_count < 1)
     709                 :            :                 return TEST_FAILED;
     710                 :            : 
     711                 :            :         /* Set up all the qps on the first of the valid devices found */
     712                 :            : 
     713                 :          1 :         dev_id = ts_params->valid_devs[0];
     714                 :            : 
     715                 :          1 :         rte_cryptodev_info_get(dev_id, &info);
     716                 :            : 
     717                 :          1 :         ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
     718                 :          1 :         ts_params->conf.socket_id = SOCKET_ID_ANY;
     719                 :          1 :         ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
     720                 :            : 
     721                 :            :         unsigned int session_size =
     722                 :          1 :                 rte_cryptodev_sym_get_private_session_size(dev_id);
     723                 :            : 
     724                 :            : #ifdef RTE_LIB_SECURITY
     725                 :          1 :         unsigned int security_session_size = rte_security_session_get_size(
     726                 :            :                         rte_cryptodev_get_sec_ctx(dev_id));
     727                 :            : 
     728                 :            :         if (session_size < security_session_size)
     729                 :            :                 session_size = security_session_size;
     730                 :            : #endif
     731                 :            :         /*
     732                 :            :          * Create mempool with maximum number of sessions.
     733                 :            :          */
     734         [ -  + ]:          1 :         if (info.sym.max_nb_sessions != 0 &&
     735                 :            :                         info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
     736                 :          0 :                 RTE_LOG(ERR, USER1, "Device does not support "
     737                 :            :                                 "at least %u sessions\n",
     738                 :            :                                 MAX_NB_SESSIONS);
     739                 :          0 :                 return TEST_FAILED;
     740                 :            :         }
     741                 :            : 
     742                 :          1 :         ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
     743                 :            :                         "test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
     744                 :            :                         SOCKET_ID_ANY);
     745         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
     746                 :            :                         "session mempool allocation failed");
     747                 :            : 
     748         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
     749                 :            :                         &ts_params->conf),
     750                 :            :                         "Failed to configure cryptodev %u with %u qps",
     751                 :            :                         dev_id, ts_params->conf.nb_queue_pairs);
     752                 :            : 
     753                 :          1 :         ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
     754                 :          1 :         ts_params->qp_conf.mp_session = ts_params->session_mpool;
     755                 :            : 
     756         [ +  + ]:          9 :         for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
     757         [ -  + ]:          8 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
     758                 :            :                         dev_id, qp_id, &ts_params->qp_conf,
     759                 :            :                         rte_cryptodev_socket_id(dev_id)),
     760                 :            :                         "Failed to setup queue pair %u on cryptodev %u",
     761                 :            :                         qp_id, dev_id);
     762                 :            :         }
     763                 :            : 
     764                 :            :         return TEST_SUCCESS;
     765                 :            : }
     766                 :            : 
     767                 :            : static void
     768                 :          1 : testsuite_teardown(void)
     769                 :            : {
     770                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     771                 :            :         int res;
     772                 :            : 
     773         [ +  - ]:          1 :         if (ts_params->large_mbuf_pool != NULL) {
     774                 :          1 :                 rte_mempool_free(ts_params->large_mbuf_pool);
     775                 :          1 :                 ts_params->large_mbuf_pool = NULL;
     776                 :            :         }
     777                 :            : 
     778         [ +  - ]:          1 :         if (ts_params->mbuf_pool != NULL) {
     779                 :          1 :                 rte_mempool_free(ts_params->mbuf_pool);
     780                 :          1 :                 ts_params->mbuf_pool = NULL;
     781                 :            :         }
     782                 :            : 
     783         [ +  - ]:          1 :         if (ts_params->op_mpool != NULL) {
     784                 :          1 :                 rte_mempool_free(ts_params->op_mpool);
     785                 :          1 :                 ts_params->op_mpool = NULL;
     786                 :            :         }
     787                 :            : 
     788         [ +  - ]:          1 :         if (ts_params->session_mpool != NULL) {
     789                 :          1 :                 rte_mempool_free(ts_params->session_mpool);
     790                 :          1 :                 ts_params->session_mpool = NULL;
     791                 :            :         }
     792                 :            : 
     793                 :          1 :         res = rte_cryptodev_close(ts_params->valid_devs[0]);
     794         [ -  + ]:          1 :         if (res)
     795                 :          0 :                 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
     796                 :          1 : }
     797                 :            : 
     798                 :            : static int
     799                 :         30 : check_capabilities_supported(enum rte_crypto_sym_xform_type type,
     800                 :            :                 const int *algs, uint16_t num_algs)
     801                 :            : {
     802                 :         30 :         uint8_t dev_id = testsuite_params.valid_devs[0];
     803                 :            :         bool some_alg_supported = false;
     804                 :            :         uint16_t i;
     805                 :            : 
     806         [ +  + ]:         72 :         for (i = 0; i < num_algs && !some_alg_supported; i++) {
     807                 :         42 :                 struct rte_cryptodev_sym_capability_idx alg = {
     808                 :         42 :                         type, {algs[i]}
     809                 :            :                 };
     810         [ +  + ]:         42 :                 if (rte_cryptodev_sym_capability_get(dev_id,
     811                 :            :                                 &alg) != NULL)
     812                 :            :                         some_alg_supported = true;
     813                 :            :         }
     814         [ +  + ]:         30 :         if (!some_alg_supported)
     815                 :         13 :                 return TEST_SKIPPED;
     816                 :            : 
     817                 :            :         return 0;
     818                 :            : }
     819                 :            : 
     820                 :            : int
     821                 :          9 : check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
     822                 :            :                 uint16_t num_ciphers)
     823                 :            : {
     824                 :         17 :         return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
     825                 :            :                         (const int *) ciphers, num_ciphers);
     826                 :            : }
     827                 :            : 
     828                 :            : int
     829                 :          2 : check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
     830                 :            :                 uint16_t num_auths)
     831                 :            : {
     832                 :          9 :         return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
     833                 :            :                         (const int *) auths, num_auths);
     834                 :            : }
     835                 :            : 
     836                 :            : int
     837                 :          0 : check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
     838                 :            :                 uint16_t num_aeads)
     839                 :            : {
     840                 :          4 :         return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
     841                 :            :                         (const int *) aeads, num_aeads);
     842                 :            : }
     843                 :            : 
     844                 :            : static int
     845                 :          1 : null_testsuite_setup(void)
     846                 :            : {
     847                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     848                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     849                 :            :         struct rte_cryptodev_info dev_info;
     850                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
     851                 :            :                 RTE_CRYPTO_CIPHER_NULL
     852                 :            :         };
     853                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
     854                 :            :                 RTE_CRYPTO_AUTH_NULL
     855                 :            :         };
     856                 :            : 
     857                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
     858                 :            : 
     859         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
     860                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
     861                 :            :                                 "testsuite not met\n");
     862                 :          0 :                 return TEST_SKIPPED;
     863                 :            :         }
     864                 :            : 
     865         [ +  - ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
     866         [ +  - ]:          1 :                         && check_auth_capabilities_supported(auths,
     867                 :            :                         RTE_DIM(auths)) != 0) {
     868                 :          1 :                 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
     869                 :            :                                 "testsuite not met\n");
     870                 :          1 :                 return TEST_SKIPPED;
     871                 :            :         }
     872                 :            : 
     873                 :            :         return 0;
     874                 :            : }
     875                 :            : 
     876                 :            : static int
     877                 :          1 : crypto_gen_testsuite_setup(void)
     878                 :            : {
     879                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     880                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     881                 :            :         struct rte_cryptodev_info dev_info;
     882                 :            : 
     883                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
     884                 :            : 
     885         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
     886                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
     887                 :            :                                 "testsuite not met\n");
     888                 :          0 :                 return TEST_SKIPPED;
     889                 :            :         }
     890                 :            : 
     891                 :            :         return 0;
     892                 :            : }
     893                 :            : 
     894                 :            : #ifdef RTE_LIB_SECURITY
     895                 :            : static int
     896                 :          4 : sec_proto_testsuite_setup(enum rte_security_session_protocol protocol)
     897                 :            : {
     898                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     899                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
     900                 :            :         struct rte_cryptodev_info dev_info;
     901                 :            :         int ret = 0;
     902                 :            : 
     903                 :          4 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
     904                 :            : 
     905         [ +  - ]:          4 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
     906                 :          4 :                 RTE_LOG(INFO, USER1,
     907                 :            :                         "Feature flag requirements for security protocol testsuite not met\n");
     908                 :          4 :                 return TEST_SKIPPED;
     909                 :            :         }
     910                 :            : 
     911                 :            :         /* Reconfigure to enable security */
     912                 :          0 :         ret = dev_configure_and_start(0);
     913         [ #  # ]:          0 :         if (ret != TEST_SUCCESS)
     914                 :            :                 return ret;
     915                 :            : 
     916                 :            :         /* Set action type */
     917                 :          0 :         ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
     918                 :            : 
     919         [ #  # ]:          0 :         if (security_proto_supported(RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, protocol) < 0) {
     920                 :          0 :                 RTE_LOG(INFO, USER1,
     921                 :            :                         "Capability requirements for security protocol test not met\n");
     922                 :            :                 ret = TEST_SKIPPED;
     923                 :            :         }
     924                 :            : 
     925                 :          0 :         test_sec_alg_list_populate();
     926                 :          0 :         test_sec_auth_only_alg_list_populate();
     927                 :            : 
     928                 :            :         /*
     929                 :            :          * Stop the device. Device would be started again by individual test
     930                 :            :          * case setup routine.
     931                 :            :          */
     932                 :          0 :         rte_cryptodev_stop(ts_params->valid_devs[0]);
     933                 :            : 
     934                 :          0 :         return ret;
     935                 :            : }
     936                 :            : 
     937                 :            : static int
     938                 :          1 : ipsec_proto_testsuite_setup(void)
     939                 :            : {
     940                 :          1 :         return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_IPSEC);
     941                 :            : }
     942                 :            : 
     943                 :            : static int
     944                 :          3 : tls_record_proto_testsuite_setup(void)
     945                 :            : {
     946                 :          3 :         test_sec_proto_pattern_generate();
     947                 :            : 
     948                 :          3 :         return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_TLS_RECORD);
     949                 :            : }
     950                 :            : 
     951                 :            : static int
     952                 :          1 : pdcp_proto_testsuite_setup(void)
     953                 :            : {
     954                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
     955                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
     956                 :            :         struct rte_cryptodev_info dev_info;
     957                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
     958                 :            :                 RTE_CRYPTO_CIPHER_NULL,
     959                 :            :                 RTE_CRYPTO_CIPHER_AES_CTR,
     960                 :            :                 RTE_CRYPTO_CIPHER_ZUC_EEA3,
     961                 :            :                 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
     962                 :            :         };
     963                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
     964                 :            :                 RTE_CRYPTO_AUTH_NULL,
     965                 :            :                 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
     966                 :            :                 RTE_CRYPTO_AUTH_AES_CMAC,
     967                 :            :                 RTE_CRYPTO_AUTH_ZUC_EIA3
     968                 :            :         };
     969                 :            : 
     970                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
     971                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
     972                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
     973                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
     974                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
     975                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
     976                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
     977                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
     978                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
     979                 :            :         RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
     980                 :            : 
     981                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
     982                 :            : 
     983         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
     984                 :            :                         !(dev_info.feature_flags &
     985                 :            :                         RTE_CRYPTODEV_FF_SECURITY)) {
     986                 :          1 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
     987                 :            :                                 "testsuite not met\n");
     988                 :          1 :                 return TEST_SKIPPED;
     989                 :            :         }
     990                 :            : 
     991         [ #  # ]:          0 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
     992         [ #  # ]:          0 :                         && check_auth_capabilities_supported(auths,
     993                 :            :                         RTE_DIM(auths)) != 0) {
     994                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
     995                 :            :                                 "testsuite not met\n");
     996                 :          0 :                 return TEST_SKIPPED;
     997                 :            :         }
     998                 :            : 
     999                 :            :         return 0;
    1000                 :            : }
    1001                 :            : 
    1002                 :            : static int
    1003                 :          1 : docsis_proto_testsuite_setup(void)
    1004                 :            : {
    1005                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1006                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1007                 :            :         struct rte_cryptodev_info dev_info;
    1008                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1009                 :            :                 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
    1010                 :            :         };
    1011                 :            : 
    1012                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1013                 :            : 
    1014         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1015                 :            :                         !(dev_info.feature_flags &
    1016                 :            :                         RTE_CRYPTODEV_FF_SECURITY)) {
    1017                 :          1 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
    1018                 :            :                                 "Proto testsuite not met\n");
    1019                 :          1 :                 return TEST_SKIPPED;
    1020                 :            :         }
    1021                 :            : 
    1022         [ #  # ]:          0 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
    1023                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
    1024                 :            :                                 "testsuite not met\n");
    1025                 :          0 :                 return TEST_SKIPPED;
    1026                 :            :         }
    1027                 :            : 
    1028                 :            :         return 0;
    1029                 :            : }
    1030                 :            : #endif
    1031                 :            : 
    1032                 :            : static int
    1033                 :          1 : aes_ccm_auth_testsuite_setup(void)
    1034                 :            : {
    1035                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1036                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1037                 :            :         struct rte_cryptodev_info dev_info;
    1038                 :          1 :         const enum rte_crypto_aead_algorithm aeads[] = {
    1039                 :            :                 RTE_CRYPTO_AEAD_AES_CCM
    1040                 :            :         };
    1041                 :            : 
    1042                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1043                 :            : 
    1044         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1045         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1046         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1047                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
    1048                 :            :                                 "testsuite not met\n");
    1049                 :          0 :                 return TEST_SKIPPED;
    1050                 :            :         }
    1051                 :            : 
    1052         [ -  + ]:          1 :         if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
    1053                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
    1054                 :            :                                 "testsuite not met\n");
    1055                 :          0 :                 return TEST_SKIPPED;
    1056                 :            :         }
    1057                 :            : 
    1058                 :            :         return 0;
    1059                 :            : }
    1060                 :            : 
    1061                 :            : static int
    1062                 :          1 : aes_gcm_auth_testsuite_setup(void)
    1063                 :            : {
    1064                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1065                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1066                 :            :         struct rte_cryptodev_info dev_info;
    1067                 :          1 :         const enum rte_crypto_aead_algorithm aeads[] = {
    1068                 :            :                 RTE_CRYPTO_AEAD_AES_GCM
    1069                 :            :         };
    1070                 :            : 
    1071                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1072                 :            : 
    1073         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
    1074                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
    1075                 :            :                                 "testsuite not met\n");
    1076                 :          0 :                 return TEST_SKIPPED;
    1077                 :            :         }
    1078                 :            : 
    1079         [ -  + ]:          1 :         if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
    1080                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
    1081                 :            :                                 "testsuite not met\n");
    1082                 :          0 :                 return TEST_SKIPPED;
    1083                 :            :         }
    1084                 :            : 
    1085                 :            :         return 0;
    1086                 :            : }
    1087                 :            : 
    1088                 :            : static int
    1089                 :          1 : aes_gmac_auth_testsuite_setup(void)
    1090                 :            : {
    1091                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1092                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1093                 :            :         struct rte_cryptodev_info dev_info;
    1094                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1095                 :            :                 RTE_CRYPTO_AUTH_AES_GMAC
    1096                 :            :         };
    1097                 :            : 
    1098                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1099                 :            : 
    1100         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1101         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1102         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1103                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
    1104                 :            :                                 "testsuite not met\n");
    1105                 :          0 :                 return TEST_SKIPPED;
    1106                 :            :         }
    1107                 :            : 
    1108         [ -  + ]:          1 :         if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
    1109                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
    1110                 :            :                                 "testsuite not met\n");
    1111                 :          0 :                 return TEST_SKIPPED;
    1112                 :            :         }
    1113                 :            : 
    1114                 :            :         return 0;
    1115                 :            : }
    1116                 :            : 
    1117                 :            : static int
    1118                 :          1 : chacha20_poly1305_testsuite_setup(void)
    1119                 :            : {
    1120                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1121                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1122                 :            :         struct rte_cryptodev_info dev_info;
    1123                 :          1 :         const enum rte_crypto_aead_algorithm aeads[] = {
    1124                 :            :                 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
    1125                 :            :         };
    1126                 :            : 
    1127                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1128                 :            : 
    1129         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1130         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1131         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1132                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for "
    1133                 :            :                                 "Chacha20-Poly1305 testsuite not met\n");
    1134                 :          0 :                 return TEST_SKIPPED;
    1135                 :            :         }
    1136                 :            : 
    1137         [ +  - ]:          1 :         if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
    1138                 :          1 :                 RTE_LOG(INFO, USER1, "Capability requirements for "
    1139                 :            :                                 "Chacha20-Poly1305 testsuite not met\n");
    1140                 :          1 :                 return TEST_SKIPPED;
    1141                 :            :         }
    1142                 :            : 
    1143                 :            :         return 0;
    1144                 :            : }
    1145                 :            : 
    1146                 :            : static int
    1147                 :          1 : snow3g_testsuite_setup(void)
    1148                 :            : {
    1149                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1150                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1151                 :            :         struct rte_cryptodev_info dev_info;
    1152                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1153                 :            :                 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
    1154                 :            : 
    1155                 :            :         };
    1156                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1157                 :            :                 RTE_CRYPTO_AUTH_SNOW3G_UIA2
    1158                 :            :         };
    1159                 :            : 
    1160                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1161                 :            : 
    1162         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
    1163                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
    1164                 :            :                                 "testsuite not met\n");
    1165                 :          0 :                 return TEST_SKIPPED;
    1166                 :            :         }
    1167                 :            : 
    1168         [ +  - ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1169         [ +  - ]:          1 :                         && check_auth_capabilities_supported(auths,
    1170                 :            :                         RTE_DIM(auths)) != 0) {
    1171                 :          1 :                 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
    1172                 :            :                                 "testsuite not met\n");
    1173                 :          1 :                 return TEST_SKIPPED;
    1174                 :            :         }
    1175                 :            : 
    1176                 :            :         return 0;
    1177                 :            : }
    1178                 :            : 
    1179                 :            : static int
    1180                 :          1 : zuc_testsuite_setup(void)
    1181                 :            : {
    1182                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1183                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1184                 :            :         struct rte_cryptodev_info dev_info;
    1185                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1186                 :            :                 RTE_CRYPTO_CIPHER_ZUC_EEA3
    1187                 :            :         };
    1188                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1189                 :            :                 RTE_CRYPTO_AUTH_ZUC_EIA3
    1190                 :            :         };
    1191                 :            : 
    1192                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1193                 :            : 
    1194         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
    1195                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
    1196                 :            :                                 "testsuite not met\n");
    1197                 :          0 :                 return TEST_SKIPPED;
    1198                 :            :         }
    1199                 :            : 
    1200         [ +  - ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1201         [ +  - ]:          1 :                         && check_auth_capabilities_supported(auths,
    1202                 :            :                         RTE_DIM(auths)) != 0) {
    1203                 :          1 :                 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
    1204                 :            :                                 "testsuite not met\n");
    1205                 :          1 :                 return TEST_SKIPPED;
    1206                 :            :         }
    1207                 :            : 
    1208                 :            :         return 0;
    1209                 :            : }
    1210                 :            : 
    1211                 :            : static int
    1212                 :          1 : hmac_md5_auth_testsuite_setup(void)
    1213                 :            : {
    1214                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1215                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1216                 :            :         struct rte_cryptodev_info dev_info;
    1217                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1218                 :            :                 RTE_CRYPTO_AUTH_MD5_HMAC
    1219                 :            :         };
    1220                 :            : 
    1221                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1222                 :            : 
    1223         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1224         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1225         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1226                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
    1227                 :            :                                 "Auth testsuite not met\n");
    1228                 :          0 :                 return TEST_SKIPPED;
    1229                 :            :         }
    1230                 :            : 
    1231         [ -  + ]:          1 :         if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
    1232                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
    1233                 :            :                                 "testsuite not met\n");
    1234                 :          0 :                 return TEST_SKIPPED;
    1235                 :            :         }
    1236                 :            : 
    1237                 :            :         return 0;
    1238                 :            : }
    1239                 :            : 
    1240                 :            : static int
    1241                 :          1 : kasumi_testsuite_setup(void)
    1242                 :            : {
    1243                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1244                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1245                 :            :         struct rte_cryptodev_info dev_info;
    1246                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1247                 :            :                 RTE_CRYPTO_CIPHER_KASUMI_F8
    1248                 :            :         };
    1249                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1250                 :            :                 RTE_CRYPTO_AUTH_KASUMI_F9
    1251                 :            :         };
    1252                 :            : 
    1253                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1254                 :            : 
    1255         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1256         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1257         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1258                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
    1259                 :            :                                 "testsuite not met\n");
    1260                 :          0 :                 return TEST_SKIPPED;
    1261                 :            :         }
    1262                 :            : 
    1263         [ +  - ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1264         [ +  - ]:          1 :                         && check_auth_capabilities_supported(auths,
    1265                 :            :                         RTE_DIM(auths)) != 0) {
    1266                 :          1 :                 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
    1267                 :            :                                 "testsuite not met\n");
    1268                 :          1 :                 return TEST_SKIPPED;
    1269                 :            :         }
    1270                 :            : 
    1271                 :            :         return 0;
    1272                 :            : }
    1273                 :            : 
    1274                 :            : static int
    1275                 :          1 : negative_aes_gcm_testsuite_setup(void)
    1276                 :            : {
    1277                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1278                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1279                 :            :         struct rte_cryptodev_info dev_info;
    1280                 :          1 :         const enum rte_crypto_aead_algorithm aeads[] = {
    1281                 :            :                 RTE_CRYPTO_AEAD_AES_GCM
    1282                 :            :         };
    1283                 :            : 
    1284                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1285                 :            : 
    1286         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1287         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1288         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1289                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
    1290                 :            :                                 "AES GCM testsuite not met\n");
    1291                 :          0 :                 return TEST_SKIPPED;
    1292                 :            :         }
    1293                 :            : 
    1294         [ -  + ]:          1 :         if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
    1295                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
    1296                 :            :                                 "AES GCM testsuite not met\n");
    1297                 :          0 :                 return TEST_SKIPPED;
    1298                 :            :         }
    1299                 :            : 
    1300                 :            :         return 0;
    1301                 :            : }
    1302                 :            : 
    1303                 :            : static int
    1304                 :          1 : negative_aes_gmac_testsuite_setup(void)
    1305                 :            : {
    1306                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1307                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1308                 :            :         struct rte_cryptodev_info dev_info;
    1309                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1310                 :            :                 RTE_CRYPTO_AUTH_AES_GMAC
    1311                 :            :         };
    1312                 :            : 
    1313                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1314                 :            : 
    1315         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1316         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1317         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1318                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
    1319                 :            :                                 "AES GMAC testsuite not met\n");
    1320                 :          0 :                 return TEST_SKIPPED;
    1321                 :            :         }
    1322                 :            : 
    1323         [ -  + ]:          1 :         if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
    1324                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
    1325                 :            :                                 "AES GMAC testsuite not met\n");
    1326                 :          0 :                 return TEST_SKIPPED;
    1327                 :            :         }
    1328                 :            : 
    1329                 :            :         return 0;
    1330                 :            : }
    1331                 :            : 
    1332                 :            : static int
    1333                 :          1 : mixed_cipher_hash_testsuite_setup(void)
    1334                 :            : {
    1335                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1336                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1337                 :            :         struct rte_cryptodev_info dev_info;
    1338                 :            :         uint64_t feat_flags;
    1339                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1340                 :            :                 RTE_CRYPTO_CIPHER_NULL,
    1341                 :            :                 RTE_CRYPTO_CIPHER_AES_CTR,
    1342                 :            :                 RTE_CRYPTO_CIPHER_ZUC_EEA3,
    1343                 :            :                 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
    1344                 :            :         };
    1345                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1346                 :            :                 RTE_CRYPTO_AUTH_NULL,
    1347                 :            :                 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
    1348                 :            :                 RTE_CRYPTO_AUTH_AES_CMAC,
    1349                 :            :                 RTE_CRYPTO_AUTH_ZUC_EIA3
    1350                 :            :         };
    1351                 :            : 
    1352                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1353                 :          1 :         feat_flags = dev_info.feature_flags;
    1354                 :            : 
    1355         [ +  - ]:          1 :         if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1356         [ -  + ]:          1 :                         (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
    1357                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
    1358                 :            :                                 "Cipher Hash testsuite not met\n");
    1359                 :          0 :                 return TEST_SKIPPED;
    1360                 :            :         }
    1361                 :            : 
    1362         [ -  + ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1363         [ #  # ]:          0 :                         && check_auth_capabilities_supported(auths,
    1364                 :            :                         RTE_DIM(auths)) != 0) {
    1365                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
    1366                 :            :                                 "Cipher Hash testsuite not met\n");
    1367                 :          0 :                 return TEST_SKIPPED;
    1368                 :            :         }
    1369                 :            : 
    1370                 :            :         return 0;
    1371                 :            : }
    1372                 :            : 
    1373                 :            : static int
    1374                 :          1 : esn_testsuite_setup(void)
    1375                 :            : {
    1376                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1377                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1378                 :            :         struct rte_cryptodev_info dev_info;
    1379                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1380                 :            :                 RTE_CRYPTO_CIPHER_AES_CBC
    1381                 :            :         };
    1382                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1383                 :            :                 RTE_CRYPTO_AUTH_SHA1_HMAC
    1384                 :            :         };
    1385                 :            : 
    1386                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1387                 :            : 
    1388         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1389         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1390         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1391                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
    1392                 :            :                                 "testsuite not met\n");
    1393                 :          0 :                 return TEST_SKIPPED;
    1394                 :            :         }
    1395                 :            : 
    1396         [ -  + ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1397         [ #  # ]:          0 :                         && check_auth_capabilities_supported(auths,
    1398                 :            :                         RTE_DIM(auths)) != 0) {
    1399                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
    1400                 :            :                                 "testsuite not met\n");
    1401                 :          0 :                 return TEST_SKIPPED;
    1402                 :            :         }
    1403                 :            : 
    1404                 :            :         return 0;
    1405                 :            : }
    1406                 :            : 
    1407                 :            : static int
    1408                 :          1 : multi_session_testsuite_setup(void)
    1409                 :            : {
    1410                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1411                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1412                 :            :         struct rte_cryptodev_info dev_info;
    1413                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1414                 :            :                 RTE_CRYPTO_CIPHER_AES_CBC
    1415                 :            :         };
    1416                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1417                 :            :                 RTE_CRYPTO_AUTH_SHA512_HMAC
    1418                 :            :         };
    1419                 :            : 
    1420                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1421                 :            : 
    1422         [ -  + ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
    1423                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
    1424                 :            :                                 "Session testsuite not met\n");
    1425                 :          0 :                 return TEST_SKIPPED;
    1426                 :            :         }
    1427                 :            : 
    1428         [ -  + ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1429         [ #  # ]:          0 :                         && check_auth_capabilities_supported(auths,
    1430                 :            :                         RTE_DIM(auths)) != 0) {
    1431                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
    1432                 :            :                                 "Session testsuite not met\n");
    1433                 :          0 :                 return TEST_SKIPPED;
    1434                 :            :         }
    1435                 :            : 
    1436                 :            :         return 0;
    1437                 :            : }
    1438                 :            : 
    1439                 :            : static int
    1440                 :          1 : negative_hmac_sha1_testsuite_setup(void)
    1441                 :            : {
    1442                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1443                 :          1 :         uint8_t dev_id = ts_params->valid_devs[0];
    1444                 :            :         struct rte_cryptodev_info dev_info;
    1445                 :          1 :         const enum rte_crypto_cipher_algorithm ciphers[] = {
    1446                 :            :                 RTE_CRYPTO_CIPHER_AES_CBC
    1447                 :            :         };
    1448                 :          1 :         const enum rte_crypto_auth_algorithm auths[] = {
    1449                 :            :                 RTE_CRYPTO_AUTH_SHA1_HMAC
    1450                 :            :         };
    1451                 :            : 
    1452                 :          1 :         rte_cryptodev_info_get(dev_id, &dev_info);
    1453                 :            : 
    1454         [ +  - ]:          1 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
    1455         [ -  + ]:          1 :                         ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    1456         [ #  # ]:          0 :                         !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    1457                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
    1458                 :            :                                 "HMAC SHA1 testsuite not met\n");
    1459                 :          0 :                 return TEST_SKIPPED;
    1460                 :            :         }
    1461                 :            : 
    1462         [ -  + ]:          1 :         if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
    1463         [ #  # ]:          0 :                         && check_auth_capabilities_supported(auths,
    1464                 :            :                         RTE_DIM(auths)) != 0) {
    1465                 :          0 :                 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
    1466                 :            :                                 "HMAC SHA1 testsuite not met\n");
    1467                 :          0 :                 return TEST_SKIPPED;
    1468                 :            :         }
    1469                 :            : 
    1470                 :            :         return 0;
    1471                 :            : }
    1472                 :            : 
    1473                 :            : static int
    1474                 :        432 : dev_configure_and_start(uint64_t ff_disable)
    1475                 :            : {
    1476                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1477                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    1478                 :            : 
    1479                 :            :         uint16_t qp_id;
    1480                 :            : 
    1481                 :            :         /* Clear unit test parameters before running test */
    1482                 :            :         memset(ut_params, 0, sizeof(*ut_params));
    1483                 :            : 
    1484                 :            :         /* Reconfigure device to default parameters */
    1485                 :        432 :         ts_params->conf.socket_id = SOCKET_ID_ANY;
    1486                 :        432 :         ts_params->conf.ff_disable = ff_disable;
    1487                 :        432 :         ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
    1488                 :        432 :         ts_params->qp_conf.mp_session = ts_params->session_mpool;
    1489                 :            : 
    1490         [ -  + ]:        432 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
    1491                 :            :                         &ts_params->conf),
    1492                 :            :                         "Failed to configure cryptodev %u",
    1493                 :            :                         ts_params->valid_devs[0]);
    1494                 :            : 
    1495         [ +  + ]:       3888 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
    1496         [ -  + ]:       3456 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
    1497                 :            :                         ts_params->valid_devs[0], qp_id,
    1498                 :            :                         &ts_params->qp_conf,
    1499                 :            :                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
    1500                 :            :                         "Failed to setup queue pair %u on cryptodev %u",
    1501                 :            :                         qp_id, ts_params->valid_devs[0]);
    1502                 :            :         }
    1503                 :            : 
    1504                 :            : 
    1505                 :        432 :         rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
    1506                 :            : 
    1507                 :            :         /* Start the device */
    1508         [ -  + ]:        432 :         TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
    1509                 :            :                         "Failed to start cryptodev %u",
    1510                 :            :                         ts_params->valid_devs[0]);
    1511                 :            : 
    1512                 :            :         return TEST_SUCCESS;
    1513                 :            : }
    1514                 :            : 
    1515                 :            : int
    1516                 :        432 : ut_setup(void)
    1517                 :            : {
    1518                 :            :         /* Configure and start the device with security feature disabled */
    1519                 :        432 :         return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
    1520                 :            : }
    1521                 :            : 
    1522                 :            : static int
    1523                 :          0 : ut_setup_security(void)
    1524                 :            : {
    1525                 :            :         /* Configure and start the device with no features disabled */
    1526                 :          0 :         return dev_configure_and_start(0);
    1527                 :            : }
    1528                 :            : 
    1529                 :            : static int
    1530                 :          0 : ut_setup_security_rx_inject(void)
    1531                 :            : {
    1532                 :          0 :         struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
    1533                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1534                 :          0 :         struct rte_eth_conf port_conf = {
    1535                 :            :                 .rxmode = {
    1536                 :            :                         .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
    1537                 :            :                                     RTE_ETH_RX_OFFLOAD_SECURITY,
    1538                 :            :                 },
    1539                 :            :                 .txmode = {
    1540                 :            :                         .offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
    1541                 :            :                 },
    1542                 :            :                 .lpbk_mode = 1,  /* Enable loopback */
    1543                 :            :         };
    1544                 :            :         struct rte_cryptodev_info dev_info;
    1545                 :          0 :         struct rte_eth_rxconf rx_conf = {
    1546                 :            :                 .rx_thresh = {
    1547                 :            :                         .pthresh = 8,
    1548                 :            :                         .hthresh = 8,
    1549                 :            :                         .wthresh = 8,
    1550                 :            :                 },
    1551                 :            :                 .rx_free_thresh = 32,
    1552                 :            :         };
    1553                 :            :         uint16_t nb_ports;
    1554                 :            :         void *sec_ctx;
    1555                 :            :         int ret;
    1556                 :            : 
    1557                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    1558         [ #  # ]:          0 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
    1559                 :            :             !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
    1560                 :          0 :                 RTE_LOG(INFO, USER1,
    1561                 :            :                         "Feature requirements for IPsec Rx inject test case not met\n");
    1562                 :          0 :                 return TEST_SKIPPED;
    1563                 :            :         }
    1564                 :            : 
    1565                 :          0 :         sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
    1566         [ #  # ]:          0 :         if (sec_ctx == NULL)
    1567                 :            :                 return TEST_SKIPPED;
    1568                 :            : 
    1569                 :          0 :         nb_ports = rte_eth_dev_count_avail();
    1570         [ #  # ]:          0 :         if (nb_ports == 0)
    1571                 :            :                 return TEST_SKIPPED;
    1572                 :            : 
    1573                 :          0 :         ret = rte_eth_dev_configure(0 /* port_id */,
    1574                 :            :                                     1 /* nb_rx_queue */,
    1575                 :            :                                     0 /* nb_tx_queue */,
    1576                 :            :                                     &port_conf);
    1577         [ #  # ]:          0 :         if (ret) {
    1578                 :            :                 printf("Could not configure ethdev port 0 [err=%d]\n", ret);
    1579                 :          0 :                 return TEST_SKIPPED;
    1580                 :            :         }
    1581                 :            : 
    1582                 :            :         /* Rx queue setup */
    1583                 :          0 :         ret = rte_eth_rx_queue_setup(0 /* port_id */,
    1584                 :            :                                      0 /* rx_queue_id */,
    1585                 :            :                                      1024 /* nb_rx_desc */,
    1586                 :            :                                      SOCKET_ID_ANY,
    1587                 :            :                                      &rx_conf,
    1588                 :            :                                      mbuf_pool);
    1589         [ #  # ]:          0 :         if (ret) {
    1590                 :            :                 printf("Could not setup eth port 0 queue 0\n");
    1591                 :          0 :                 return TEST_SKIPPED;
    1592                 :            :         }
    1593                 :            : 
    1594                 :          0 :         ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
    1595         [ #  # ]:          0 :         if (ret) {
    1596                 :            :                 printf("Could not enable Rx inject offload");
    1597                 :          0 :                 return TEST_SKIPPED;
    1598                 :            :         }
    1599                 :            : 
    1600                 :          0 :         ret = rte_eth_dev_start(0);
    1601         [ #  # ]:          0 :         if (ret) {
    1602                 :            :                 printf("Could not start ethdev");
    1603                 :          0 :                 return TEST_SKIPPED;
    1604                 :            :         }
    1605                 :            : 
    1606                 :          0 :         ret = rte_eth_promiscuous_enable(0);
    1607         [ #  # ]:          0 :         if (ret) {
    1608                 :            :                 printf("Could not enable promiscuous mode");
    1609                 :          0 :                 return TEST_SKIPPED;
    1610                 :            :         }
    1611                 :            : 
    1612                 :            :         /* Configure and start cryptodev with no features disabled */
    1613                 :          0 :         return dev_configure_and_start(0);
    1614                 :            : }
    1615                 :            : 
    1616                 :            : static inline void
    1617                 :          0 : ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
    1618                 :            : {
    1619                 :          0 : }
    1620                 :            : 
    1621                 :            : static inline void
    1622                 :        108 : ext_mbuf_memzone_free(int nb_segs)
    1623                 :            : {
    1624                 :            :         int i;
    1625                 :            : 
    1626         [ +  + ]:        324 :         for (i = 0; i <= nb_segs; i++) {
    1627                 :            :                 char mz_name[RTE_MEMZONE_NAMESIZE];
    1628                 :            :                 const struct rte_memzone *memzone;
    1629                 :            :                 snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
    1630                 :        216 :                 memzone = rte_memzone_lookup(mz_name);
    1631         [ +  + ]:        216 :                 if (memzone != NULL) {
    1632                 :          2 :                         rte_memzone_free(memzone);
    1633                 :            :                         memzone = NULL;
    1634                 :            :                 }
    1635                 :            :         }
    1636                 :        108 : }
    1637                 :            : 
    1638                 :            : static inline struct rte_mbuf *
    1639                 :          2 : ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
    1640                 :            :                 int nb_segs, const void *input_text)
    1641                 :            : {
    1642                 :            :         struct rte_mbuf *m = NULL, *mbuf = NULL;
    1643                 :            :         size_t data_off = 0;
    1644                 :            :         uint8_t *dst;
    1645                 :            :         int i, size;
    1646                 :            :         int t_len;
    1647                 :            : 
    1648         [ -  + ]:          2 :         if (pkt_len < 1) {
    1649                 :            :                 printf("Packet size must be 1 or more (is %d)\n", pkt_len);
    1650                 :          0 :                 return NULL;
    1651                 :            :         }
    1652                 :            : 
    1653         [ -  + ]:          2 :         if (nb_segs < 1) {
    1654                 :            :                 printf("Number of segments must be 1 or more (is %d)\n",
    1655                 :            :                                 nb_segs);
    1656                 :          0 :                 return NULL;
    1657                 :            :         }
    1658                 :            : 
    1659         [ +  - ]:          2 :         t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
    1660                 :            :         size = pkt_len;
    1661                 :            : 
    1662                 :            :         /* Create chained mbuf_src with external buffer */
    1663         [ +  + ]:          4 :         for (i = 0; size > 0; i++) {
    1664                 :            :                 struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
    1665                 :          2 :                 uint16_t data_len = RTE_MIN(size, t_len);
    1666                 :            :                 char mz_name[RTE_MEMZONE_NAMESIZE];
    1667                 :            :                 const struct rte_memzone *memzone;
    1668                 :            :                 void *ext_buf_addr = NULL;
    1669                 :            :                 rte_iova_t buf_iova;
    1670                 :          2 :                 bool freed = false;
    1671                 :            :                 uint16_t buf_len;
    1672                 :            : 
    1673                 :          2 :                 buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
    1674                 :            :                         sizeof(struct rte_mbuf_ext_shared_info), 8);
    1675                 :            : 
    1676                 :            :                 snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
    1677                 :          2 :                 memzone = rte_memzone_lookup(mz_name);
    1678   [ -  +  -  - ]:          2 :                 if (memzone != NULL && memzone->len != buf_len) {
    1679                 :          0 :                         rte_memzone_free(memzone);
    1680                 :            :                         memzone = NULL;
    1681                 :            :                 }
    1682         [ +  - ]:          2 :                 if (memzone == NULL) {
    1683                 :          2 :                         memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
    1684                 :            :                                 RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
    1685         [ -  + ]:          2 :                         if (memzone == NULL) {
    1686                 :            :                                 printf("Can't allocate memory zone %s\n", mz_name);
    1687                 :          0 :                                 return NULL;
    1688                 :            :                         }
    1689                 :            :                 }
    1690                 :            : 
    1691                 :          2 :                 ext_buf_addr = memzone->addr;
    1692         [ -  + ]:          2 :                 if (input_text)
    1693                 :          0 :                         memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
    1694                 :            : 
    1695                 :            :                 /* Create buffer to hold rte_mbuf header */
    1696                 :          2 :                 m = rte_pktmbuf_alloc(mbuf_pool);
    1697         [ +  - ]:          2 :                 if (i == 0)
    1698                 :            :                         mbuf = m;
    1699                 :            : 
    1700         [ -  + ]:          2 :                 if (m == NULL) {
    1701                 :            :                         printf("Cannot create segment for source mbuf");
    1702                 :          0 :                         goto fail;
    1703                 :            :                 }
    1704                 :            : 
    1705                 :            :                 /* Save shared data (like callback function) in external buffer's end */
    1706                 :            :                 ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
    1707                 :            :                         ext_mbuf_callback_fn_free, &freed);
    1708                 :            :                 if (ret_shinfo == NULL) {
    1709                 :            :                         printf("Shared mem initialization failed!\n");
    1710                 :          0 :                         goto fail;
    1711                 :            :                 }
    1712                 :            : 
    1713                 :          2 :                 buf_iova = rte_mem_virt2iova(ext_buf_addr);
    1714                 :            : 
    1715                 :            :                 /* Attach external buffer to mbuf */
    1716                 :            :                 rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
    1717                 :            :                         ret_shinfo);
    1718         [ -  + ]:          2 :                 if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
    1719                 :            :                         printf("External buffer is not attached to mbuf\n");
    1720                 :          0 :                         goto fail;
    1721                 :            :                 }
    1722                 :            : 
    1723         [ -  + ]:          2 :                 if (input_text) {
    1724                 :            :                         dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
    1725         [ #  # ]:          0 :                         if (dst == NULL) {
    1726                 :            :                                 printf("Cannot append %d bytes to the mbuf\n", data_len);
    1727                 :          0 :                                 goto fail;
    1728                 :            :                         }
    1729                 :            :                 }
    1730                 :            : 
    1731         [ -  + ]:          2 :                 if (mbuf != m)
    1732                 :            :                         rte_pktmbuf_chain(mbuf, m);
    1733                 :            : 
    1734                 :          2 :                 size -= data_len;
    1735                 :          2 :                 data_off += data_len;
    1736                 :            :         }
    1737                 :            : 
    1738                 :            :         return mbuf;
    1739                 :            : 
    1740                 :            : fail:
    1741                 :          0 :         rte_pktmbuf_free(mbuf);
    1742                 :          0 :         ext_mbuf_memzone_free(nb_segs);
    1743                 :          0 :         return NULL;
    1744                 :            : }
    1745                 :            : 
    1746                 :            : void
    1747                 :        432 : ut_teardown(void)
    1748                 :            : {
    1749                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1750                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    1751                 :            : 
    1752                 :            :         /* free crypto session structure */
    1753                 :            : #ifdef RTE_LIB_SECURITY
    1754         [ -  + ]:        432 :         if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
    1755         [ #  # ]:          0 :                 if (ut_params->sec_session) {
    1756                 :          0 :                         rte_security_session_destroy(rte_cryptodev_get_sec_ctx
    1757                 :          0 :                                                 (ts_params->valid_devs[0]),
    1758                 :            :                                                 ut_params->sec_session);
    1759                 :          0 :                         ut_params->sec_session = NULL;
    1760                 :            :                 }
    1761                 :            :         } else
    1762                 :            : #endif
    1763                 :            :         {
    1764         [ +  + ]:        432 :                 if (ut_params->sess) {
    1765                 :        109 :                         rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
    1766                 :            :                                         ut_params->sess);
    1767                 :        109 :                         ut_params->sess = NULL;
    1768                 :            :                 }
    1769                 :            :         }
    1770                 :            : 
    1771                 :            :         /* free crypto operation structure */
    1772                 :        432 :         rte_crypto_op_free(ut_params->op);
    1773                 :            : 
    1774                 :            :         /*
    1775                 :            :          * free mbuf - both obuf and ibuf are usually the same,
    1776                 :            :          * so check if they point at the same address is necessary,
    1777                 :            :          * to avoid freeing the mbuf twice.
    1778                 :            :          */
    1779         [ +  + ]:        432 :         if (ut_params->obuf) {
    1780                 :          6 :                 rte_pktmbuf_free(ut_params->obuf);
    1781         [ +  + ]:          6 :                 if (ut_params->ibuf == ut_params->obuf)
    1782                 :          3 :                         ut_params->ibuf = 0;
    1783                 :          6 :                 ut_params->obuf = 0;
    1784                 :            :         }
    1785         [ +  + ]:        432 :         if (ut_params->ibuf) {
    1786                 :        108 :                 ext_mbuf_memzone_free(1);
    1787                 :        108 :                 rte_pktmbuf_free(ut_params->ibuf);
    1788                 :        108 :                 ut_params->ibuf = 0;
    1789                 :            :         }
    1790                 :            : 
    1791         [ +  - ]:        432 :         if (ts_params->mbuf_pool != NULL)
    1792                 :        432 :                 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
    1793                 :            :                         rte_mempool_avail_count(ts_params->mbuf_pool));
    1794                 :            : 
    1795                 :            :         /* Stop the device */
    1796                 :        432 :         rte_cryptodev_stop(ts_params->valid_devs[0]);
    1797                 :        432 : }
    1798                 :            : 
    1799                 :            : static void
    1800                 :          0 : ut_teardown_rx_inject(void)
    1801                 :            : {
    1802                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1803                 :            :         void *sec_ctx;
    1804                 :            :         int ret;
    1805                 :            : 
    1806         [ #  # ]:          0 :         if  (rte_eth_dev_count_avail() != 0) {
    1807                 :          0 :                 ret = rte_eth_dev_reset(0);
    1808         [ #  # ]:          0 :                 if (ret)
    1809                 :            :                         printf("Could not reset eth port 0");
    1810                 :            : 
    1811                 :            :         }
    1812                 :            : 
    1813                 :          0 :         ut_teardown();
    1814                 :            : 
    1815                 :          0 :         sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
    1816         [ #  # ]:          0 :         if (sec_ctx == NULL)
    1817                 :            :                 return;
    1818                 :            : 
    1819                 :          0 :         ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
    1820         [ #  # ]:          0 :         if (ret) {
    1821                 :            :                 printf("Could not disable Rx inject offload");
    1822                 :          0 :                 return;
    1823                 :            :         }
    1824                 :            : }
    1825                 :            : 
    1826                 :            : static int
    1827                 :          1 : test_device_configure_invalid_dev_id(void)
    1828                 :            : {
    1829                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1830                 :            :         uint16_t dev_id, num_devs = 0;
    1831                 :            : 
    1832         [ -  + ]:          1 :         TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
    1833                 :            :                         "Need at least %d devices for test", 1);
    1834                 :            : 
    1835                 :            :         /* valid dev_id values */
    1836                 :          1 :         dev_id = ts_params->valid_devs[0];
    1837                 :            : 
    1838                 :            :         /* Stop the device in case it's started so it can be configured */
    1839                 :          1 :         rte_cryptodev_stop(dev_id);
    1840                 :            : 
    1841         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
    1842                 :            :                         "Failed test for rte_cryptodev_configure: "
    1843                 :            :                         "invalid dev_num %u", dev_id);
    1844                 :            : 
    1845                 :            :         /* invalid dev_id values */
    1846                 :            :         dev_id = num_devs;
    1847                 :            : 
    1848         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
    1849                 :            :                         "Failed test for rte_cryptodev_configure: "
    1850                 :            :                         "invalid dev_num %u", dev_id);
    1851                 :            : 
    1852                 :            :         dev_id = 0xff;
    1853                 :            : 
    1854         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
    1855                 :            :                         "Failed test for rte_cryptodev_configure:"
    1856                 :            :                         "invalid dev_num %u", dev_id);
    1857                 :            : 
    1858                 :            :         return TEST_SUCCESS;
    1859                 :            : }
    1860                 :            : 
    1861                 :            : static int
    1862                 :          1 : test_device_configure_invalid_queue_pair_ids(void)
    1863                 :            : {
    1864                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1865                 :          1 :         uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
    1866                 :            : 
    1867                 :            :         /* Stop the device in case it's started so it can be configured */
    1868                 :          1 :         rte_cryptodev_stop(ts_params->valid_devs[0]);
    1869                 :            : 
    1870                 :            :         /* valid - max value queue pairs */
    1871                 :          1 :         ts_params->conf.nb_queue_pairs = orig_nb_qps;
    1872                 :            : 
    1873         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
    1874                 :            :                         &ts_params->conf),
    1875                 :            :                         "Failed to configure cryptodev: dev_id %u, qp_id %u",
    1876                 :            :                         ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
    1877                 :            : 
    1878                 :            :         /* valid - one queue pairs */
    1879                 :          1 :         ts_params->conf.nb_queue_pairs = 1;
    1880                 :            : 
    1881         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
    1882                 :            :                         &ts_params->conf),
    1883                 :            :                         "Failed to configure cryptodev: dev_id %u, qp_id %u",
    1884                 :            :                         ts_params->valid_devs[0],
    1885                 :            :                         ts_params->conf.nb_queue_pairs);
    1886                 :            : 
    1887                 :            : 
    1888                 :            :         /* invalid - zero queue pairs */
    1889                 :          1 :         ts_params->conf.nb_queue_pairs = 0;
    1890                 :            : 
    1891         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
    1892                 :            :                         &ts_params->conf),
    1893                 :            :                         "Failed test for rte_cryptodev_configure, dev_id %u,"
    1894                 :            :                         " invalid qps: %u",
    1895                 :            :                         ts_params->valid_devs[0],
    1896                 :            :                         ts_params->conf.nb_queue_pairs);
    1897                 :            : 
    1898                 :            : 
    1899                 :            :         /* invalid - max value supported by field queue pairs */
    1900                 :          1 :         ts_params->conf.nb_queue_pairs = UINT16_MAX;
    1901                 :            : 
    1902         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
    1903                 :            :                         &ts_params->conf),
    1904                 :            :                         "Failed test for rte_cryptodev_configure, dev_id %u,"
    1905                 :            :                         " invalid qps: %u",
    1906                 :            :                         ts_params->valid_devs[0],
    1907                 :            :                         ts_params->conf.nb_queue_pairs);
    1908                 :            : 
    1909                 :            : 
    1910                 :            :         /* invalid - max value + 1 queue pairs */
    1911                 :          1 :         ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
    1912                 :            : 
    1913         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
    1914                 :            :                         &ts_params->conf),
    1915                 :            :                         "Failed test for rte_cryptodev_configure, dev_id %u,"
    1916                 :            :                         " invalid qps: %u",
    1917                 :            :                         ts_params->valid_devs[0],
    1918                 :            :                         ts_params->conf.nb_queue_pairs);
    1919                 :            : 
    1920                 :            :         /* revert to original testsuite value */
    1921                 :          1 :         ts_params->conf.nb_queue_pairs = orig_nb_qps;
    1922                 :            : 
    1923                 :          1 :         return TEST_SUCCESS;
    1924                 :            : }
    1925                 :            : 
    1926                 :            : static int
    1927                 :          1 : test_queue_pair_descriptor_setup(void)
    1928                 :            : {
    1929                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    1930                 :          1 :         struct rte_cryptodev_qp_conf qp_conf = {
    1931                 :            :                 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
    1932                 :            :         };
    1933                 :            :         uint16_t qp_id;
    1934                 :            : 
    1935                 :            :         /* Stop the device in case it's started so it can be configured */
    1936                 :          1 :         rte_cryptodev_stop(ts_params->valid_devs[0]);
    1937                 :            : 
    1938         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
    1939                 :            :                         &ts_params->conf),
    1940                 :            :                         "Failed to configure cryptodev %u",
    1941                 :            :                         ts_params->valid_devs[0]);
    1942                 :            : 
    1943                 :            :         /*
    1944                 :            :          * Test various ring sizes on this device. memzones can't be
    1945                 :            :          * freed so are re-used if ring is released and re-created.
    1946                 :            :          */
    1947                 :          1 :         qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
    1948                 :          1 :         qp_conf.mp_session = ts_params->session_mpool;
    1949                 :            : 
    1950         [ +  + ]:          9 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
    1951         [ -  + ]:          8 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
    1952                 :            :                                 ts_params->valid_devs[0], qp_id, &qp_conf,
    1953                 :            :                                 rte_cryptodev_socket_id(
    1954                 :            :                                                 ts_params->valid_devs[0])),
    1955                 :            :                                 "Failed test for "
    1956                 :            :                                 "rte_cryptodev_queue_pair_setup: num_inflights "
    1957                 :            :                                 "%u on qp %u on cryptodev %u",
    1958                 :            :                                 qp_conf.nb_descriptors, qp_id,
    1959                 :            :                                 ts_params->valid_devs[0]);
    1960                 :            :         }
    1961                 :            : 
    1962                 :          1 :         qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
    1963                 :            : 
    1964         [ +  + ]:          9 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
    1965         [ -  + ]:          8 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
    1966                 :            :                                 ts_params->valid_devs[0], qp_id, &qp_conf,
    1967                 :            :                                 rte_cryptodev_socket_id(
    1968                 :            :                                                 ts_params->valid_devs[0])),
    1969                 :            :                                 "Failed test for"
    1970                 :            :                                 " rte_cryptodev_queue_pair_setup: num_inflights"
    1971                 :            :                                 " %u on qp %u on cryptodev %u",
    1972                 :            :                                 qp_conf.nb_descriptors, qp_id,
    1973                 :            :                                 ts_params->valid_devs[0]);
    1974                 :            :         }
    1975                 :            : 
    1976                 :          1 :         qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
    1977                 :            : 
    1978         [ +  + ]:          9 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
    1979         [ -  + ]:          8 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
    1980                 :            :                                 ts_params->valid_devs[0], qp_id, &qp_conf,
    1981                 :            :                                 rte_cryptodev_socket_id(
    1982                 :            :                                                 ts_params->valid_devs[0])),
    1983                 :            :                                 "Failed test for "
    1984                 :            :                                 "rte_cryptodev_queue_pair_setup: num_inflights"
    1985                 :            :                                 " %u on qp %u on cryptodev %u",
    1986                 :            :                                 qp_conf.nb_descriptors, qp_id,
    1987                 :            :                                 ts_params->valid_devs[0]);
    1988                 :            :         }
    1989                 :            : 
    1990                 :          1 :         qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
    1991                 :            : 
    1992         [ +  + ]:          9 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
    1993         [ -  + ]:          8 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
    1994                 :            :                                 ts_params->valid_devs[0], qp_id, &qp_conf,
    1995                 :            :                                 rte_cryptodev_socket_id(
    1996                 :            :                                                 ts_params->valid_devs[0])),
    1997                 :            :                                 "Failed test for"
    1998                 :            :                                 " rte_cryptodev_queue_pair_setup:"
    1999                 :            :                                 "num_inflights %u on qp %u on cryptodev %u",
    2000                 :            :                                 qp_conf.nb_descriptors, qp_id,
    2001                 :            :                                 ts_params->valid_devs[0]);
    2002                 :            :         }
    2003                 :            : 
    2004                 :            :         /* test invalid queue pair id */
    2005                 :          1 :         qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;      /*valid */
    2006                 :            : 
    2007                 :            :         qp_id = ts_params->conf.nb_queue_pairs;              /*invalid */
    2008                 :            : 
    2009         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
    2010                 :            :                         ts_params->valid_devs[0],
    2011                 :            :                         qp_id, &qp_conf,
    2012                 :            :                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
    2013                 :            :                         "Failed test for rte_cryptodev_queue_pair_setup:"
    2014                 :            :                         "invalid qp %u on cryptodev %u",
    2015                 :            :                         qp_id, ts_params->valid_devs[0]);
    2016                 :            : 
    2017                 :            :         qp_id = 0xffff; /*invalid*/
    2018                 :            : 
    2019         [ -  + ]:          1 :         TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
    2020                 :            :                         ts_params->valid_devs[0],
    2021                 :            :                         qp_id, &qp_conf,
    2022                 :            :                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
    2023                 :            :                         "Failed test for rte_cryptodev_queue_pair_setup:"
    2024                 :            :                         "invalid qp %u on cryptodev %u",
    2025                 :            :                         qp_id, ts_params->valid_devs[0]);
    2026                 :            : 
    2027                 :            :         return TEST_SUCCESS;
    2028                 :            : }
    2029                 :            : 
    2030                 :            : /* ***** Plaintext data for tests ***** */
    2031                 :            : 
    2032                 :            : const char catch_22_quote_1[] =
    2033                 :            :                 "There was only one catch and that was Catch-22, which "
    2034                 :            :                 "specified that a concern for one's safety in the face of "
    2035                 :            :                 "dangers that were real and immediate was the process of a "
    2036                 :            :                 "rational mind. Orr was crazy and could be grounded. All he "
    2037                 :            :                 "had to do was ask; and as soon as he did, he would no longer "
    2038                 :            :                 "be crazy and would have to fly more missions. Orr would be "
    2039                 :            :                 "crazy to fly more missions and sane if he didn't, but if he "
    2040                 :            :                 "was sane he had to fly them. If he flew them he was crazy "
    2041                 :            :                 "and didn't have to; but if he didn't want to he was sane and "
    2042                 :            :                 "had to. Yossarian was moved very deeply by the absolute "
    2043                 :            :                 "simplicity of this clause of Catch-22 and let out a "
    2044                 :            :                 "respectful whistle. \"That's some catch, that Catch-22\", he "
    2045                 :            :                 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
    2046                 :            : 
    2047                 :            : const char catch_22_quote[] =
    2048                 :            :                 "What a lousy earth! He wondered how many people were "
    2049                 :            :                 "destitute that same night even in his own prosperous country, "
    2050                 :            :                 "how many homes were shanties, how many husbands were drunk "
    2051                 :            :                 "and wives socked, and how many children were bullied, abused, "
    2052                 :            :                 "or abandoned. How many families hungered for food they could "
    2053                 :            :                 "not afford to buy? How many hearts were broken? How many "
    2054                 :            :                 "suicides would take place that same night, how many people "
    2055                 :            :                 "would go insane? How many cockroaches and landlords would "
    2056                 :            :                 "triumph? How many winners were losers, successes failures, "
    2057                 :            :                 "and rich men poor men? How many wise guys were stupid? How "
    2058                 :            :                 "many happy endings were unhappy endings? How many honest men "
    2059                 :            :                 "were liars, brave men cowards, loyal men traitors, how many "
    2060                 :            :                 "sainted men were corrupt, how many people in positions of "
    2061                 :            :                 "trust had sold their souls to bodyguards, how many had never "
    2062                 :            :                 "had souls? How many straight-and-narrow paths were crooked "
    2063                 :            :                 "paths? How many best families were worst families and how "
    2064                 :            :                 "many good people were bad people? When you added them all up "
    2065                 :            :                 "and then subtracted, you might be left with only the children, "
    2066                 :            :                 "and perhaps with Albert Einstein and an old violinist or "
    2067                 :            :                 "sculptor somewhere.";
    2068                 :            : 
    2069                 :            : #define QUOTE_480_BYTES         (480)
    2070                 :            : #define QUOTE_512_BYTES         (512)
    2071                 :            : #define QUOTE_768_BYTES         (768)
    2072                 :            : #define QUOTE_1024_BYTES        (1024)
    2073                 :            : 
    2074                 :            : 
    2075                 :            : 
    2076                 :            : /* ***** SHA1 Hash Tests ***** */
    2077                 :            : 
    2078                 :            : #define HMAC_KEY_LENGTH_SHA1    (DIGEST_BYTE_LENGTH_SHA1)
    2079                 :            : 
    2080                 :            : static uint8_t hmac_sha1_key[] = {
    2081                 :            :         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
    2082                 :            :         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
    2083                 :            :         0xDE, 0xF4, 0xDE, 0xAD };
    2084                 :            : 
    2085                 :            : /* ***** SHA224 Hash Tests ***** */
    2086                 :            : 
    2087                 :            : #define HMAC_KEY_LENGTH_SHA224  (DIGEST_BYTE_LENGTH_SHA224)
    2088                 :            : 
    2089                 :            : 
    2090                 :            : /* ***** AES-CBC Cipher Tests ***** */
    2091                 :            : 
    2092                 :            : #define CIPHER_KEY_LENGTH_AES_CBC       (16)
    2093                 :            : #define CIPHER_IV_LENGTH_AES_CBC        (CIPHER_KEY_LENGTH_AES_CBC)
    2094                 :            : 
    2095                 :            : static uint8_t aes_cbc_key[] = {
    2096                 :            :         0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
    2097                 :            :         0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
    2098                 :            : 
    2099                 :            : static uint8_t aes_cbc_iv[] = {
    2100                 :            :         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    2101                 :            :         0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
    2102                 :            : 
    2103                 :            : 
    2104                 :            : /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
    2105                 :            : 
    2106                 :            : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
    2107                 :            :         0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
    2108                 :            :         0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
    2109                 :            :         0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
    2110                 :            :         0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
    2111                 :            :         0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
    2112                 :            :         0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
    2113                 :            :         0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
    2114                 :            :         0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
    2115                 :            :         0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
    2116                 :            :         0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
    2117                 :            :         0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
    2118                 :            :         0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
    2119                 :            :         0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
    2120                 :            :         0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
    2121                 :            :         0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
    2122                 :            :         0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
    2123                 :            :         0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
    2124                 :            :         0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
    2125                 :            :         0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
    2126                 :            :         0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
    2127                 :            :         0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
    2128                 :            :         0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
    2129                 :            :         0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
    2130                 :            :         0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
    2131                 :            :         0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
    2132                 :            :         0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
    2133                 :            :         0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
    2134                 :            :         0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
    2135                 :            :         0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
    2136                 :            :         0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
    2137                 :            :         0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
    2138                 :            :         0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
    2139                 :            :         0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
    2140                 :            :         0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
    2141                 :            :         0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
    2142                 :            :         0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
    2143                 :            :         0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
    2144                 :            :         0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
    2145                 :            :         0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
    2146                 :            :         0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
    2147                 :            :         0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
    2148                 :            :         0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
    2149                 :            :         0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
    2150                 :            :         0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
    2151                 :            :         0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
    2152                 :            :         0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
    2153                 :            :         0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
    2154                 :            :         0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
    2155                 :            :         0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
    2156                 :            :         0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
    2157                 :            :         0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
    2158                 :            :         0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
    2159                 :            :         0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
    2160                 :            :         0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
    2161                 :            :         0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
    2162                 :            :         0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
    2163                 :            :         0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
    2164                 :            :         0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
    2165                 :            :         0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
    2166                 :            :         0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
    2167                 :            :         0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
    2168                 :            :         0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
    2169                 :            :         0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
    2170                 :            :         0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
    2171                 :            : };
    2172                 :            : 
    2173                 :            : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
    2174                 :            :         0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
    2175                 :            :         0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
    2176                 :            :         0x18, 0x8c, 0x1d, 0x32
    2177                 :            : };
    2178                 :            : 
    2179                 :            : 
    2180                 :            : /* Multisession Vector context Test */
    2181                 :            : /*Begin Session 0 */
    2182                 :            : static uint8_t ms_aes_cbc_key0[] = {
    2183                 :            :         0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    2184                 :            :         0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
    2185                 :            : };
    2186                 :            : 
    2187                 :            : static uint8_t ms_aes_cbc_iv0[] = {
    2188                 :            :         0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    2189                 :            :         0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
    2190                 :            : };
    2191                 :            : 
    2192                 :            : static const uint8_t ms_aes_cbc_cipher0[] = {
    2193                 :            :                 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
    2194                 :            :                 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
    2195                 :            :                 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
    2196                 :            :                 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
    2197                 :            :                 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
    2198                 :            :                 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
    2199                 :            :                 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
    2200                 :            :                 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
    2201                 :            :                 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
    2202                 :            :                 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
    2203                 :            :                 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
    2204                 :            :                 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
    2205                 :            :                 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
    2206                 :            :                 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
    2207                 :            :                 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
    2208                 :            :                 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
    2209                 :            :                 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
    2210                 :            :                 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
    2211                 :            :                 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
    2212                 :            :                 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
    2213                 :            :                 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
    2214                 :            :                 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
    2215                 :            :                 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
    2216                 :            :                 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
    2217                 :            :                 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
    2218                 :            :                 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
    2219                 :            :                 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
    2220                 :            :                 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
    2221                 :            :                 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
    2222                 :            :                 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
    2223                 :            :                 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
    2224                 :            :                 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
    2225                 :            :                 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
    2226                 :            :                 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
    2227                 :            :                 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
    2228                 :            :                 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
    2229                 :            :                 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
    2230                 :            :                 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
    2231                 :            :                 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
    2232                 :            :                 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
    2233                 :            :                 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
    2234                 :            :                 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
    2235                 :            :                 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
    2236                 :            :                 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
    2237                 :            :                 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
    2238                 :            :                 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
    2239                 :            :                 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
    2240                 :            :                 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
    2241                 :            :                 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
    2242                 :            :                 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
    2243                 :            :                 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
    2244                 :            :                 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
    2245                 :            :                 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
    2246                 :            :                 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
    2247                 :            :                 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
    2248                 :            :                 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
    2249                 :            :                 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
    2250                 :            :                 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
    2251                 :            :                 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
    2252                 :            :                 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
    2253                 :            :                 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
    2254                 :            :                 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
    2255                 :            :                 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
    2256                 :            :                 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
    2257                 :            : };
    2258                 :            : 
    2259                 :            : 
    2260                 :            : static  uint8_t ms_hmac_key0[] = {
    2261                 :            :                 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
    2262                 :            :                 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
    2263                 :            :                 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
    2264                 :            :                 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
    2265                 :            :                 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
    2266                 :            :                 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
    2267                 :            :                 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
    2268                 :            :                 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
    2269                 :            : };
    2270                 :            : 
    2271                 :            : static const uint8_t ms_hmac_digest0[] = {
    2272                 :            :                 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
    2273                 :            :                 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
    2274                 :            :                 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
    2275                 :            :                 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
    2276                 :            :                 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
    2277                 :            :                 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
    2278                 :            :                 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
    2279                 :            :                 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
    2280                 :            :                 };
    2281                 :            : 
    2282                 :            : /* End Session 0 */
    2283                 :            : /* Begin session 1 */
    2284                 :            : 
    2285                 :            : static  uint8_t ms_aes_cbc_key1[] = {
    2286                 :            :                 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    2287                 :            :                 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
    2288                 :            : };
    2289                 :            : 
    2290                 :            : static  uint8_t ms_aes_cbc_iv1[] = {
    2291                 :            :         0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    2292                 :            :         0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
    2293                 :            : };
    2294                 :            : 
    2295                 :            : static const uint8_t ms_aes_cbc_cipher1[] = {
    2296                 :            :                 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
    2297                 :            :                 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
    2298                 :            :                 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
    2299                 :            :                 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
    2300                 :            :                 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
    2301                 :            :                 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
    2302                 :            :                 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
    2303                 :            :                 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
    2304                 :            :                 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
    2305                 :            :                 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
    2306                 :            :                 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
    2307                 :            :                 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
    2308                 :            :                 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
    2309                 :            :                 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
    2310                 :            :                 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
    2311                 :            :                 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
    2312                 :            :                 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
    2313                 :            :                 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
    2314                 :            :                 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
    2315                 :            :                 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
    2316                 :            :                 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
    2317                 :            :                 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
    2318                 :            :                 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
    2319                 :            :                 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
    2320                 :            :                 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
    2321                 :            :                 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
    2322                 :            :                 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
    2323                 :            :                 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
    2324                 :            :                 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
    2325                 :            :                 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
    2326                 :            :                 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
    2327                 :            :                 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
    2328                 :            :                 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
    2329                 :            :                 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
    2330                 :            :                 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
    2331                 :            :                 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
    2332                 :            :                 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
    2333                 :            :                 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
    2334                 :            :                 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
    2335                 :            :                 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
    2336                 :            :                 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
    2337                 :            :                 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
    2338                 :            :                 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
    2339                 :            :                 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
    2340                 :            :                 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
    2341                 :            :                 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
    2342                 :            :                 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
    2343                 :            :                 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
    2344                 :            :                 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
    2345                 :            :                 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
    2346                 :            :                 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
    2347                 :            :                 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
    2348                 :            :                 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
    2349                 :            :                 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
    2350                 :            :                 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
    2351                 :            :                 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
    2352                 :            :                 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
    2353                 :            :                 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
    2354                 :            :                 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
    2355                 :            :                 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
    2356                 :            :                 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
    2357                 :            :                 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
    2358                 :            :                 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
    2359                 :            :                 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
    2360                 :            : 
    2361                 :            : };
    2362                 :            : 
    2363                 :            : static uint8_t ms_hmac_key1[] = {
    2364                 :            :                 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
    2365                 :            :                 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
    2366                 :            :                 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
    2367                 :            :                 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
    2368                 :            :                 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
    2369                 :            :                 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
    2370                 :            :                 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
    2371                 :            :                 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
    2372                 :            : };
    2373                 :            : 
    2374                 :            : static const uint8_t ms_hmac_digest1[] = {
    2375                 :            :                 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
    2376                 :            :                 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
    2377                 :            :                 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
    2378                 :            :                 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
    2379                 :            :                 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
    2380                 :            :                 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
    2381                 :            :                 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
    2382                 :            :                 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
    2383                 :            : };
    2384                 :            : /* End Session 1  */
    2385                 :            : /* Begin Session 2 */
    2386                 :            : static  uint8_t ms_aes_cbc_key2[] = {
    2387                 :            :                 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    2388                 :            :                 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
    2389                 :            : };
    2390                 :            : 
    2391                 :            : static  uint8_t ms_aes_cbc_iv2[] = {
    2392                 :            :                 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    2393                 :            :                 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
    2394                 :            : };
    2395                 :            : 
    2396                 :            : static const uint8_t ms_aes_cbc_cipher2[] = {
    2397                 :            :                 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
    2398                 :            :                 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
    2399                 :            :                 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
    2400                 :            :                 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
    2401                 :            :                 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
    2402                 :            :                 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
    2403                 :            :                 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
    2404                 :            :                 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
    2405                 :            :                 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
    2406                 :            :                 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
    2407                 :            :                 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
    2408                 :            :                 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
    2409                 :            :                 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
    2410                 :            :                 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
    2411                 :            :                 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
    2412                 :            :                 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
    2413                 :            :                 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
    2414                 :            :                 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
    2415                 :            :                 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
    2416                 :            :                 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
    2417                 :            :                 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
    2418                 :            :                 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
    2419                 :            :                 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
    2420                 :            :                 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
    2421                 :            :                 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
    2422                 :            :                 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
    2423                 :            :                 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
    2424                 :            :                 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
    2425                 :            :                 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
    2426                 :            :                 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
    2427                 :            :                 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
    2428                 :            :                 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
    2429                 :            :                 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
    2430                 :            :                 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
    2431                 :            :                 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
    2432                 :            :                 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
    2433                 :            :                 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
    2434                 :            :                 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
    2435                 :            :                 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
    2436                 :            :                 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
    2437                 :            :                 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
    2438                 :            :                 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
    2439                 :            :                 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
    2440                 :            :                 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
    2441                 :            :                 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
    2442                 :            :                 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
    2443                 :            :                 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
    2444                 :            :                 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
    2445                 :            :                 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
    2446                 :            :                 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
    2447                 :            :                 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
    2448                 :            :                 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
    2449                 :            :                 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
    2450                 :            :                 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
    2451                 :            :                 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
    2452                 :            :                 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
    2453                 :            :                 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
    2454                 :            :                 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
    2455                 :            :                 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
    2456                 :            :                 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
    2457                 :            :                 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
    2458                 :            :                 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
    2459                 :            :                 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
    2460                 :            :                 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
    2461                 :            : };
    2462                 :            : 
    2463                 :            : static  uint8_t ms_hmac_key2[] = {
    2464                 :            :                 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
    2465                 :            :                 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
    2466                 :            :                 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
    2467                 :            :                 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
    2468                 :            :                 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
    2469                 :            :                 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
    2470                 :            :                 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
    2471                 :            :                 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
    2472                 :            : };
    2473                 :            : 
    2474                 :            : static const uint8_t ms_hmac_digest2[] = {
    2475                 :            :                 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
    2476                 :            :                 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
    2477                 :            :                 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
    2478                 :            :                 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
    2479                 :            :                 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
    2480                 :            :                 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
    2481                 :            :                 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
    2482                 :            :                 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
    2483                 :            : };
    2484                 :            : 
    2485                 :            : /* End Session 2 */
    2486                 :            : 
    2487                 :            : #define MAX_OPS_PROCESSED (MAX_NUM_OPS_INFLIGHT - 1)
    2488                 :            : static int
    2489                 :          1 : test_queue_pair_descriptor_count(void)
    2490                 :            : {
    2491                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    2492                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    2493                 :          1 :         struct rte_crypto_op *ops_deq[MAX_OPS_PROCESSED] = { NULL };
    2494                 :          1 :         struct rte_crypto_op *ops[MAX_OPS_PROCESSED] = { NULL };
    2495                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    2496                 :            :         int qp_depth = 0;
    2497                 :            :         int i;
    2498                 :            : 
    2499         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    2500                 :            :                 return TEST_SKIPPED;
    2501                 :            : 
    2502                 :            :         /* Verify if the queue pair depth API is supported by driver */
    2503         [ +  - ]:          1 :         qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
    2504         [ #  # ]:          0 :         if (qp_depth == -ENOTSUP)
    2505                 :          1 :                 return TEST_SKIPPED;
    2506                 :            : 
    2507                 :            :         /* Verify the capabilities */
    2508                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    2509                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
    2510         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
    2511                 :            :                 return TEST_SKIPPED;
    2512                 :            : 
    2513                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    2514                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
    2515         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
    2516                 :            :                 return TEST_SKIPPED;
    2517                 :            : 
    2518                 :            :         /* Setup Cipher Parameters */
    2519                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    2520                 :          0 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
    2521                 :          0 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
    2522                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
    2523                 :          0 :         ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
    2524                 :          0 :         ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
    2525                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    2526                 :          0 :         ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
    2527                 :            : 
    2528                 :            :         /* Setup HMAC Parameters */
    2529                 :          0 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    2530                 :          0 :         ut_params->auth_xform.next = NULL;
    2531                 :          0 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
    2532                 :          0 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
    2533                 :          0 :         ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
    2534                 :          0 :         ut_params->auth_xform.auth.key.data = hmac_sha1_key;
    2535                 :          0 :         ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
    2536                 :            : 
    2537                 :          0 :         rte_errno = 0;
    2538                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
    2539                 :            :                         &ut_params->cipher_xform, ts_params->session_mpool);
    2540         [ #  # ]:          0 :         if (rte_errno == ENOTSUP)
    2541                 :            :                 return TEST_SKIPPED;
    2542                 :            : 
    2543         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    2544                 :            : 
    2545         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
    2546                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops, MAX_OPS_PROCESSED),
    2547                 :            :                         MAX_OPS_PROCESSED, "failed to generate burst of crypto ops");
    2548                 :            : 
    2549                 :            :         /* Generate crypto op data structure */
    2550         [ #  # ]:          0 :         for (i = 0; i < MAX_OPS_PROCESSED; i++) {
    2551                 :            :                 struct rte_mbuf *m;
    2552                 :            :                 uint8_t *digest;
    2553                 :            : 
    2554                 :            :                 /* Generate test mbuf data and space for digest */
    2555                 :          0 :                 m = setup_test_string(ts_params->mbuf_pool, catch_22_quote, QUOTE_512_BYTES, 0);
    2556         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
    2557                 :            : 
    2558                 :            :                 digest = (uint8_t *)rte_pktmbuf_append(m, DIGEST_BYTE_LENGTH_SHA1);
    2559         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(digest, "no room to append digest");
    2560                 :            : 
    2561         [ #  # ]:          0 :                 rte_crypto_op_attach_sym_session(ops[i], ut_params->sess);
    2562                 :            : 
    2563                 :            :                 /* set crypto operation source mbuf */
    2564                 :          0 :                 ops[i]->sym->m_src = m;
    2565                 :            : 
    2566                 :            :                 /* Set crypto operation authentication parameters */
    2567                 :          0 :                 ops[i]->sym->auth.digest.data = digest;
    2568                 :          0 :                 ops[i]->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m, QUOTE_512_BYTES);
    2569                 :            : 
    2570                 :          0 :                 ops[i]->sym->auth.data.offset = 0;
    2571                 :          0 :                 ops[i]->sym->auth.data.length = QUOTE_512_BYTES;
    2572                 :            : 
    2573                 :            :                 /* Copy IV at the end of the crypto operation */
    2574                 :          0 :                 memcpy(rte_crypto_op_ctod_offset(ops[i], uint8_t *, IV_OFFSET), aes_cbc_iv,
    2575                 :            :                                 CIPHER_IV_LENGTH_AES_CBC);
    2576                 :            : 
    2577                 :            :                 /* Set crypto operation cipher parameters */
    2578                 :          0 :                 ops[i]->sym->cipher.data.offset = 0;
    2579                 :          0 :                 ops[i]->sym->cipher.data.length = QUOTE_512_BYTES;
    2580                 :            : 
    2581         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0], 0,
    2582                 :            :                                         &ops[i], 1), 1, "Error enqueuing");
    2583                 :            :         }
    2584                 :            : 
    2585         [ #  # ]:          0 :         for (i = 0; i < MAX_OPS_PROCESSED; i++) {
    2586         [ #  # ]:          0 :                 qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
    2587         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(qp_depth, MAX_OPS_PROCESSED - i,
    2588                 :            :                         "Crypto queue pair depth used does not match with inflight ops");
    2589                 :            : 
    2590                 :          0 :                 while (rte_cryptodev_dequeue_burst(ts_params->valid_devs[0], 0,
    2591         [ #  # ]:          0 :                                         &ops_deq[i], 1) == 0)
    2592                 :            :                         rte_pause();
    2593                 :            : 
    2594         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(ops_deq[i]->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    2595                 :            :                                 "crypto op processing failed");
    2596                 :            : 
    2597                 :          0 :                 rte_pktmbuf_free(ops_deq[i]->sym->m_src);
    2598                 :          0 :                 rte_crypto_op_free(ops_deq[i]);
    2599                 :            :         }
    2600                 :            : 
    2601                 :            :         return TEST_SUCCESS;
    2602                 :            : }
    2603                 :            : 
    2604                 :            : static int
    2605                 :          2 : test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
    2606                 :            : {
    2607                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    2608                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    2609                 :            :         /* Verify the capabilities */
    2610                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    2611                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    2612                 :          2 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
    2613         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    2614                 :            :                         &cap_idx) == NULL)
    2615                 :            :                 return TEST_SKIPPED;
    2616                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    2617                 :          2 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
    2618         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    2619                 :            :                         &cap_idx) == NULL)
    2620                 :            :                 return TEST_SKIPPED;
    2621                 :            : 
    2622                 :            :         /* Generate test mbuf data and space for digest */
    2623                 :          2 :         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
    2624                 :            :                         catch_22_quote, QUOTE_512_BYTES, 0);
    2625                 :            : 
    2626                 :          2 :         ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    2627                 :            :                         DIGEST_BYTE_LENGTH_SHA1);
    2628         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
    2629                 :            : 
    2630                 :            :         /* Setup Cipher Parameters */
    2631                 :          2 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    2632                 :          2 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
    2633                 :            : 
    2634                 :          2 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
    2635                 :          2 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
    2636                 :          2 :         ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
    2637                 :          2 :         ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
    2638                 :          2 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    2639                 :          2 :         ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
    2640                 :            : 
    2641                 :            :         /* Setup HMAC Parameters */
    2642                 :          2 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    2643                 :            : 
    2644                 :          2 :         ut_params->auth_xform.next = NULL;
    2645                 :            : 
    2646                 :          2 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
    2647                 :          2 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
    2648                 :          2 :         ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
    2649                 :          2 :         ut_params->auth_xform.auth.key.data = hmac_sha1_key;
    2650                 :          2 :         ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
    2651                 :            : 
    2652                 :          2 :         rte_errno = 0;
    2653                 :          4 :         ut_params->sess = rte_cryptodev_sym_session_create(
    2654                 :          2 :                         ts_params->valid_devs[0], &ut_params->cipher_xform,
    2655                 :            :                         ts_params->session_mpool);
    2656         [ +  - ]:          2 :         if (rte_errno == ENOTSUP)
    2657                 :            :                 return TEST_SKIPPED;
    2658         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    2659                 :            : 
    2660                 :            :         /* Generate crypto op data structure */
    2661                 :          2 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    2662                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    2663         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    2664                 :            :                         "Failed to allocate symmetric crypto operation struct");
    2665                 :            : 
    2666         [ +  - ]:          2 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    2667                 :            : 
    2668                 :          2 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    2669                 :            : 
    2670                 :            :         /* set crypto operation source mbuf */
    2671                 :          2 :         sym_op->m_src = ut_params->ibuf;
    2672                 :            : 
    2673                 :            :         /* Set crypto operation authentication parameters */
    2674                 :          2 :         sym_op->auth.digest.data = ut_params->digest;
    2675         [ -  + ]:          2 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    2676                 :            :                         ut_params->ibuf, QUOTE_512_BYTES);
    2677                 :            : 
    2678                 :          2 :         sym_op->auth.data.offset = 0;
    2679                 :          2 :         sym_op->auth.data.length = QUOTE_512_BYTES;
    2680                 :            : 
    2681                 :            :         /* Copy IV at the end of the crypto operation */
    2682         [ -  + ]:          2 :         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
    2683                 :            :                         aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
    2684                 :            : 
    2685                 :            :         /* Set crypto operation cipher parameters */
    2686                 :          2 :         sym_op->cipher.data.offset = 0;
    2687                 :          2 :         sym_op->cipher.data.length = QUOTE_512_BYTES;
    2688                 :            : 
    2689                 :            :         /* Process crypto operation */
    2690         [ -  + ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    2691                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
    2692                 :            :                         ut_params->op);
    2693                 :            :         else
    2694         [ -  + ]:          2 :                 TEST_ASSERT_NOT_NULL(
    2695                 :            :                         process_crypto_request(ts_params->valid_devs[0],
    2696                 :            :                                 ut_params->op),
    2697                 :            :                                 "failed to process sym crypto op");
    2698                 :            : 
    2699         [ -  + ]:          2 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    2700                 :            :                         "crypto op processing failed");
    2701                 :            : 
    2702                 :            :         /* Validate obuf */
    2703                 :          2 :         uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
    2704                 :            :                         uint8_t *);
    2705                 :            : 
    2706         [ -  + ]:          2 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
    2707                 :            :                         catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
    2708                 :            :                         QUOTE_512_BYTES,
    2709                 :            :                         "ciphertext data not as expected");
    2710                 :            : 
    2711                 :          2 :         uint8_t *digest = ciphertext + QUOTE_512_BYTES;
    2712                 :            : 
    2713   [ +  -  -  + ]:          4 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
    2714                 :            :                         catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
    2715                 :            :                         gbl_driver_id == rte_cryptodev_driver_id_get(
    2716                 :            :                                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
    2717                 :            :                                         TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
    2718                 :            :                                         DIGEST_BYTE_LENGTH_SHA1,
    2719                 :            :                         "Generated digest data not as expected");
    2720                 :            : 
    2721                 :            :         return TEST_SUCCESS;
    2722                 :            : }
    2723                 :            : 
    2724                 :            : /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
    2725                 :            : 
    2726                 :            : #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
    2727                 :            : 
    2728                 :            : static uint8_t hmac_sha512_key[] = {
    2729                 :            :         0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
    2730                 :            :         0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
    2731                 :            :         0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
    2732                 :            :         0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
    2733                 :            :         0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
    2734                 :            :         0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
    2735                 :            :         0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
    2736                 :            :         0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
    2737                 :            : 
    2738                 :            : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
    2739                 :            :         0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
    2740                 :            :         0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
    2741                 :            :         0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
    2742                 :            :         0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
    2743                 :            :         0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
    2744                 :            :         0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
    2745                 :            :         0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
    2746                 :            :         0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
    2747                 :            : 
    2748                 :            : 
    2749                 :            : 
    2750                 :            : static int
    2751                 :            : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
    2752                 :            :                 struct crypto_unittest_params *ut_params,
    2753                 :            :                 uint8_t *cipher_key,
    2754                 :            :                 uint8_t *hmac_key);
    2755                 :            : 
    2756                 :            : static int
    2757                 :            : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
    2758                 :            :                 struct crypto_unittest_params *ut_params,
    2759                 :            :                 struct crypto_testsuite_params *ts_params,
    2760                 :            :                 const uint8_t *cipher,
    2761                 :            :                 const uint8_t *digest,
    2762                 :            :                 const uint8_t *iv);
    2763                 :            : 
    2764                 :            : 
    2765                 :            : static int
    2766                 :            : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
    2767                 :            :                 struct crypto_unittest_params *ut_params,
    2768                 :            :                 uint8_t *cipher_key,
    2769                 :            :                 uint8_t *hmac_key)
    2770                 :            : {
    2771                 :            : 
    2772                 :            :         /* Setup Cipher Parameters */
    2773                 :          4 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    2774                 :          4 :         ut_params->cipher_xform.next = NULL;
    2775                 :            : 
    2776                 :          4 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
    2777                 :          4 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
    2778                 :          4 :         ut_params->cipher_xform.cipher.key.data = cipher_key;
    2779                 :          4 :         ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
    2780                 :          4 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    2781                 :          4 :         ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
    2782                 :            : 
    2783                 :            :         /* Setup HMAC Parameters */
    2784                 :          4 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    2785                 :          4 :         ut_params->auth_xform.next = &ut_params->cipher_xform;
    2786                 :            : 
    2787                 :          4 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
    2788                 :          4 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
    2789                 :          4 :         ut_params->auth_xform.auth.key.data = hmac_key;
    2790                 :          4 :         ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
    2791                 :          4 :         ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
    2792                 :            : 
    2793                 :            :         return TEST_SUCCESS;
    2794                 :            : }
    2795                 :            : 
    2796                 :            : 
    2797                 :            : static int
    2798                 :          5 : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
    2799                 :            :                 struct crypto_unittest_params *ut_params,
    2800                 :            :                 struct crypto_testsuite_params *ts_params,
    2801                 :            :                 const uint8_t *cipher,
    2802                 :            :                 const uint8_t *digest,
    2803                 :            :                 const uint8_t *iv)
    2804                 :            : {
    2805                 :            :         int ret;
    2806                 :            : 
    2807                 :            :         /* Generate test mbuf data and digest */
    2808                 :          5 :         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
    2809                 :            :                         (const char *)
    2810                 :            :                         cipher,
    2811                 :            :                         QUOTE_512_BYTES, 0);
    2812                 :            : 
    2813                 :          5 :         ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    2814                 :            :                         DIGEST_BYTE_LENGTH_SHA512);
    2815         [ -  + ]:          5 :         TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
    2816                 :            : 
    2817                 :            :         rte_memcpy(ut_params->digest,
    2818                 :            :                         digest,
    2819                 :            :                         DIGEST_BYTE_LENGTH_SHA512);
    2820                 :            : 
    2821                 :            :         /* Generate Crypto op data structure */
    2822                 :          5 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    2823                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    2824         [ -  + ]:          5 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    2825                 :            :                         "Failed to allocate symmetric crypto operation struct");
    2826                 :            : 
    2827                 :            :         rte_crypto_op_attach_sym_session(ut_params->op, sess);
    2828                 :            : 
    2829                 :          5 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    2830                 :            : 
    2831                 :            :         /* set crypto operation source mbuf */
    2832                 :          5 :         sym_op->m_src = ut_params->ibuf;
    2833                 :            : 
    2834                 :          5 :         sym_op->auth.digest.data = ut_params->digest;
    2835         [ -  + ]:          5 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    2836                 :            :                         ut_params->ibuf, QUOTE_512_BYTES);
    2837                 :            : 
    2838                 :          5 :         sym_op->auth.data.offset = 0;
    2839                 :          5 :         sym_op->auth.data.length = QUOTE_512_BYTES;
    2840                 :            : 
    2841                 :            :         /* Copy IV at the end of the crypto operation */
    2842         [ -  + ]:          5 :         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
    2843                 :            :                         iv, CIPHER_IV_LENGTH_AES_CBC);
    2844                 :            : 
    2845                 :          5 :         sym_op->cipher.data.offset = 0;
    2846                 :          5 :         sym_op->cipher.data.length = QUOTE_512_BYTES;
    2847                 :            : 
    2848                 :            :         /* Process crypto operation */
    2849         [ -  + ]:          5 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    2850                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
    2851                 :            :                         ut_params->op);
    2852         [ -  + ]:          5 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    2853                 :          0 :                 ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
    2854         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
    2855                 :            :                         return ret;
    2856                 :            :         } else
    2857         [ -  + ]:          5 :                 TEST_ASSERT_NOT_NULL(
    2858                 :            :                                 process_crypto_request(ts_params->valid_devs[0],
    2859                 :            :                                         ut_params->op),
    2860                 :            :                                         "failed to process sym crypto op");
    2861                 :            : 
    2862         [ -  + ]:          5 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    2863                 :            :                         "crypto op processing failed");
    2864                 :            : 
    2865                 :          5 :         ut_params->obuf = ut_params->op->sym->m_src;
    2866                 :            : 
    2867                 :            :         /* Validate obuf */
    2868         [ -  + ]:          5 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    2869                 :            :                         rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
    2870                 :            :                         catch_22_quote,
    2871                 :            :                         QUOTE_512_BYTES,
    2872                 :            :                         "Plaintext data not as expected");
    2873                 :            : 
    2874                 :            :         /* Validate obuf */
    2875         [ -  + ]:          5 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    2876                 :            :                         "Digest verification failed");
    2877                 :            : 
    2878                 :            :         return TEST_SUCCESS;
    2879                 :            : }
    2880                 :            : 
    2881                 :            : /* ***** SNOW 3G Tests ***** */
    2882                 :            : static int
    2883                 :          0 : create_wireless_algo_hash_session(uint8_t dev_id,
    2884                 :            :         const uint8_t *key, const uint8_t key_len,
    2885                 :            :         const uint8_t iv_len, const uint8_t auth_len,
    2886                 :            :         enum rte_crypto_auth_operation op,
    2887                 :            :         enum rte_crypto_auth_algorithm algo)
    2888                 :          0 : {
    2889                 :          0 :         uint8_t hash_key[key_len];
    2890                 :            : 
    2891                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    2892                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    2893                 :            : 
    2894                 :            :         memcpy(hash_key, key, key_len);
    2895                 :            : 
    2896                 :          0 :         debug_hexdump(stdout, "key:", key, key_len);
    2897                 :            : 
    2898                 :            :         /* Setup Authentication Parameters */
    2899                 :          0 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    2900                 :          0 :         ut_params->auth_xform.next = NULL;
    2901                 :            : 
    2902                 :          0 :         ut_params->auth_xform.auth.op = op;
    2903                 :          0 :         ut_params->auth_xform.auth.algo = algo;
    2904                 :          0 :         ut_params->auth_xform.auth.key.length = key_len;
    2905                 :          0 :         ut_params->auth_xform.auth.key.data = hash_key;
    2906                 :          0 :         ut_params->auth_xform.auth.digest_length = auth_len;
    2907                 :          0 :         ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
    2908                 :          0 :         ut_params->auth_xform.auth.iv.length = iv_len;
    2909                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    2910                 :            :                         &ut_params->auth_xform, ts_params->session_mpool);
    2911   [ #  #  #  # ]:          0 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
    2912                 :            :                 return TEST_SKIPPED;
    2913                 :            : 
    2914         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    2915                 :            :         return 0;
    2916                 :            : }
    2917                 :            : 
    2918                 :            : static int
    2919                 :          0 : create_wireless_algo_cipher_session(uint8_t dev_id,
    2920                 :            :                         enum rte_crypto_cipher_operation op,
    2921                 :            :                         enum rte_crypto_cipher_algorithm algo,
    2922                 :            :                         const uint8_t *key, const uint8_t key_len,
    2923                 :            :                         uint8_t iv_len)
    2924                 :          0 : {
    2925                 :          0 :         uint8_t cipher_key[key_len];
    2926                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    2927                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    2928                 :            : 
    2929                 :            :         memcpy(cipher_key, key, key_len);
    2930                 :            : 
    2931                 :            :         /* Setup Cipher Parameters */
    2932                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    2933                 :          0 :         ut_params->cipher_xform.next = NULL;
    2934                 :            : 
    2935                 :          0 :         ut_params->cipher_xform.cipher.algo = algo;
    2936                 :          0 :         ut_params->cipher_xform.cipher.op = op;
    2937                 :          0 :         ut_params->cipher_xform.cipher.key.data = cipher_key;
    2938                 :          0 :         ut_params->cipher_xform.cipher.key.length = key_len;
    2939                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    2940                 :          0 :         ut_params->cipher_xform.cipher.iv.length = iv_len;
    2941                 :            : 
    2942                 :          0 :         debug_hexdump(stdout, "key:", key, key_len);
    2943                 :            : 
    2944                 :            :         /* Create Crypto session */
    2945                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    2946                 :            :                         &ut_params->cipher_xform, ts_params->session_mpool);
    2947                 :            : 
    2948   [ #  #  #  # ]:          0 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
    2949                 :            :                 return TEST_SKIPPED;
    2950                 :            : 
    2951         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    2952                 :            :         return 0;
    2953                 :            : }
    2954                 :            : 
    2955                 :            : static int
    2956                 :          0 : create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
    2957                 :            :                         unsigned int cipher_len,
    2958                 :            :                         unsigned int cipher_offset)
    2959                 :            : {
    2960                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    2961                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    2962                 :            : 
    2963                 :            :         /* Generate Crypto op data structure */
    2964                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    2965                 :            :                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    2966         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    2967                 :            :                                 "Failed to allocate pktmbuf offload");
    2968                 :            : 
    2969                 :            :         /* Set crypto operation data parameters */
    2970         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    2971                 :            : 
    2972                 :          0 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    2973                 :            : 
    2974                 :            :         /* set crypto operation source mbuf */
    2975                 :          0 :         sym_op->m_src = ut_params->ibuf;
    2976                 :            : 
    2977                 :            :         /* iv */
    2978         [ #  # ]:          0 :         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
    2979                 :            :                         iv, iv_len);
    2980                 :          0 :         sym_op->cipher.data.length = cipher_len;
    2981                 :          0 :         sym_op->cipher.data.offset = cipher_offset;
    2982                 :          0 :         return 0;
    2983                 :            : }
    2984                 :            : 
    2985                 :            : static int
    2986                 :          0 : create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
    2987                 :            :                         unsigned int cipher_len,
    2988                 :            :                         unsigned int cipher_offset)
    2989                 :            : {
    2990                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    2991                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    2992                 :            : 
    2993                 :            :         /* Generate Crypto op data structure */
    2994                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    2995                 :            :                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    2996         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    2997                 :            :                                 "Failed to allocate pktmbuf offload");
    2998                 :            : 
    2999                 :            :         /* Set crypto operation data parameters */
    3000         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    3001                 :            : 
    3002                 :          0 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    3003                 :            : 
    3004                 :            :         /* set crypto operation source mbuf */
    3005                 :          0 :         sym_op->m_src = ut_params->ibuf;
    3006                 :          0 :         sym_op->m_dst = ut_params->obuf;
    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                 :          1 : create_wireless_algo_cipher_auth_session(uint8_t dev_id,
    3018                 :            :                 enum rte_crypto_cipher_operation cipher_op,
    3019                 :            :                 enum rte_crypto_auth_operation auth_op,
    3020                 :            :                 enum rte_crypto_auth_algorithm auth_algo,
    3021                 :            :                 enum rte_crypto_cipher_algorithm cipher_algo,
    3022                 :            :                 const uint8_t *a_key, uint8_t a_key_len,
    3023                 :            :                 const uint8_t *c_key, uint8_t c_key_len,
    3024                 :            :                 uint8_t auth_iv_len, uint8_t auth_len,
    3025                 :            :                 uint8_t cipher_iv_len)
    3026                 :            : 
    3027                 :            : {
    3028                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3029                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3030                 :            : 
    3031                 :            :         /* Setup Authentication Parameters */
    3032                 :          1 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3033                 :          1 :         ut_params->auth_xform.next = NULL;
    3034                 :            : 
    3035                 :          1 :         ut_params->auth_xform.auth.op = auth_op;
    3036                 :          1 :         ut_params->auth_xform.auth.algo = auth_algo;
    3037                 :          1 :         ut_params->auth_xform.auth.key.length = a_key_len;
    3038                 :          1 :         ut_params->auth_xform.auth.key.data = a_key;
    3039                 :          1 :         ut_params->auth_xform.auth.digest_length = auth_len;
    3040                 :            :         /* Auth IV will be after cipher IV */
    3041                 :          1 :         ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
    3042                 :          1 :         ut_params->auth_xform.auth.iv.length = auth_iv_len;
    3043                 :            : 
    3044                 :            :         /* Setup Cipher Parameters */
    3045                 :          1 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    3046                 :          1 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
    3047                 :            : 
    3048                 :          1 :         ut_params->cipher_xform.cipher.algo = cipher_algo;
    3049                 :          1 :         ut_params->cipher_xform.cipher.op = cipher_op;
    3050                 :          1 :         ut_params->cipher_xform.cipher.key.data = c_key;
    3051                 :          1 :         ut_params->cipher_xform.cipher.key.length = c_key_len;
    3052                 :          1 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    3053                 :          1 :         ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
    3054                 :            : 
    3055                 :          1 :         debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
    3056                 :          1 :         debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
    3057                 :            : 
    3058                 :            :         /* Create Crypto session*/
    3059                 :          1 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    3060                 :            :                         &ut_params->cipher_xform, ts_params->session_mpool);
    3061   [ -  +  -  - ]:          1 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
    3062                 :            :                 return TEST_SKIPPED;
    3063                 :            : 
    3064         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    3065                 :            :         return 0;
    3066                 :            : }
    3067                 :            : 
    3068                 :            : static int
    3069                 :          0 : create_wireless_cipher_auth_session(uint8_t dev_id,
    3070                 :            :                 enum rte_crypto_cipher_operation cipher_op,
    3071                 :            :                 enum rte_crypto_auth_operation auth_op,
    3072                 :            :                 enum rte_crypto_auth_algorithm auth_algo,
    3073                 :            :                 enum rte_crypto_cipher_algorithm cipher_algo,
    3074                 :            :                 const struct wireless_test_data *tdata)
    3075                 :          0 : {
    3076                 :          0 :         const uint8_t key_len = tdata->key.len;
    3077                 :          0 :         uint8_t cipher_auth_key[key_len];
    3078                 :            : 
    3079                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3080                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3081                 :          0 :         const uint8_t *key = tdata->key.data;
    3082                 :          0 :         const uint8_t auth_len = tdata->digest.len;
    3083                 :          0 :         uint8_t cipher_iv_len = tdata->cipher_iv.len;
    3084                 :          0 :         uint8_t auth_iv_len = tdata->auth_iv.len;
    3085                 :            : 
    3086                 :            :         memcpy(cipher_auth_key, key, key_len);
    3087                 :            : 
    3088                 :            :         /* Setup Authentication Parameters */
    3089                 :          0 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3090                 :          0 :         ut_params->auth_xform.next = NULL;
    3091                 :            : 
    3092                 :          0 :         ut_params->auth_xform.auth.op = auth_op;
    3093                 :          0 :         ut_params->auth_xform.auth.algo = auth_algo;
    3094                 :          0 :         ut_params->auth_xform.auth.key.length = key_len;
    3095                 :            :         /* Hash key = cipher key */
    3096                 :          0 :         ut_params->auth_xform.auth.key.data = cipher_auth_key;
    3097                 :          0 :         ut_params->auth_xform.auth.digest_length = auth_len;
    3098                 :            :         /* Auth IV will be after cipher IV */
    3099                 :          0 :         ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
    3100                 :          0 :         ut_params->auth_xform.auth.iv.length = auth_iv_len;
    3101                 :            : 
    3102                 :            :         /* Setup Cipher Parameters */
    3103                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    3104                 :          0 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
    3105                 :            : 
    3106                 :          0 :         ut_params->cipher_xform.cipher.algo = cipher_algo;
    3107                 :          0 :         ut_params->cipher_xform.cipher.op = cipher_op;
    3108                 :          0 :         ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
    3109                 :          0 :         ut_params->cipher_xform.cipher.key.length = key_len;
    3110                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    3111                 :          0 :         ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
    3112                 :            : 
    3113                 :            : 
    3114                 :          0 :         debug_hexdump(stdout, "key:", key, key_len);
    3115                 :            : 
    3116                 :            :         /* Create Crypto session*/
    3117                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    3118                 :            :                         &ut_params->cipher_xform, ts_params->session_mpool);
    3119   [ #  #  #  # ]:          0 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
    3120                 :            :                 return TEST_SKIPPED;
    3121                 :            : 
    3122         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    3123                 :            :         return 0;
    3124                 :            : }
    3125                 :            : 
    3126                 :            : static int
    3127                 :            : create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
    3128                 :            :                 const struct wireless_test_data *tdata)
    3129                 :            : {
    3130                 :          0 :         return create_wireless_cipher_auth_session(dev_id,
    3131                 :            :                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    3132                 :            :                 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
    3133                 :            :                 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
    3134                 :            : }
    3135                 :            : 
    3136                 :            : static int
    3137                 :          1 : create_wireless_algo_auth_cipher_session(uint8_t dev_id,
    3138                 :            :                 enum rte_crypto_cipher_operation cipher_op,
    3139                 :            :                 enum rte_crypto_auth_operation auth_op,
    3140                 :            :                 enum rte_crypto_auth_algorithm auth_algo,
    3141                 :            :                 enum rte_crypto_cipher_algorithm cipher_algo,
    3142                 :            :                 const uint8_t *a_key, const uint8_t a_key_len,
    3143                 :            :                 const uint8_t *c_key, const uint8_t c_key_len,
    3144                 :            :                 uint8_t auth_iv_len, uint8_t auth_len,
    3145                 :            :                 uint8_t cipher_iv_len)
    3146                 :            : {
    3147                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3148                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3149                 :            : 
    3150                 :            :         /* Setup Authentication Parameters */
    3151                 :          1 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3152                 :          1 :         ut_params->auth_xform.auth.op = auth_op;
    3153                 :          1 :         ut_params->auth_xform.next = &ut_params->cipher_xform;
    3154                 :          1 :         ut_params->auth_xform.auth.algo = auth_algo;
    3155                 :          1 :         ut_params->auth_xform.auth.key.length = a_key_len;
    3156                 :          1 :         ut_params->auth_xform.auth.key.data = a_key;
    3157                 :          1 :         ut_params->auth_xform.auth.digest_length = auth_len;
    3158                 :            :         /* Auth IV will be after cipher IV */
    3159                 :          1 :         ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
    3160                 :          1 :         ut_params->auth_xform.auth.iv.length = auth_iv_len;
    3161                 :            : 
    3162                 :            :         /* Setup Cipher Parameters */
    3163                 :          1 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    3164                 :          1 :         ut_params->cipher_xform.next = NULL;
    3165                 :          1 :         ut_params->cipher_xform.cipher.algo = cipher_algo;
    3166                 :          1 :         ut_params->cipher_xform.cipher.op = cipher_op;
    3167                 :          1 :         ut_params->cipher_xform.cipher.key.data = c_key;
    3168                 :          1 :         ut_params->cipher_xform.cipher.key.length = c_key_len;
    3169                 :          1 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    3170                 :          1 :         ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
    3171                 :            : 
    3172                 :          1 :         debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
    3173                 :          1 :         debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
    3174                 :            : 
    3175                 :            :         /* Create Crypto session*/
    3176         [ -  + ]:          1 :         if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
    3177                 :          0 :                 ut_params->auth_xform.next = NULL;
    3178                 :          0 :                 ut_params->cipher_xform.next = &ut_params->auth_xform;
    3179                 :          0 :                 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    3180                 :            :                         &ut_params->cipher_xform, ts_params->session_mpool);
    3181                 :            :         } else
    3182                 :          1 :                 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    3183                 :            :                         &ut_params->auth_xform, ts_params->session_mpool);
    3184                 :            : 
    3185   [ -  +  -  - ]:          1 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
    3186                 :            :                 return TEST_SKIPPED;
    3187                 :            : 
    3188         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    3189                 :            : 
    3190                 :            :         return 0;
    3191                 :            : }
    3192                 :            : 
    3193                 :            : static int
    3194                 :          0 : create_wireless_algo_hash_operation(const uint8_t *auth_tag,
    3195                 :            :                 unsigned int auth_tag_len,
    3196                 :            :                 const uint8_t *iv, unsigned int iv_len,
    3197                 :            :                 unsigned int data_pad_len,
    3198                 :            :                 enum rte_crypto_auth_operation op,
    3199                 :            :                 unsigned int auth_len, unsigned int auth_offset)
    3200                 :            : {
    3201                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3202                 :            : 
    3203                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3204                 :            : 
    3205                 :            :         /* Generate Crypto op data structure */
    3206                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    3207                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    3208         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    3209                 :            :                 "Failed to allocate pktmbuf offload");
    3210                 :            : 
    3211                 :            :         /* Set crypto operation data parameters */
    3212         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    3213                 :            : 
    3214                 :          0 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    3215                 :            : 
    3216                 :            :         /* set crypto operation source mbuf */
    3217                 :          0 :         sym_op->m_src = ut_params->ibuf;
    3218                 :            : 
    3219                 :            :         /* iv */
    3220         [ #  # ]:          0 :         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
    3221                 :            :                         iv, iv_len);
    3222                 :            :         /* digest */
    3223                 :          0 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
    3224                 :            :                                         ut_params->ibuf, auth_tag_len);
    3225                 :            : 
    3226         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
    3227                 :            :                                 "no room to append auth tag");
    3228                 :          0 :         ut_params->digest = sym_op->auth.digest.data;
    3229         [ #  # ]:          0 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    3230                 :            :                         ut_params->ibuf, data_pad_len);
    3231         [ #  # ]:          0 :         if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
    3232                 :          0 :                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
    3233                 :            :         else
    3234         [ #  # ]:          0 :                 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
    3235                 :            : 
    3236                 :          0 :         debug_hexdump(stdout, "digest:",
    3237                 :          0 :                 sym_op->auth.digest.data,
    3238                 :            :                 auth_tag_len);
    3239                 :            : 
    3240                 :          0 :         sym_op->auth.data.length = auth_len;
    3241                 :          0 :         sym_op->auth.data.offset = auth_offset;
    3242                 :            : 
    3243                 :          0 :         return 0;
    3244                 :            : }
    3245                 :            : 
    3246                 :            : static int
    3247                 :          0 : create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
    3248                 :            :         enum rte_crypto_auth_operation op)
    3249                 :            : {
    3250                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3251                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3252                 :            : 
    3253                 :          0 :         const uint8_t *auth_tag = tdata->digest.data;
    3254                 :          0 :         const unsigned int auth_tag_len = tdata->digest.len;
    3255         [ #  # ]:          0 :         unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
    3256                 :          0 :         unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    3257                 :            : 
    3258                 :          0 :         const uint8_t *cipher_iv = tdata->cipher_iv.data;
    3259                 :          0 :         const uint8_t cipher_iv_len = tdata->cipher_iv.len;
    3260                 :          0 :         const uint8_t *auth_iv = tdata->auth_iv.data;
    3261                 :          0 :         const uint8_t auth_iv_len = tdata->auth_iv.len;
    3262                 :          0 :         const unsigned int cipher_len = tdata->validCipherLenInBits.len;
    3263                 :          0 :         const unsigned int auth_len = tdata->validAuthLenInBits.len;
    3264                 :            : 
    3265                 :            :         /* Generate Crypto op data structure */
    3266                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    3267                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    3268         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    3269                 :            :                         "Failed to allocate pktmbuf offload");
    3270                 :            :         /* Set crypto operation data parameters */
    3271         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    3272                 :            : 
    3273                 :          0 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    3274                 :            : 
    3275                 :            :         /* set crypto operation source mbuf */
    3276                 :          0 :         sym_op->m_src = ut_params->ibuf;
    3277                 :            : 
    3278                 :            :         /* digest */
    3279                 :          0 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
    3280                 :            :                         ut_params->ibuf, auth_tag_len);
    3281                 :            : 
    3282         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
    3283                 :            :                         "no room to append auth tag");
    3284                 :          0 :         ut_params->digest = sym_op->auth.digest.data;
    3285         [ #  # ]:          0 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    3286                 :            :                         ut_params->ibuf, data_pad_len);
    3287         [ #  # ]:          0 :         if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
    3288                 :          0 :                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
    3289                 :            :         else
    3290         [ #  # ]:          0 :                 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
    3291                 :            : 
    3292                 :          0 :         debug_hexdump(stdout, "digest:",
    3293                 :          0 :                 sym_op->auth.digest.data,
    3294                 :            :                 auth_tag_len);
    3295                 :            : 
    3296                 :            :         /* Copy cipher and auth IVs at the end of the crypto operation */
    3297                 :          0 :         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
    3298                 :            :                                                 IV_OFFSET);
    3299         [ #  # ]:          0 :         rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
    3300                 :          0 :         iv_ptr += cipher_iv_len;
    3301         [ #  # ]:          0 :         rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
    3302                 :            : 
    3303                 :          0 :         sym_op->cipher.data.length = cipher_len;
    3304                 :          0 :         sym_op->cipher.data.offset = 0;
    3305                 :          0 :         sym_op->auth.data.length = auth_len;
    3306                 :          0 :         sym_op->auth.data.offset = 0;
    3307                 :            : 
    3308                 :          0 :         return 0;
    3309                 :            : }
    3310                 :            : 
    3311                 :            : static int
    3312                 :            : create_zuc_cipher_hash_generate_operation(
    3313                 :            :                 const struct wireless_test_data *tdata)
    3314                 :            : {
    3315                 :          0 :         return create_wireless_cipher_hash_operation(tdata,
    3316                 :            :                 RTE_CRYPTO_AUTH_OP_GENERATE);
    3317                 :            : }
    3318                 :            : 
    3319                 :            : static int
    3320                 :          0 : create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
    3321                 :            :                 const unsigned auth_tag_len,
    3322                 :            :                 const uint8_t *auth_iv, uint8_t auth_iv_len,
    3323                 :            :                 unsigned data_pad_len,
    3324                 :            :                 enum rte_crypto_auth_operation op,
    3325                 :            :                 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
    3326                 :            :                 const unsigned cipher_len, const unsigned cipher_offset,
    3327                 :            :                 const unsigned auth_len, const unsigned auth_offset)
    3328                 :            : {
    3329                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3330                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3331                 :            : 
    3332                 :          0 :         enum rte_crypto_cipher_algorithm cipher_algo =
    3333                 :            :                         ut_params->cipher_xform.cipher.algo;
    3334                 :          0 :         enum rte_crypto_auth_algorithm auth_algo =
    3335                 :            :                         ut_params->auth_xform.auth.algo;
    3336                 :            : 
    3337                 :            :         /* Generate Crypto op data structure */
    3338                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    3339                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    3340         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    3341                 :            :                         "Failed to allocate pktmbuf offload");
    3342                 :            :         /* Set crypto operation data parameters */
    3343         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    3344                 :            : 
    3345                 :          0 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    3346                 :            : 
    3347                 :            :         /* set crypto operation source mbuf */
    3348                 :          0 :         sym_op->m_src = ut_params->ibuf;
    3349                 :            : 
    3350                 :            :         /* digest */
    3351                 :          0 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
    3352                 :            :                         ut_params->ibuf, auth_tag_len);
    3353                 :            : 
    3354         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
    3355                 :            :                         "no room to append auth tag");
    3356                 :          0 :         ut_params->digest = sym_op->auth.digest.data;
    3357                 :            : 
    3358         [ #  # ]:          0 :         if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
    3359                 :          0 :                 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    3360                 :            :                                 ut_params->ibuf, data_pad_len);
    3361                 :            :         } else {
    3362                 :            :                 struct rte_mbuf *m = ut_params->ibuf;
    3363                 :            :                 unsigned int offset = data_pad_len;
    3364                 :            : 
    3365   [ #  #  #  # ]:          0 :                 while (offset > m->data_len && m->next != NULL) {
    3366                 :          0 :                         offset -= m->data_len;
    3367                 :            :                         m = m->next;
    3368                 :            :                 }
    3369                 :          0 :                 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    3370                 :            :                         m, offset);
    3371                 :            :         }
    3372                 :            : 
    3373         [ #  # ]:          0 :         if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
    3374                 :          0 :                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
    3375                 :            :         else
    3376         [ #  # ]:          0 :                 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
    3377                 :            : 
    3378                 :          0 :         debug_hexdump(stdout, "digest:",
    3379                 :          0 :                 sym_op->auth.digest.data,
    3380                 :            :                 auth_tag_len);
    3381                 :            : 
    3382                 :            :         /* Copy cipher and auth IVs at the end of the crypto operation */
    3383                 :          0 :         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
    3384                 :            :                                                 IV_OFFSET);
    3385         [ #  # ]:          0 :         rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
    3386                 :          0 :         iv_ptr += cipher_iv_len;
    3387         [ #  # ]:          0 :         rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
    3388                 :            : 
    3389                 :          0 :         if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
    3390         [ #  # ]:          0 :                 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
    3391                 :            :                 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
    3392                 :          0 :                 sym_op->cipher.data.length = cipher_len;
    3393                 :          0 :                 sym_op->cipher.data.offset = cipher_offset;
    3394                 :            :         } else {
    3395                 :          0 :                 sym_op->cipher.data.length = cipher_len >> 3;
    3396                 :          0 :                 sym_op->cipher.data.offset = cipher_offset >> 3;
    3397                 :            :         }
    3398                 :            : 
    3399                 :          0 :         if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
    3400   [ #  #  #  # ]:          0 :                 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
    3401                 :            :                 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
    3402                 :          0 :                 sym_op->auth.data.length = auth_len;
    3403                 :          0 :                 sym_op->auth.data.offset = auth_offset;
    3404                 :            :         } else {
    3405                 :          0 :                 sym_op->auth.data.length = auth_len >> 3;
    3406                 :          0 :                 sym_op->auth.data.offset = auth_offset >> 3;
    3407                 :            :         }
    3408                 :            : 
    3409                 :            :         return 0;
    3410                 :            : }
    3411                 :            : 
    3412                 :            : static int
    3413                 :          2 : create_wireless_algo_auth_cipher_operation(
    3414                 :            :                 const uint8_t *auth_tag, unsigned int auth_tag_len,
    3415                 :            :                 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
    3416                 :            :                 const uint8_t *auth_iv, uint8_t auth_iv_len,
    3417                 :            :                 unsigned int data_pad_len,
    3418                 :            :                 unsigned int cipher_len, unsigned int cipher_offset,
    3419                 :            :                 unsigned int auth_len, unsigned int auth_offset,
    3420                 :            :                 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
    3421                 :            : {
    3422                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3423                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3424                 :            : 
    3425                 :          2 :         enum rte_crypto_cipher_algorithm cipher_algo =
    3426                 :            :                         ut_params->cipher_xform.cipher.algo;
    3427                 :          2 :         enum rte_crypto_auth_algorithm auth_algo =
    3428                 :            :                         ut_params->auth_xform.auth.algo;
    3429                 :            : 
    3430                 :            :         /* Generate Crypto op data structure */
    3431                 :          2 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    3432                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    3433         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    3434                 :            :                         "Failed to allocate pktmbuf offload");
    3435                 :            : 
    3436                 :            :         /* Set crypto operation data parameters */
    3437         [ +  - ]:          2 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    3438                 :            : 
    3439                 :          2 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    3440                 :            : 
    3441                 :            :         /* set crypto operation mbufs */
    3442                 :          2 :         sym_op->m_src = ut_params->ibuf;
    3443         [ -  + ]:          2 :         if (op_mode == OUT_OF_PLACE)
    3444                 :          0 :                 sym_op->m_dst = ut_params->obuf;
    3445                 :            : 
    3446                 :            :         /* digest */
    3447         [ -  + ]:          2 :         if (!do_sgl) {
    3448         [ #  # ]:          0 :                 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
    3449                 :            :                         (op_mode == IN_PLACE ?
    3450                 :            :                                 ut_params->ibuf : ut_params->obuf),
    3451                 :            :                         uint8_t *, data_pad_len);
    3452         [ #  # ]:          0 :                 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
    3453                 :            :                         (op_mode == IN_PLACE ?
    3454                 :            :                                 ut_params->ibuf : ut_params->obuf),
    3455                 :            :                         data_pad_len);
    3456                 :          0 :                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
    3457                 :            :         } else {
    3458                 :          2 :                 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
    3459                 :            :                 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
    3460         [ -  + ]:          2 :                                 sym_op->m_src : sym_op->m_dst);
    3461         [ +  + ]:         32 :                 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
    3462                 :         30 :                         remaining_off -= rte_pktmbuf_data_len(sgl_buf);
    3463                 :         30 :                         sgl_buf = sgl_buf->next;
    3464                 :            :                 }
    3465                 :            : 
    3466                 :            :                 /* The last segment should be large enough to hold full digest */
    3467         [ -  + ]:          2 :                 if (sgl_buf->data_len < auth_tag_len) {
    3468                 :          0 :                         rte_pktmbuf_free(sgl_buf->next);
    3469                 :          0 :                         sgl_buf->next = NULL;
    3470   [ #  #  #  # ]:          0 :                         TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
    3471                 :            :                                         auth_tag_len - sgl_buf->data_len),
    3472                 :            :                                         "No room to append auth tag");
    3473                 :            :                 }
    3474                 :            : 
    3475                 :          2 :                 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
    3476                 :            :                                 uint8_t *, remaining_off);
    3477                 :          2 :                 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
    3478                 :            :                                 remaining_off);
    3479                 :            :                 memset(sym_op->auth.digest.data, 0, remaining_off);
    3480         [ -  + ]:          2 :                 while (sgl_buf->next != NULL) {
    3481                 :          0 :                         memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
    3482                 :          0 :                                 0, rte_pktmbuf_data_len(sgl_buf));
    3483                 :          0 :                         sgl_buf = sgl_buf->next;
    3484                 :            :                 }
    3485                 :            :         }
    3486                 :            : 
    3487                 :            :         /* Copy digest for the verification */
    3488         [ +  + ]:          2 :         if (verify)
    3489                 :          1 :                 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
    3490                 :            : 
    3491                 :            :         /* Copy cipher and auth IVs at the end of the crypto operation */
    3492                 :          2 :         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
    3493                 :            :                         ut_params->op, uint8_t *, IV_OFFSET);
    3494                 :            : 
    3495         [ -  + ]:          2 :         rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
    3496                 :          2 :         iv_ptr += cipher_iv_len;
    3497         [ -  + ]:          2 :         rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
    3498                 :            : 
    3499                 :            :         /* Only copy over the offset data needed from src to dst in OOP,
    3500                 :            :          * if the auth and cipher offsets are not aligned
    3501                 :            :          */
    3502         [ -  + ]:          2 :         if (op_mode == OUT_OF_PLACE) {
    3503         [ #  # ]:          0 :                 if (cipher_offset > auth_offset)
    3504                 :          0 :                         rte_memcpy(
    3505                 :          0 :                                 rte_pktmbuf_mtod_offset(
    3506                 :            :                                         sym_op->m_dst,
    3507                 :            :                                         uint8_t *, auth_offset >> 3),
    3508                 :          0 :                                 rte_pktmbuf_mtod_offset(
    3509                 :            :                                         sym_op->m_src,
    3510                 :            :                                         uint8_t *, auth_offset >> 3),
    3511         [ #  # ]:          0 :                                 ((cipher_offset >> 3) - (auth_offset >> 3)));
    3512                 :            :         }
    3513                 :            : 
    3514                 :          2 :         if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
    3515         [ -  + ]:          2 :                 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
    3516                 :            :                 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
    3517                 :          0 :                 sym_op->cipher.data.length = cipher_len;
    3518                 :          0 :                 sym_op->cipher.data.offset = cipher_offset;
    3519                 :            :         } else {
    3520                 :          2 :                 sym_op->cipher.data.length = cipher_len >> 3;
    3521                 :          2 :                 sym_op->cipher.data.offset = cipher_offset >> 3;
    3522                 :            :         }
    3523                 :            : 
    3524                 :          2 :         if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
    3525   [ +  -  -  + ]:          2 :                 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
    3526                 :            :                 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
    3527                 :          0 :                 sym_op->auth.data.length = auth_len;
    3528                 :          0 :                 sym_op->auth.data.offset = auth_offset;
    3529                 :            :         } else {
    3530                 :          2 :                 sym_op->auth.data.length = auth_len >> 3;
    3531                 :          2 :                 sym_op->auth.data.offset = auth_offset >> 3;
    3532                 :            :         }
    3533                 :            : 
    3534                 :            :         return 0;
    3535                 :            : }
    3536                 :            : 
    3537                 :            : static int
    3538                 :          0 : test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
    3539                 :            : {
    3540                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3541                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3542                 :            : 
    3543                 :            :         int retval;
    3544                 :            :         unsigned plaintext_pad_len;
    3545                 :            :         unsigned plaintext_len;
    3546                 :            :         uint8_t *plaintext;
    3547                 :            :         struct rte_cryptodev_info dev_info;
    3548                 :            : 
    3549                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    3550                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    3551                 :            : 
    3552         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
    3553         [ #  # ]:          0 :                         ((tdata->validAuthLenInBits.len % 8) != 0)) {
    3554                 :            :                 printf("Device doesn't support NON-Byte Aligned Data.\n");
    3555                 :          0 :                 return TEST_SKIPPED;
    3556                 :            :         }
    3557                 :            : 
    3558         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    3559         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    3560                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    3561                 :          0 :                 return TEST_SKIPPED;
    3562                 :            :         }
    3563                 :            : 
    3564         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    3565                 :            :                 return TEST_SKIPPED;
    3566                 :            : 
    3567                 :            :         /* Verify the capabilities */
    3568                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    3569                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3570                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
    3571         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    3572                 :            :                         &cap_idx) == NULL)
    3573                 :            :                 return TEST_SKIPPED;
    3574                 :            : 
    3575                 :            :         /* Create SNOW 3G session */
    3576                 :          0 :         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
    3577                 :          0 :                         tdata->key.data, tdata->key.len,
    3578                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    3579                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
    3580                 :            :                         RTE_CRYPTO_AUTH_SNOW3G_UIA2);
    3581         [ #  # ]:          0 :         if (retval < 0)
    3582                 :            :                 return retval;
    3583                 :            : 
    3584                 :            :         /* alloc mbuf and set payload */
    3585         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    3586                 :            : 
    3587         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    3588                 :            :         rte_pktmbuf_tailroom(ut_params->ibuf));
    3589                 :            : 
    3590         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    3591                 :            :         /* Append data which is padded to a multiple of */
    3592                 :            :         /* the algorithms block size */
    3593                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    3594                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    3595                 :            :                                 plaintext_pad_len);
    3596                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    3597                 :            : 
    3598                 :            :         /* Create SNOW 3G operation */
    3599                 :          0 :         retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
    3600                 :          0 :                         tdata->auth_iv.data, tdata->auth_iv.len,
    3601                 :            :                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
    3602                 :          0 :                         tdata->validAuthLenInBits.len,
    3603                 :            :                         0);
    3604         [ #  # ]:          0 :         if (retval < 0)
    3605                 :            :                 return retval;
    3606                 :            : 
    3607         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    3608                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
    3609                 :            :                                                0);
    3610         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    3611                 :            :                         return retval;
    3612                 :            :         } else
    3613                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    3614                 :            :                                 ut_params->op);
    3615                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    3616                 :            :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    3617                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    3618                 :            :                                                     uint8_t *,
    3619                 :            :                                                     plaintext_pad_len);
    3620                 :            : 
    3621                 :            :         /* Validate obuf */
    3622         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    3623                 :            :         ut_params->digest,
    3624                 :            :         tdata->digest.data,
    3625                 :            :         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
    3626                 :            :         "SNOW 3G Generated auth tag not as expected");
    3627                 :            : 
    3628                 :            :         return 0;
    3629                 :            : }
    3630                 :            : 
    3631                 :            : static int
    3632                 :          0 : test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
    3633                 :            : {
    3634                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3635                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3636                 :            : 
    3637                 :            :         int retval;
    3638                 :            :         unsigned plaintext_pad_len;
    3639                 :            :         unsigned plaintext_len;
    3640                 :            :         uint8_t *plaintext;
    3641                 :            :         struct rte_cryptodev_info dev_info;
    3642                 :            : 
    3643                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    3644                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    3645                 :            : 
    3646         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
    3647         [ #  # ]:          0 :                         ((tdata->validAuthLenInBits.len % 8) != 0)) {
    3648                 :            :                 printf("Device doesn't support NON-Byte Aligned Data.\n");
    3649                 :          0 :                 return TEST_SKIPPED;
    3650                 :            :         }
    3651                 :            : 
    3652         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    3653         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    3654                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    3655                 :          0 :                 return TEST_SKIPPED;
    3656                 :            :         }
    3657                 :            : 
    3658         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    3659                 :            :                 return TEST_SKIPPED;
    3660                 :            : 
    3661                 :            :         /* Verify the capabilities */
    3662                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    3663                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3664                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
    3665         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    3666                 :            :                         &cap_idx) == NULL)
    3667                 :            :                 return TEST_SKIPPED;
    3668                 :            : 
    3669                 :            :         /* Create SNOW 3G session */
    3670                 :          0 :         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
    3671                 :          0 :                                 tdata->key.data, tdata->key.len,
    3672                 :          0 :                                 tdata->auth_iv.len, tdata->digest.len,
    3673                 :            :                                 RTE_CRYPTO_AUTH_OP_VERIFY,
    3674                 :            :                                 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
    3675         [ #  # ]:          0 :         if (retval < 0)
    3676                 :            :                 return retval;
    3677                 :            :         /* alloc mbuf and set payload */
    3678         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    3679                 :            : 
    3680         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    3681                 :            :         rte_pktmbuf_tailroom(ut_params->ibuf));
    3682                 :            : 
    3683         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    3684                 :            :         /* Append data which is padded to a multiple of */
    3685                 :            :         /* the algorithms block size */
    3686                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    3687                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    3688                 :            :                                 plaintext_pad_len);
    3689                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    3690                 :            : 
    3691                 :            :         /* Create SNOW 3G operation */
    3692                 :          0 :         retval = create_wireless_algo_hash_operation(tdata->digest.data,
    3693                 :          0 :                         tdata->digest.len,
    3694                 :          0 :                         tdata->auth_iv.data, tdata->auth_iv.len,
    3695                 :            :                         plaintext_pad_len,
    3696                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY,
    3697                 :          0 :                         tdata->validAuthLenInBits.len,
    3698                 :            :                         0);
    3699         [ #  # ]:          0 :         if (retval < 0)
    3700                 :            :                 return retval;
    3701                 :            : 
    3702         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    3703                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
    3704                 :            :                                                0);
    3705         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    3706                 :            :                         return retval;
    3707                 :            :         } else
    3708                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    3709                 :            :                                 ut_params->op);
    3710         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    3711                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    3712                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    3713                 :            :                                                     uint8_t *,
    3714                 :            :                                                     plaintext_pad_len);
    3715                 :            : 
    3716                 :            :         /* Validate obuf */
    3717         [ #  # ]:          0 :         if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
    3718                 :            :                 return 0;
    3719                 :            :         else
    3720                 :          0 :                 return -1;
    3721                 :            : 
    3722                 :            :         return 0;
    3723                 :            : }
    3724                 :            : 
    3725                 :            : static int
    3726                 :          0 : test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
    3727                 :            : {
    3728                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3729                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3730                 :            : 
    3731                 :            :         int retval;
    3732                 :            :         unsigned plaintext_pad_len;
    3733                 :            :         unsigned plaintext_len;
    3734                 :            :         uint8_t *plaintext;
    3735                 :            :         struct rte_cryptodev_info dev_info;
    3736                 :            : 
    3737                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    3738                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    3739                 :            : 
    3740         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    3741         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    3742                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    3743                 :          0 :                 return TEST_SKIPPED;
    3744                 :            :         }
    3745                 :            : 
    3746         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    3747                 :            :                 return TEST_SKIPPED;
    3748                 :            : 
    3749                 :            :         /* Verify the capabilities */
    3750                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    3751                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3752                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
    3753         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    3754                 :            :                         &cap_idx) == NULL)
    3755                 :            :                 return TEST_SKIPPED;
    3756                 :            : 
    3757                 :            :         /* Create KASUMI session */
    3758                 :          0 :         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
    3759                 :          0 :                         tdata->key.data, tdata->key.len,
    3760                 :          0 :                         0, tdata->digest.len,
    3761                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
    3762                 :            :                         RTE_CRYPTO_AUTH_KASUMI_F9);
    3763         [ #  # ]:          0 :         if (retval < 0)
    3764                 :            :                 return retval;
    3765                 :            : 
    3766                 :            :         /* alloc mbuf and set payload */
    3767         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    3768                 :            : 
    3769         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    3770                 :            :         rte_pktmbuf_tailroom(ut_params->ibuf));
    3771                 :            : 
    3772         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    3773                 :            :         /* Append data which is padded to a multiple of */
    3774                 :            :         /* the algorithms block size */
    3775                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    3776                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    3777                 :            :                                 plaintext_pad_len);
    3778                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    3779                 :            : 
    3780                 :            :         /* Create KASUMI operation */
    3781                 :          0 :         retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
    3782                 :            :                         NULL, 0,
    3783                 :            :                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
    3784                 :          0 :                         tdata->plaintext.len,
    3785                 :            :                         0);
    3786         [ #  # ]:          0 :         if (retval < 0)
    3787                 :            :                 return retval;
    3788                 :            : 
    3789         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    3790                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
    3791                 :            :                         ut_params->op);
    3792         [ #  # ]:          0 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    3793                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
    3794                 :            :                                                0);
    3795         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    3796                 :            :                         return retval;
    3797                 :            :         } else
    3798                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    3799                 :            :                         ut_params->op);
    3800                 :            : 
    3801                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    3802                 :            :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    3803                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    3804                 :            :                                                     uint8_t *,
    3805                 :            :                                                     plaintext_pad_len);
    3806                 :            : 
    3807                 :            :         /* Validate obuf */
    3808         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    3809                 :            :         ut_params->digest,
    3810                 :            :         tdata->digest.data,
    3811                 :            :         DIGEST_BYTE_LENGTH_KASUMI_F9,
    3812                 :            :         "KASUMI Generated auth tag not as expected");
    3813                 :            : 
    3814                 :            :         return 0;
    3815                 :            : }
    3816                 :            : 
    3817                 :            : static int
    3818                 :          0 : test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
    3819                 :            : {
    3820                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    3821                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    3822                 :            : 
    3823                 :            :         int retval;
    3824                 :            :         unsigned plaintext_pad_len;
    3825                 :            :         unsigned plaintext_len;
    3826                 :            :         uint8_t *plaintext;
    3827                 :            :         struct rte_cryptodev_info dev_info;
    3828                 :            : 
    3829                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    3830                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    3831                 :            : 
    3832         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    3833         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    3834                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    3835                 :          0 :                 return TEST_SKIPPED;
    3836                 :            :         }
    3837                 :            : 
    3838         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    3839                 :            :                 return TEST_SKIPPED;
    3840                 :            : 
    3841                 :            :         /* Verify the capabilities */
    3842                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    3843                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    3844                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
    3845         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    3846                 :            :                         &cap_idx) == NULL)
    3847                 :            :                 return TEST_SKIPPED;
    3848                 :            : 
    3849                 :            :         /* Create KASUMI session */
    3850                 :          0 :         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
    3851                 :          0 :                                 tdata->key.data, tdata->key.len,
    3852                 :          0 :                                 0, tdata->digest.len,
    3853                 :            :                                 RTE_CRYPTO_AUTH_OP_VERIFY,
    3854                 :            :                                 RTE_CRYPTO_AUTH_KASUMI_F9);
    3855         [ #  # ]:          0 :         if (retval < 0)
    3856                 :            :                 return retval;
    3857                 :            :         /* alloc mbuf and set payload */
    3858         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    3859                 :            : 
    3860         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    3861                 :            :         rte_pktmbuf_tailroom(ut_params->ibuf));
    3862                 :            : 
    3863         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    3864                 :            :         /* Append data which is padded to a multiple */
    3865                 :            :         /* of the algorithms block size */
    3866                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    3867                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    3868                 :            :                                 plaintext_pad_len);
    3869                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    3870                 :            : 
    3871                 :            :         /* Create KASUMI operation */
    3872                 :          0 :         retval = create_wireless_algo_hash_operation(tdata->digest.data,
    3873                 :          0 :                         tdata->digest.len,
    3874                 :            :                         NULL, 0,
    3875                 :            :                         plaintext_pad_len,
    3876                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY,
    3877                 :          0 :                         tdata->plaintext.len,
    3878                 :            :                         0);
    3879         [ #  # ]:          0 :         if (retval < 0)
    3880                 :            :                 return retval;
    3881                 :            : 
    3882         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    3883                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
    3884                 :            :                                                0);
    3885         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    3886                 :            :                         return retval;
    3887                 :            :         } else
    3888                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    3889                 :            :                                 ut_params->op);
    3890         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    3891                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    3892                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    3893                 :            :                                                     uint8_t *,
    3894                 :            :                                                     plaintext_pad_len);
    3895                 :            : 
    3896                 :            :         /* Validate obuf */
    3897         [ #  # ]:          0 :         if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
    3898                 :            :                 return 0;
    3899                 :            :         else
    3900                 :          0 :                 return -1;
    3901                 :            : 
    3902                 :            :         return 0;
    3903                 :            : }
    3904                 :            : 
    3905                 :            : static int
    3906                 :          0 : test_snow3g_hash_generate_test_case_1(void)
    3907                 :            : {
    3908                 :          0 :         return test_snow3g_authentication(&snow3g_hash_test_case_1);
    3909                 :            : }
    3910                 :            : 
    3911                 :            : static int
    3912                 :          0 : test_snow3g_hash_generate_test_case_2(void)
    3913                 :            : {
    3914                 :          0 :         return test_snow3g_authentication(&snow3g_hash_test_case_2);
    3915                 :            : }
    3916                 :            : 
    3917                 :            : static int
    3918                 :          0 : test_snow3g_hash_generate_test_case_3(void)
    3919                 :            : {
    3920                 :          0 :         return test_snow3g_authentication(&snow3g_hash_test_case_3);
    3921                 :            : }
    3922                 :            : 
    3923                 :            : static int
    3924                 :          0 : test_snow3g_hash_generate_test_case_4(void)
    3925                 :            : {
    3926                 :          0 :         return test_snow3g_authentication(&snow3g_hash_test_case_4);
    3927                 :            : }
    3928                 :            : 
    3929                 :            : static int
    3930                 :          0 : test_snow3g_hash_generate_test_case_5(void)
    3931                 :            : {
    3932                 :          0 :         return test_snow3g_authentication(&snow3g_hash_test_case_5);
    3933                 :            : }
    3934                 :            : 
    3935                 :            : static int
    3936                 :          0 : test_snow3g_hash_generate_test_case_6(void)
    3937                 :            : {
    3938                 :          0 :         return test_snow3g_authentication(&snow3g_hash_test_case_6);
    3939                 :            : }
    3940                 :            : 
    3941                 :            : static int
    3942                 :          0 : test_snow3g_hash_verify_test_case_1(void)
    3943                 :            : {
    3944                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
    3945                 :            : 
    3946                 :            : }
    3947                 :            : 
    3948                 :            : static int
    3949                 :          0 : test_snow3g_hash_verify_test_case_2(void)
    3950                 :            : {
    3951                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
    3952                 :            : }
    3953                 :            : 
    3954                 :            : static int
    3955                 :          0 : test_snow3g_hash_verify_test_case_3(void)
    3956                 :            : {
    3957                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
    3958                 :            : }
    3959                 :            : 
    3960                 :            : static int
    3961                 :          0 : test_snow3g_hash_verify_test_case_4(void)
    3962                 :            : {
    3963                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
    3964                 :            : }
    3965                 :            : 
    3966                 :            : static int
    3967                 :          0 : test_snow3g_hash_verify_test_case_5(void)
    3968                 :            : {
    3969                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
    3970                 :            : }
    3971                 :            : 
    3972                 :            : static int
    3973                 :          0 : test_snow3g_hash_verify_test_case_6(void)
    3974                 :            : {
    3975                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
    3976                 :            : }
    3977                 :            : 
    3978                 :            : static int
    3979                 :          0 : test_kasumi_hash_generate_test_case_1(void)
    3980                 :            : {
    3981                 :          0 :         return test_kasumi_authentication(&kasumi_hash_test_case_1);
    3982                 :            : }
    3983                 :            : 
    3984                 :            : static int
    3985                 :          0 : test_kasumi_hash_generate_test_case_2(void)
    3986                 :            : {
    3987                 :          0 :         return test_kasumi_authentication(&kasumi_hash_test_case_2);
    3988                 :            : }
    3989                 :            : 
    3990                 :            : static int
    3991                 :          0 : test_kasumi_hash_generate_test_case_3(void)
    3992                 :            : {
    3993                 :          0 :         return test_kasumi_authentication(&kasumi_hash_test_case_3);
    3994                 :            : }
    3995                 :            : 
    3996                 :            : static int
    3997                 :          0 : test_kasumi_hash_generate_test_case_4(void)
    3998                 :            : {
    3999                 :          0 :         return test_kasumi_authentication(&kasumi_hash_test_case_4);
    4000                 :            : }
    4001                 :            : 
    4002                 :            : static int
    4003                 :          0 : test_kasumi_hash_generate_test_case_5(void)
    4004                 :            : {
    4005                 :          0 :         return test_kasumi_authentication(&kasumi_hash_test_case_5);
    4006                 :            : }
    4007                 :            : 
    4008                 :            : static int
    4009                 :          0 : test_kasumi_hash_generate_test_case_6(void)
    4010                 :            : {
    4011                 :          0 :         return test_kasumi_authentication(&kasumi_hash_test_case_6);
    4012                 :            : }
    4013                 :            : 
    4014                 :            : static int
    4015                 :          0 : test_kasumi_hash_verify_test_case_1(void)
    4016                 :            : {
    4017                 :          0 :         return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
    4018                 :            : }
    4019                 :            : 
    4020                 :            : static int
    4021                 :          0 : test_kasumi_hash_verify_test_case_2(void)
    4022                 :            : {
    4023                 :          0 :         return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
    4024                 :            : }
    4025                 :            : 
    4026                 :            : static int
    4027                 :          0 : test_kasumi_hash_verify_test_case_3(void)
    4028                 :            : {
    4029                 :          0 :         return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
    4030                 :            : }
    4031                 :            : 
    4032                 :            : static int
    4033                 :          0 : test_kasumi_hash_verify_test_case_4(void)
    4034                 :            : {
    4035                 :          0 :         return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
    4036                 :            : }
    4037                 :            : 
    4038                 :            : static int
    4039                 :          0 : test_kasumi_hash_verify_test_case_5(void)
    4040                 :            : {
    4041                 :          0 :         return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
    4042                 :            : }
    4043                 :            : 
    4044                 :            : static int
    4045                 :          0 : test_kasumi_encryption(const struct kasumi_test_data *tdata)
    4046                 :            : {
    4047                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4048                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4049                 :            : 
    4050                 :            :         int retval;
    4051                 :            :         uint8_t *plaintext, *ciphertext;
    4052                 :            :         unsigned plaintext_pad_len;
    4053                 :            :         unsigned plaintext_len;
    4054                 :            :         struct rte_cryptodev_info dev_info;
    4055                 :            : 
    4056                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4057                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4058                 :            : 
    4059         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    4060         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    4061                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    4062                 :          0 :                 return TEST_SKIPPED;
    4063                 :            :         }
    4064                 :            : 
    4065         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4066                 :            :                 return TEST_SKIPPED;
    4067                 :            : 
    4068                 :            :         /* Verify the capabilities */
    4069                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4070                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4071                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    4072         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4073                 :            :                         &cap_idx) == NULL)
    4074                 :            :                 return TEST_SKIPPED;
    4075                 :            : 
    4076                 :            :         /* Create KASUMI session */
    4077                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4078                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4079                 :            :                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    4080                 :          0 :                                         tdata->key.data, tdata->key.len,
    4081                 :          0 :                                         tdata->cipher_iv.len);
    4082         [ #  # ]:          0 :         if (retval < 0)
    4083                 :            :                 return retval;
    4084                 :            : 
    4085         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4086                 :            : 
    4087                 :            :         /* Clear mbuf payload */
    4088         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    4089                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    4090                 :            : 
    4091         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4092                 :            :         /* Append data which is padded to a multiple */
    4093                 :            :         /* of the algorithms block size */
    4094                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    4095                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    4096                 :            :                                 plaintext_pad_len);
    4097                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    4098                 :            : 
    4099                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    4100                 :            : 
    4101                 :            :         /* Create KASUMI operation */
    4102                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    4103                 :          0 :                                 tdata->cipher_iv.len,
    4104                 :          0 :                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    4105                 :          0 :                                 tdata->validCipherOffsetInBits.len);
    4106         [ #  # ]:          0 :         if (retval < 0)
    4107                 :            :                 return retval;
    4108                 :            : 
    4109         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    4110                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    4111                 :          0 :                                                tdata->cipher_iv.len);
    4112         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    4113                 :            :                         return retval;
    4114                 :            :         } else
    4115                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4116                 :            :                                 ut_params->op);
    4117         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4118                 :            : 
    4119                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4120         [ #  # ]:          0 :         if (ut_params->obuf)
    4121                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    4122                 :            :         else
    4123                 :          0 :                 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
    4124                 :            : 
    4125                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    4126                 :            : 
    4127                 :          0 :         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
    4128                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    4129                 :            :         /* Validate obuf */
    4130   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4131                 :            :                 ciphertext,
    4132                 :            :                 reference_ciphertext,
    4133                 :            :                 tdata->validCipherLenInBits.len,
    4134                 :            :                 "KASUMI Ciphertext data not as expected");
    4135                 :            :         return 0;
    4136                 :            : }
    4137                 :            : 
    4138                 :            : static int
    4139                 :          0 : test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
    4140                 :            : {
    4141                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4142                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4143                 :            : 
    4144                 :            :         int retval;
    4145                 :            : 
    4146                 :            :         unsigned int plaintext_pad_len;
    4147                 :            :         unsigned int plaintext_len;
    4148                 :            : 
    4149                 :            :         uint8_t buffer[10000];
    4150                 :            :         const uint8_t *ciphertext;
    4151                 :            : 
    4152                 :            :         struct rte_cryptodev_info dev_info;
    4153                 :            : 
    4154                 :            :         /* Verify the capabilities */
    4155                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4156                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4157                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    4158         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4159                 :            :                         &cap_idx) == NULL)
    4160                 :            :                 return TEST_SKIPPED;
    4161                 :            : 
    4162                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4163                 :            : 
    4164                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4165                 :            : 
    4166         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    4167                 :            :                 printf("Device doesn't support in-place scatter-gather. "
    4168                 :            :                                 "Test Skipped.\n");
    4169                 :          0 :                 return TEST_SKIPPED;
    4170                 :            :         }
    4171                 :            : 
    4172         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    4173         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    4174                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    4175                 :          0 :                 return TEST_SKIPPED;
    4176                 :            :         }
    4177                 :            : 
    4178         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4179                 :            :                 return TEST_SKIPPED;
    4180                 :            : 
    4181                 :            :         /* Create KASUMI session */
    4182                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4183                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4184                 :            :                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    4185                 :          0 :                                         tdata->key.data, tdata->key.len,
    4186                 :          0 :                                         tdata->cipher_iv.len);
    4187         [ #  # ]:          0 :         if (retval < 0)
    4188                 :            :                 return retval;
    4189                 :            : 
    4190         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4191                 :            : 
    4192                 :            : 
    4193                 :            :         /* Append data which is padded to a multiple */
    4194                 :            :         /* of the algorithms block size */
    4195                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    4196                 :            : 
    4197                 :          0 :         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    4198                 :            :                         plaintext_pad_len, 10, 0);
    4199                 :            : 
    4200                 :          0 :         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
    4201                 :            : 
    4202                 :            :         /* Create KASUMI operation */
    4203                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    4204                 :          0 :                                 tdata->cipher_iv.len,
    4205                 :          0 :                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    4206                 :          0 :                                 tdata->validCipherOffsetInBits.len);
    4207         [ #  # ]:          0 :         if (retval < 0)
    4208                 :            :                 return retval;
    4209                 :            : 
    4210         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    4211                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    4212                 :          0 :                                                tdata->cipher_iv.len);
    4213         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    4214                 :            :                         return retval;
    4215                 :            :         } else
    4216                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4217                 :            :                                                 ut_params->op);
    4218         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4219                 :            : 
    4220                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4221                 :            : 
    4222         [ #  # ]:          0 :         if (ut_params->obuf)
    4223                 :            :                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    4224                 :            :                                 plaintext_len, buffer);
    4225                 :            :         else
    4226                 :          0 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
    4227         [ #  # ]:          0 :                                 tdata->validCipherOffsetInBits.len >> 3,
    4228                 :            :                                 plaintext_len, buffer);
    4229                 :            : 
    4230                 :            :         /* Validate obuf */
    4231                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    4232                 :            : 
    4233                 :          0 :         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
    4234                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    4235                 :            :         /* Validate obuf */
    4236   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4237                 :            :                 ciphertext,
    4238                 :            :                 reference_ciphertext,
    4239                 :            :                 tdata->validCipherLenInBits.len,
    4240                 :            :                 "KASUMI Ciphertext data not as expected");
    4241                 :            :         return 0;
    4242                 :            : }
    4243                 :            : 
    4244                 :            : static int
    4245                 :          0 : test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
    4246                 :            : {
    4247                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4248                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4249                 :            : 
    4250                 :            :         int retval;
    4251                 :            :         uint8_t *plaintext, *ciphertext;
    4252                 :            :         unsigned plaintext_pad_len;
    4253                 :            :         unsigned plaintext_len;
    4254                 :            : 
    4255                 :            :         /* Verify the capabilities */
    4256                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4257                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4258                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    4259                 :            :         /* Data-path service does not support OOP */
    4260         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4261                 :            :                         &cap_idx) == NULL)
    4262                 :            :                 return TEST_SKIPPED;
    4263                 :            : 
    4264         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    4265                 :            :                 return TEST_SKIPPED;
    4266                 :            : 
    4267         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4268                 :            :                 return TEST_SKIPPED;
    4269                 :            : 
    4270                 :            :         /* Create KASUMI session */
    4271                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4272                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4273                 :            :                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    4274                 :          0 :                                         tdata->key.data, tdata->key.len,
    4275                 :          0 :                                         tdata->cipher_iv.len);
    4276         [ #  # ]:          0 :         if (retval < 0)
    4277                 :            :                 return retval;
    4278                 :            : 
    4279                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4280                 :          0 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4281                 :            : 
    4282                 :            :         /* Clear mbuf payload */
    4283         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    4284         [ #  # ]:          0 :                rte_pktmbuf_tailroom(ut_params->ibuf));
    4285                 :            : 
    4286         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4287                 :            :         /* Append data which is padded to a multiple */
    4288                 :            :         /* of the algorithms block size */
    4289                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    4290                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    4291                 :            :                                 plaintext_pad_len);
    4292                 :          0 :         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
    4293                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    4294                 :            : 
    4295                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    4296                 :            : 
    4297                 :            :         /* Create KASUMI operation */
    4298                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    4299                 :          0 :                                 tdata->cipher_iv.len,
    4300                 :          0 :                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    4301                 :          0 :                                 tdata->validCipherOffsetInBits.len);
    4302         [ #  # ]:          0 :         if (retval < 0)
    4303                 :            :                 return retval;
    4304                 :            : 
    4305                 :          0 :         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4306                 :            :                                                 ut_params->op);
    4307         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4308                 :            : 
    4309                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4310         [ #  # ]:          0 :         if (ut_params->obuf)
    4311                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    4312                 :            :         else
    4313                 :          0 :                 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
    4314                 :            : 
    4315                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    4316                 :            : 
    4317                 :          0 :         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
    4318                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    4319                 :            :         /* Validate obuf */
    4320   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4321                 :            :                 ciphertext,
    4322                 :            :                 reference_ciphertext,
    4323                 :            :                 tdata->validCipherLenInBits.len,
    4324                 :            :                 "KASUMI Ciphertext data not as expected");
    4325                 :            :         return 0;
    4326                 :            : }
    4327                 :            : 
    4328                 :            : static int
    4329                 :          0 : test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
    4330                 :            : {
    4331                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4332                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4333                 :            : 
    4334                 :            :         int retval;
    4335                 :            :         unsigned int plaintext_pad_len;
    4336                 :            :         unsigned int plaintext_len;
    4337                 :            : 
    4338                 :            :         const uint8_t *ciphertext;
    4339                 :            :         uint8_t buffer[2048];
    4340                 :            : 
    4341                 :            :         struct rte_cryptodev_info dev_info;
    4342                 :            : 
    4343                 :            :         /* Verify the capabilities */
    4344                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4345                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4346                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    4347         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4348                 :            :                         &cap_idx) == NULL)
    4349                 :            :                 return TEST_SKIPPED;
    4350                 :            : 
    4351         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    4352                 :            :                 return TEST_SKIPPED;
    4353                 :            : 
    4354         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4355                 :            :                 return TEST_SKIPPED;
    4356                 :            : 
    4357                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4358                 :            : 
    4359                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4360         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
    4361                 :            :                 printf("Device doesn't support out-of-place scatter-gather "
    4362                 :            :                                 "in both input and output mbufs. "
    4363                 :            :                                 "Test Skipped.\n");
    4364                 :          0 :                 return TEST_SKIPPED;
    4365                 :            :         }
    4366                 :            : 
    4367                 :            :         /* Create KASUMI session */
    4368                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4369                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4370                 :            :                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    4371                 :          0 :                                         tdata->key.data, tdata->key.len,
    4372                 :          0 :                                         tdata->cipher_iv.len);
    4373         [ #  # ]:          0 :         if (retval < 0)
    4374                 :            :                 return retval;
    4375                 :            : 
    4376         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4377                 :            :         /* Append data which is padded to a multiple */
    4378                 :            :         /* of the algorithms block size */
    4379                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    4380                 :            : 
    4381                 :          0 :         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    4382                 :            :                         plaintext_pad_len, 10, 0);
    4383                 :          0 :         ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
    4384                 :            :                         plaintext_pad_len, 3, 0);
    4385                 :            : 
    4386                 :            :         /* Append data which is padded to a multiple */
    4387                 :            :         /* of the algorithms block size */
    4388                 :          0 :         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
    4389                 :            : 
    4390                 :            :         /* Create KASUMI operation */
    4391                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    4392                 :          0 :                                 tdata->cipher_iv.len,
    4393                 :          0 :                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    4394                 :          0 :                                 tdata->validCipherOffsetInBits.len);
    4395         [ #  # ]:          0 :         if (retval < 0)
    4396                 :            :                 return retval;
    4397                 :            : 
    4398                 :          0 :         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4399                 :            :                                                 ut_params->op);
    4400         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4401                 :            : 
    4402                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4403         [ #  # ]:          0 :         if (ut_params->obuf)
    4404                 :            :                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    4405                 :            :                                 plaintext_pad_len, buffer);
    4406                 :            :         else
    4407                 :          0 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
    4408         [ #  # ]:          0 :                                 tdata->validCipherOffsetInBits.len >> 3,
    4409                 :            :                                 plaintext_pad_len, buffer);
    4410                 :            : 
    4411                 :          0 :         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
    4412                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    4413                 :            :         /* Validate obuf */
    4414   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4415                 :            :                 ciphertext,
    4416                 :            :                 reference_ciphertext,
    4417                 :            :                 tdata->validCipherLenInBits.len,
    4418                 :            :                 "KASUMI Ciphertext data not as expected");
    4419                 :            :         return 0;
    4420                 :            : }
    4421                 :            : 
    4422                 :            : 
    4423                 :            : static int
    4424                 :          0 : test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
    4425                 :            : {
    4426                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4427                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4428                 :            : 
    4429                 :            :         int retval;
    4430                 :            :         uint8_t *ciphertext, *plaintext;
    4431                 :            :         unsigned ciphertext_pad_len;
    4432                 :            :         unsigned ciphertext_len;
    4433                 :            : 
    4434                 :            :         /* Verify the capabilities */
    4435                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4436                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4437                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    4438         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4439                 :            :                         &cap_idx) == NULL)
    4440                 :            :                 return TEST_SKIPPED;
    4441                 :            : 
    4442         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    4443                 :            :                 return TEST_SKIPPED;
    4444                 :            : 
    4445         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4446                 :            :                 return TEST_SKIPPED;
    4447                 :            : 
    4448                 :            :         /* Create KASUMI session */
    4449                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4450                 :            :                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
    4451                 :            :                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    4452                 :          0 :                                         tdata->key.data, tdata->key.len,
    4453                 :          0 :                                         tdata->cipher_iv.len);
    4454         [ #  # ]:          0 :         if (retval < 0)
    4455                 :            :                 return retval;
    4456                 :            : 
    4457                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4458                 :          0 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4459                 :            : 
    4460                 :            :         /* Clear mbuf payload */
    4461         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    4462         [ #  # ]:          0 :                rte_pktmbuf_tailroom(ut_params->ibuf));
    4463                 :            : 
    4464         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    4465                 :            :         /* Append data which is padded to a multiple */
    4466                 :            :         /* of the algorithms block size */
    4467                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
    4468                 :          0 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    4469                 :            :                                 ciphertext_pad_len);
    4470                 :          0 :         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
    4471                 :          0 :         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    4472                 :            : 
    4473                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
    4474                 :            : 
    4475                 :            :         /* Create KASUMI operation */
    4476                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    4477                 :          0 :                                 tdata->cipher_iv.len,
    4478                 :          0 :                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    4479                 :          0 :                                 tdata->validCipherOffsetInBits.len);
    4480         [ #  # ]:          0 :         if (retval < 0)
    4481                 :            :                 return retval;
    4482                 :            : 
    4483                 :          0 :         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4484                 :            :                                                 ut_params->op);
    4485         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4486                 :            : 
    4487                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4488         [ #  # ]:          0 :         if (ut_params->obuf)
    4489                 :          0 :                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    4490                 :            :         else
    4491                 :          0 :                 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
    4492                 :            : 
    4493                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
    4494                 :            : 
    4495                 :          0 :         const uint8_t *reference_plaintext = tdata->plaintext.data +
    4496                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    4497                 :            :         /* Validate obuf */
    4498   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4499                 :            :                 plaintext,
    4500                 :            :                 reference_plaintext,
    4501                 :            :                 tdata->validCipherLenInBits.len,
    4502                 :            :                 "KASUMI Plaintext data not as expected");
    4503                 :            :         return 0;
    4504                 :            : }
    4505                 :            : 
    4506                 :            : static int
    4507                 :          0 : test_kasumi_decryption(const struct kasumi_test_data *tdata)
    4508                 :            : {
    4509                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4510                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4511                 :            : 
    4512                 :            :         int retval;
    4513                 :            :         uint8_t *ciphertext, *plaintext;
    4514                 :            :         unsigned ciphertext_pad_len;
    4515                 :            :         unsigned ciphertext_len;
    4516                 :            :         struct rte_cryptodev_info dev_info;
    4517                 :            : 
    4518                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4519                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4520                 :            : 
    4521         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    4522         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    4523                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    4524                 :          0 :                 return TEST_SKIPPED;
    4525                 :            :         }
    4526                 :            : 
    4527         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4528                 :            :                 return TEST_SKIPPED;
    4529                 :            : 
    4530                 :            :         /* Verify the capabilities */
    4531                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4532                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4533                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    4534         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4535                 :            :                         &cap_idx) == NULL)
    4536                 :            :                 return TEST_SKIPPED;
    4537                 :            : 
    4538                 :            :         /* Create KASUMI session */
    4539                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4540                 :            :                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
    4541                 :            :                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    4542                 :          0 :                                         tdata->key.data, tdata->key.len,
    4543                 :          0 :                                         tdata->cipher_iv.len);
    4544         [ #  # ]:          0 :         if (retval < 0)
    4545                 :            :                 return retval;
    4546                 :            : 
    4547         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4548                 :            : 
    4549                 :            :         /* Clear mbuf payload */
    4550         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    4551                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    4552                 :            : 
    4553         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    4554                 :            :         /* Append data which is padded to a multiple */
    4555                 :            :         /* of the algorithms block size */
    4556                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
    4557                 :          0 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    4558                 :            :                                 ciphertext_pad_len);
    4559                 :          0 :         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    4560                 :            : 
    4561                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
    4562                 :            : 
    4563                 :            :         /* Create KASUMI operation */
    4564                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    4565                 :          0 :                         tdata->cipher_iv.len,
    4566                 :          0 :                         RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    4567                 :          0 :                         tdata->validCipherOffsetInBits.len);
    4568         [ #  # ]:          0 :         if (retval < 0)
    4569                 :            :                 return retval;
    4570                 :            : 
    4571         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    4572                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    4573                 :            :                                                0);
    4574         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    4575                 :            :                         return retval;
    4576                 :            :         } else
    4577                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4578                 :            :                                                 ut_params->op);
    4579         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4580                 :            : 
    4581                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4582         [ #  # ]:          0 :         if (ut_params->obuf)
    4583                 :          0 :                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    4584                 :            :         else
    4585                 :          0 :                 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
    4586                 :            : 
    4587                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
    4588                 :            : 
    4589                 :          0 :         const uint8_t *reference_plaintext = tdata->plaintext.data +
    4590                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    4591                 :            :         /* Validate obuf */
    4592   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4593                 :            :                 plaintext,
    4594                 :            :                 reference_plaintext,
    4595                 :            :                 tdata->validCipherLenInBits.len,
    4596                 :            :                 "KASUMI Plaintext data not as expected");
    4597                 :            :         return 0;
    4598                 :            : }
    4599                 :            : 
    4600                 :            : static int
    4601                 :          0 : test_snow3g_encryption(const struct snow3g_test_data *tdata)
    4602                 :            : {
    4603                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4604                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4605                 :            : 
    4606                 :            :         int retval;
    4607                 :            :         uint8_t *plaintext, *ciphertext;
    4608                 :            :         unsigned plaintext_pad_len;
    4609                 :            :         unsigned plaintext_len;
    4610                 :            :         struct rte_cryptodev_info dev_info;
    4611                 :            : 
    4612                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4613                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4614                 :            : 
    4615         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    4616         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    4617                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    4618                 :          0 :                 return TEST_SKIPPED;
    4619                 :            :         }
    4620                 :            : 
    4621         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4622                 :            :                 return TEST_SKIPPED;
    4623                 :            : 
    4624                 :            :         /* Verify the capabilities */
    4625                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4626                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4627                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    4628         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4629                 :            :                         &cap_idx) == NULL)
    4630                 :            :                 return TEST_SKIPPED;
    4631                 :            : 
    4632                 :            :         /* Create SNOW 3G session */
    4633                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4634                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4635                 :            :                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    4636                 :          0 :                                         tdata->key.data, tdata->key.len,
    4637                 :          0 :                                         tdata->cipher_iv.len);
    4638         [ #  # ]:          0 :         if (retval < 0)
    4639                 :            :                 return retval;
    4640                 :            : 
    4641         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4642                 :            : 
    4643                 :            :         /* Clear mbuf payload */
    4644         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    4645                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    4646                 :            : 
    4647         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4648                 :            :         /* Append data which is padded to a multiple of */
    4649                 :            :         /* the algorithms block size */
    4650                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    4651                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    4652                 :            :                                 plaintext_pad_len);
    4653                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    4654                 :            : 
    4655                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    4656                 :            : 
    4657                 :            :         /* Create SNOW 3G operation */
    4658                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    4659                 :          0 :                                         tdata->cipher_iv.len,
    4660                 :          0 :                                         tdata->validCipherLenInBits.len,
    4661                 :            :                                         0);
    4662         [ #  # ]:          0 :         if (retval < 0)
    4663                 :            :                 return retval;
    4664                 :            : 
    4665         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    4666                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    4667                 :          0 :                                                tdata->cipher_iv.len);
    4668         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    4669                 :            :                         return retval;
    4670                 :            :         } else
    4671                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4672                 :            :                                                 ut_params->op);
    4673         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4674                 :            : 
    4675                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4676         [ #  # ]:          0 :         if (ut_params->obuf)
    4677                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    4678                 :            :         else
    4679                 :            :                 ciphertext = plaintext;
    4680                 :            : 
    4681                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    4682                 :            : 
    4683                 :            :         /* Validate obuf */
    4684   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4685                 :            :                 ciphertext,
    4686                 :            :                 tdata->ciphertext.data,
    4687                 :            :                 tdata->validDataLenInBits.len,
    4688                 :            :                 "SNOW 3G Ciphertext data not as expected");
    4689                 :            :         return 0;
    4690                 :            : }
    4691                 :            : 
    4692                 :            : 
    4693                 :            : static int
    4694                 :          0 : test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
    4695                 :            : {
    4696                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4697                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4698                 :            :         uint8_t *plaintext, *ciphertext;
    4699                 :            : 
    4700                 :            :         int retval;
    4701                 :            :         unsigned plaintext_pad_len;
    4702                 :            :         unsigned plaintext_len;
    4703                 :            :         struct rte_cryptodev_info dev_info;
    4704                 :            : 
    4705                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4706                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4707                 :            : 
    4708         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    4709         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    4710                 :            :                 printf("Device does not support RAW data-path APIs.\n");
    4711                 :          0 :                 return -ENOTSUP;
    4712                 :            :         }
    4713                 :            : 
    4714                 :            :         /* Verify the capabilities */
    4715                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4716                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4717                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    4718         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4719                 :            :                         &cap_idx) == NULL)
    4720                 :            :                 return TEST_SKIPPED;
    4721                 :            : 
    4722         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    4723                 :            :                 return TEST_SKIPPED;
    4724                 :            : 
    4725         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4726                 :            :                 return TEST_SKIPPED;
    4727                 :            : 
    4728                 :            :         /* Create SNOW 3G session */
    4729                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4730                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4731                 :            :                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    4732                 :          0 :                                         tdata->key.data, tdata->key.len,
    4733                 :          0 :                                         tdata->cipher_iv.len);
    4734         [ #  # ]:          0 :         if (retval < 0)
    4735                 :            :                 return retval;
    4736                 :            : 
    4737                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4738                 :          0 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4739                 :            : 
    4740         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    4741                 :            :                         "Failed to allocate input buffer in mempool");
    4742         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->obuf,
    4743                 :            :                         "Failed to allocate output buffer in mempool");
    4744                 :            : 
    4745                 :            :         /* Clear mbuf payload */
    4746         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    4747                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    4748                 :            : 
    4749         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4750                 :            :         /* Append data which is padded to a multiple of */
    4751                 :            :         /* the algorithms block size */
    4752                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    4753                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    4754                 :            :                                 plaintext_pad_len);
    4755                 :          0 :         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
    4756                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    4757                 :            : 
    4758                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    4759                 :            : 
    4760                 :            :         /* Create SNOW 3G operation */
    4761                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    4762                 :          0 :                                         tdata->cipher_iv.len,
    4763                 :          0 :                                         tdata->validCipherLenInBits.len,
    4764                 :            :                                         0);
    4765         [ #  # ]:          0 :         if (retval < 0)
    4766                 :            :                 return retval;
    4767                 :            : 
    4768         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    4769                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    4770                 :          0 :                                                tdata->cipher_iv.len);
    4771         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    4772                 :            :                         return retval;
    4773                 :            :         } else
    4774                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4775                 :            :                                                 ut_params->op);
    4776         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4777                 :            : 
    4778                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4779         [ #  # ]:          0 :         if (ut_params->obuf)
    4780                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    4781                 :            :         else
    4782                 :            :                 ciphertext = plaintext;
    4783                 :            : 
    4784                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    4785                 :            : 
    4786                 :            :         /* Validate obuf */
    4787   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4788                 :            :                 ciphertext,
    4789                 :            :                 tdata->ciphertext.data,
    4790                 :            :                 tdata->validDataLenInBits.len,
    4791                 :            :                 "SNOW 3G Ciphertext data not as expected");
    4792                 :            :         return 0;
    4793                 :            : }
    4794                 :            : 
    4795                 :            : static int
    4796                 :          0 : test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
    4797                 :            :                 uint8_t sgl_in, uint8_t sgl_out)
    4798                 :            : {
    4799                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4800                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4801                 :            : 
    4802                 :            :         int retval;
    4803                 :            :         unsigned int plaintext_pad_len;
    4804                 :            :         unsigned int plaintext_len;
    4805                 :            :         uint8_t buffer[10000];
    4806                 :            :         const uint8_t *ciphertext;
    4807                 :            : 
    4808                 :            :         struct rte_cryptodev_info dev_info;
    4809                 :            : 
    4810                 :            :         /* Verify the capabilities */
    4811                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4812                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4813                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    4814         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4815                 :            :                         &cap_idx) == NULL)
    4816                 :            :                 return TEST_SKIPPED;
    4817                 :            : 
    4818         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    4819                 :            :                 return TEST_SKIPPED;
    4820                 :            : 
    4821         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4822                 :            :                 return TEST_SKIPPED;
    4823                 :            : 
    4824                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4825                 :            : 
    4826                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4827                 :            : 
    4828   [ #  #  #  # ]:          0 :         if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
    4829         [ #  # ]:          0 :                         || ((!sgl_in && sgl_out) &&
    4830         [ #  # ]:          0 :                         !(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
    4831         [ #  # ]:          0 :                         || ((sgl_in && !sgl_out) &&
    4832         [ #  # ]:          0 :                         !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
    4833                 :            :                 printf("Device doesn't support out-of-place scatter gather type. "
    4834                 :            :                                 "Test Skipped.\n");
    4835                 :          0 :                 return TEST_SKIPPED;
    4836                 :            :         }
    4837                 :            : 
    4838         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    4839         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    4840                 :            :                 printf("Device does not support RAW data-path APIs.\n");
    4841                 :          0 :                 return -ENOTSUP;
    4842                 :            :         }
    4843                 :            : 
    4844                 :            :         /* Create SNOW 3G session */
    4845                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4846                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4847                 :            :                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    4848                 :          0 :                                         tdata->key.data, tdata->key.len,
    4849                 :          0 :                                         tdata->cipher_iv.len);
    4850         [ #  # ]:          0 :         if (retval < 0)
    4851                 :            :                 return retval;
    4852                 :            : 
    4853         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    4854                 :            :         /* Append data which is padded to a multiple of */
    4855                 :            :         /* the algorithms block size */
    4856                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    4857                 :            : 
    4858         [ #  # ]:          0 :         if (sgl_in)
    4859                 :          0 :                 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    4860                 :            :                                 plaintext_pad_len, 10, 0);
    4861                 :            :         else {
    4862                 :          0 :                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4863                 :            :                 rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
    4864                 :            :         }
    4865                 :            : 
    4866         [ #  # ]:          0 :         if (sgl_out)
    4867                 :          0 :                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
    4868                 :            :                                 plaintext_pad_len, 3, 0);
    4869                 :            :         else {
    4870                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4871                 :            :                 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
    4872                 :            :         }
    4873                 :            : 
    4874         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    4875                 :            :                         "Failed to allocate input buffer in mempool");
    4876         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->obuf,
    4877                 :            :                         "Failed to allocate output buffer in mempool");
    4878                 :            : 
    4879                 :          0 :         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
    4880                 :            : 
    4881                 :            :         /* Create SNOW 3G operation */
    4882                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    4883                 :          0 :                                         tdata->cipher_iv.len,
    4884                 :          0 :                                         tdata->validCipherLenInBits.len,
    4885                 :            :                                         0);
    4886         [ #  # ]:          0 :         if (retval < 0)
    4887                 :            :                 return retval;
    4888                 :            : 
    4889         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    4890                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    4891                 :          0 :                                                tdata->cipher_iv.len);
    4892         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    4893                 :            :                         return retval;
    4894                 :            :         } else
    4895                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    4896                 :            :                                                 ut_params->op);
    4897         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    4898                 :            : 
    4899                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    4900         [ #  # ]:          0 :         if (ut_params->obuf)
    4901                 :            :                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    4902                 :            :                                 plaintext_len, buffer);
    4903                 :            :         else
    4904         [ #  # ]:          0 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    4905                 :            :                                 plaintext_len, buffer);
    4906                 :            : 
    4907                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    4908                 :            : 
    4909                 :            :         /* Validate obuf */
    4910   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    4911                 :            :                 ciphertext,
    4912                 :            :                 tdata->ciphertext.data,
    4913                 :            :                 tdata->validDataLenInBits.len,
    4914                 :            :                 "SNOW 3G Ciphertext data not as expected");
    4915                 :            : 
    4916                 :            :         return 0;
    4917                 :            : }
    4918                 :            : 
    4919                 :            : /* Shift right a buffer by "offset" bits, "offset" < 8 */
    4920                 :            : static void
    4921                 :          0 : buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
    4922                 :            : {
    4923                 :            :         uint8_t curr_byte, prev_byte;
    4924         [ #  # ]:          0 :         uint32_t length_in_bytes = ceil_byte_length(length + offset);
    4925                 :          0 :         uint8_t lower_byte_mask = (1 << offset) - 1;
    4926                 :            :         unsigned i;
    4927                 :            : 
    4928                 :          0 :         prev_byte = buffer[0];
    4929                 :          0 :         buffer[0] >>= offset;
    4930                 :            : 
    4931         [ #  # ]:          0 :         for (i = 1; i < length_in_bytes; i++) {
    4932                 :          0 :                 curr_byte = buffer[i];
    4933                 :          0 :                 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
    4934                 :          0 :                                 (curr_byte >> offset);
    4935                 :            :                 prev_byte = curr_byte;
    4936                 :            :         }
    4937                 :          0 : }
    4938                 :            : 
    4939                 :            : static int
    4940                 :          0 : test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
    4941                 :            : {
    4942                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    4943                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    4944                 :            :         uint8_t *plaintext, *ciphertext;
    4945                 :            :         int retval;
    4946                 :            :         uint32_t plaintext_len;
    4947                 :            :         uint32_t plaintext_pad_len;
    4948                 :            :         uint8_t extra_offset = 4;
    4949                 :            :         uint8_t *expected_ciphertext_shifted;
    4950                 :            :         struct rte_cryptodev_info dev_info;
    4951                 :            : 
    4952                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    4953                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    4954                 :            : 
    4955         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
    4956         [ #  # ]:          0 :                         ((tdata->validDataLenInBits.len % 8) != 0)) {
    4957                 :            :                 printf("Device doesn't support NON-Byte Aligned Data.\n");
    4958                 :          0 :                 return TEST_SKIPPED;
    4959                 :            :         }
    4960                 :            : 
    4961                 :            :         /* Verify the capabilities */
    4962                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    4963                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    4964                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    4965         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    4966                 :            :                         &cap_idx) == NULL)
    4967                 :            :                 return TEST_SKIPPED;
    4968                 :            : 
    4969         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    4970                 :            :                 return TEST_SKIPPED;
    4971                 :            : 
    4972         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    4973                 :            :                 return TEST_SKIPPED;
    4974                 :            : 
    4975                 :            :         /* Create SNOW 3G session */
    4976                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    4977                 :            :                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    4978                 :            :                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    4979                 :          0 :                                         tdata->key.data, tdata->key.len,
    4980                 :          0 :                                         tdata->cipher_iv.len);
    4981         [ #  # ]:          0 :         if (retval < 0)
    4982                 :            :                 return retval;
    4983                 :            : 
    4984                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4985                 :          0 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    4986                 :            : 
    4987         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    4988                 :            :                         "Failed to allocate input buffer in mempool");
    4989         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->obuf,
    4990                 :            :                         "Failed to allocate output buffer in mempool");
    4991                 :            : 
    4992                 :            :         /* Clear mbuf payload */
    4993         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    4994                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    4995                 :            : 
    4996         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
    4997                 :            :         /*
    4998                 :            :          * Append data which is padded to a
    4999                 :            :          * multiple of the algorithms block size
    5000                 :            :          */
    5001                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    5002                 :            : 
    5003                 :          0 :         plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
    5004                 :            :                                                 plaintext_pad_len);
    5005                 :            : 
    5006                 :          0 :         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
    5007                 :            : 
    5008                 :          0 :         memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
    5009                 :          0 :         buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
    5010                 :            : 
    5011                 :            : #ifdef RTE_APP_TEST_DEBUG
    5012                 :            :         rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
    5013                 :            : #endif
    5014                 :            :         /* Create SNOW 3G operation */
    5015                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    5016                 :          0 :                                         tdata->cipher_iv.len,
    5017                 :          0 :                                         tdata->validCipherLenInBits.len,
    5018                 :            :                                         extra_offset);
    5019         [ #  # ]:          0 :         if (retval < 0)
    5020                 :            :                 return retval;
    5021                 :            : 
    5022         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5023                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    5024                 :          0 :                                                tdata->cipher_iv.len);
    5025         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5026                 :            :                         return retval;
    5027                 :            :         } else
    5028                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5029                 :            :                                                 ut_params->op);
    5030         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5031                 :            : 
    5032                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    5033         [ #  # ]:          0 :         if (ut_params->obuf)
    5034                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    5035                 :            :         else
    5036                 :            :                 ciphertext = plaintext;
    5037                 :            : 
    5038                 :            : #ifdef RTE_APP_TEST_DEBUG
    5039                 :            :         rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    5040                 :            : #endif
    5041                 :            : 
    5042                 :          0 :         expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
    5043                 :            : 
    5044         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
    5045                 :            :                         "failed to reserve memory for ciphertext shifted\n");
    5046                 :            : 
    5047                 :          0 :         memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
    5048         [ #  # ]:          0 :                         ceil_byte_length(tdata->ciphertext.len));
    5049                 :          0 :         buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
    5050                 :            :                         extra_offset);
    5051                 :            :         /* Validate obuf */
    5052   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
             #  #  #  # ]
    5053                 :            :                 ciphertext,
    5054                 :            :                 expected_ciphertext_shifted,
    5055                 :            :                 tdata->validDataLenInBits.len,
    5056                 :            :                 extra_offset,
    5057                 :            :                 "SNOW 3G Ciphertext data not as expected");
    5058                 :            :         return 0;
    5059                 :            : }
    5060                 :            : 
    5061                 :          0 : static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
    5062                 :            : {
    5063                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5064                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5065                 :            : 
    5066                 :            :         int retval;
    5067                 :            : 
    5068                 :            :         uint8_t *plaintext, *ciphertext;
    5069                 :            :         unsigned ciphertext_pad_len;
    5070                 :            :         unsigned ciphertext_len;
    5071                 :            :         struct rte_cryptodev_info dev_info;
    5072                 :            : 
    5073                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5074                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5075                 :            : 
    5076         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5077         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5078                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    5079                 :          0 :                 return TEST_SKIPPED;
    5080                 :            :         }
    5081                 :            : 
    5082         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5083                 :            :                 return TEST_SKIPPED;
    5084                 :            : 
    5085                 :            :         /* Verify the capabilities */
    5086                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    5087                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    5088                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    5089         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5090                 :            :                         &cap_idx) == NULL)
    5091                 :            :                 return TEST_SKIPPED;
    5092                 :            : 
    5093                 :            :         /* Create SNOW 3G session */
    5094                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    5095                 :            :                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
    5096                 :            :                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    5097                 :          0 :                                         tdata->key.data, tdata->key.len,
    5098                 :          0 :                                         tdata->cipher_iv.len);
    5099         [ #  # ]:          0 :         if (retval < 0)
    5100                 :            :                 return retval;
    5101                 :            : 
    5102         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5103                 :            : 
    5104                 :            :         /* Clear mbuf payload */
    5105         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    5106                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    5107                 :            : 
    5108         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    5109                 :            :         /* Append data which is padded to a multiple of */
    5110                 :            :         /* the algorithms block size */
    5111                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    5112                 :          0 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5113                 :            :                                 ciphertext_pad_len);
    5114                 :          0 :         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    5115                 :            : 
    5116                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
    5117                 :            : 
    5118                 :            :         /* Create SNOW 3G operation */
    5119                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    5120                 :          0 :                                         tdata->cipher_iv.len,
    5121                 :          0 :                                         tdata->validCipherLenInBits.len,
    5122                 :          0 :                                         tdata->cipher.offset_bits);
    5123         [ #  # ]:          0 :         if (retval < 0)
    5124                 :            :                 return retval;
    5125                 :            : 
    5126         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5127                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    5128                 :          0 :                                                tdata->cipher_iv.len);
    5129         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5130                 :            :                         return retval;
    5131                 :            :         } else
    5132                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5133                 :            :                                                 ut_params->op);
    5134         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5135                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    5136         [ #  # ]:          0 :         if (ut_params->obuf)
    5137                 :          0 :                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    5138                 :            :         else
    5139                 :            :                 plaintext = ciphertext;
    5140                 :            : 
    5141                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
    5142                 :            : 
    5143                 :            :         /* Validate obuf */
    5144   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
                   #  # ]
    5145                 :            :                                 tdata->plaintext.data,
    5146                 :            :                                 tdata->validDataLenInBits.len,
    5147                 :            :                                 "SNOW 3G Plaintext data not as expected");
    5148                 :            :         return 0;
    5149                 :            : }
    5150                 :            : 
    5151                 :          0 : static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
    5152                 :            : {
    5153                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5154                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5155                 :            : 
    5156                 :            :         int retval;
    5157                 :            : 
    5158                 :            :         uint8_t *plaintext, *ciphertext;
    5159                 :            :         unsigned ciphertext_pad_len;
    5160                 :            :         unsigned ciphertext_len;
    5161                 :            :         struct rte_cryptodev_info dev_info;
    5162                 :            : 
    5163                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5164                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5165                 :            : 
    5166         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5167         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5168                 :            :                 printf("Device does not support RAW data-path APIs.\n");
    5169                 :          0 :                 return -ENOTSUP;
    5170                 :            :         }
    5171                 :            :         /* Verify the capabilities */
    5172                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    5173                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    5174                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    5175         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5176                 :            :                         &cap_idx) == NULL)
    5177                 :            :                 return TEST_SKIPPED;
    5178                 :            : 
    5179         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    5180                 :            :                 return TEST_SKIPPED;
    5181                 :            : 
    5182         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5183                 :            :                 return TEST_SKIPPED;
    5184                 :            : 
    5185                 :            :         /* Create SNOW 3G session */
    5186                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    5187                 :            :                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
    5188                 :            :                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    5189                 :          0 :                                         tdata->key.data, tdata->key.len,
    5190                 :          0 :                                         tdata->cipher_iv.len);
    5191         [ #  # ]:          0 :         if (retval < 0)
    5192                 :            :                 return retval;
    5193                 :            : 
    5194                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5195                 :          0 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5196                 :            : 
    5197         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    5198                 :            :                         "Failed to allocate input buffer");
    5199         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->obuf,
    5200                 :            :                         "Failed to allocate output buffer");
    5201                 :            : 
    5202                 :            :         /* Clear mbuf payload */
    5203         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    5204                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    5205                 :            : 
    5206                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
    5207                 :          0 :                        rte_pktmbuf_tailroom(ut_params->obuf));
    5208                 :            : 
    5209         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    5210                 :            :         /* Append data which is padded to a multiple of */
    5211                 :            :         /* the algorithms block size */
    5212                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    5213                 :          0 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5214                 :            :                                 ciphertext_pad_len);
    5215                 :          0 :         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
    5216                 :          0 :         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    5217                 :            : 
    5218                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
    5219                 :            : 
    5220                 :            :         /* Create SNOW 3G operation */
    5221                 :          0 :         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
    5222                 :          0 :                                         tdata->cipher_iv.len,
    5223                 :          0 :                                         tdata->validCipherLenInBits.len,
    5224                 :            :                                         0);
    5225         [ #  # ]:          0 :         if (retval < 0)
    5226                 :            :                 return retval;
    5227                 :            : 
    5228         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5229                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    5230                 :          0 :                                                tdata->cipher_iv.len);
    5231         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5232                 :            :                         return retval;
    5233                 :            :         } else
    5234                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5235                 :            :                                                 ut_params->op);
    5236         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5237                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    5238         [ #  # ]:          0 :         if (ut_params->obuf)
    5239                 :          0 :                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    5240                 :            :         else
    5241                 :            :                 plaintext = ciphertext;
    5242                 :            : 
    5243                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
    5244                 :            : 
    5245                 :            :         /* Validate obuf */
    5246   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
                   #  # ]
    5247                 :            :                                 tdata->plaintext.data,
    5248                 :            :                                 tdata->validDataLenInBits.len,
    5249                 :            :                                 "SNOW 3G Plaintext data not as expected");
    5250                 :            :         return 0;
    5251                 :            : }
    5252                 :            : 
    5253                 :            : static int
    5254                 :          0 : test_zuc_cipher_auth(const struct wireless_test_data *tdata)
    5255                 :            : {
    5256                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5257                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5258                 :            : 
    5259                 :            :         int retval;
    5260                 :            : 
    5261                 :            :         uint8_t *plaintext, *ciphertext;
    5262                 :            :         unsigned int plaintext_pad_len;
    5263                 :            :         unsigned int plaintext_len;
    5264                 :            : 
    5265                 :            :         struct rte_cryptodev_info dev_info;
    5266                 :            : 
    5267                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5268                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5269                 :            : 
    5270         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
    5271         [ #  # ]:          0 :                         ((tdata->validAuthLenInBits.len % 8 != 0) ||
    5272         [ #  # ]:          0 :                         (tdata->validDataLenInBits.len % 8 != 0))) {
    5273                 :            :                 printf("Device doesn't support NON-Byte Aligned Data.\n");
    5274                 :          0 :                 return TEST_SKIPPED;
    5275                 :            :         }
    5276                 :            : 
    5277         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5278         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5279                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    5280                 :          0 :                 return TEST_SKIPPED;
    5281                 :            :         }
    5282                 :            : 
    5283         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5284                 :            :                 return TEST_SKIPPED;
    5285                 :            : 
    5286                 :            :         /* Check if device supports ZUC EEA3 */
    5287         [ #  # ]:          0 :         if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
    5288                 :          0 :                         tdata->key.len, tdata->cipher_iv.len) < 0)
    5289                 :            :                 return TEST_SKIPPED;
    5290                 :            : 
    5291                 :            :         /* Check if device supports ZUC EIA3 */
    5292         [ #  # ]:          0 :         if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
    5293                 :          0 :                         tdata->key.len, tdata->auth_iv.len,
    5294                 :          0 :                         tdata->digest.len) < 0)
    5295                 :            :                 return TEST_SKIPPED;
    5296                 :            : 
    5297                 :            :         /* Create ZUC session */
    5298                 :          0 :         retval = create_zuc_cipher_auth_encrypt_generate_session(
    5299                 :          0 :                         ts_params->valid_devs[0],
    5300                 :            :                         tdata);
    5301         [ #  # ]:          0 :         if (retval != 0)
    5302                 :            :                 return retval;
    5303         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5304                 :            : 
    5305                 :            :         /* clear mbuf payload */
    5306         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    5307                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
    5308                 :            : 
    5309         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    5310                 :            :         /* Append data which is padded to a multiple of */
    5311                 :            :         /* the algorithms block size */
    5312                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    5313                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5314                 :            :                                 plaintext_pad_len);
    5315                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    5316                 :            : 
    5317                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    5318                 :            : 
    5319                 :            :         /* Create ZUC operation */
    5320                 :            :         retval = create_zuc_cipher_hash_generate_operation(tdata);
    5321         [ #  # ]:          0 :         if (retval < 0)
    5322                 :            :                 return retval;
    5323                 :            : 
    5324         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5325                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    5326                 :          0 :                                                tdata->cipher_iv.len);
    5327         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5328                 :            :                         return retval;
    5329                 :            :         } else
    5330                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5331                 :            :                         ut_params->op);
    5332         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5333                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    5334         [ #  # ]:          0 :         if (ut_params->obuf)
    5335                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    5336                 :            :         else
    5337                 :            :                 ciphertext = plaintext;
    5338                 :            : 
    5339                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    5340                 :            :         /* Validate obuf */
    5341   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    5342                 :            :                         ciphertext,
    5343                 :            :                         tdata->ciphertext.data,
    5344                 :            :                         tdata->validDataLenInBits.len,
    5345                 :            :                         "ZUC Ciphertext data not as expected");
    5346                 :            : 
    5347                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    5348                 :            :                                                     uint8_t *,
    5349                 :            :                                                     plaintext_pad_len);
    5350                 :            : 
    5351                 :            :         /* Validate obuf */
    5352         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    5353                 :            :                         ut_params->digest,
    5354                 :            :                         tdata->digest.data,
    5355                 :            :                         tdata->digest.len,
    5356                 :            :                         "ZUC Generated auth tag not as expected");
    5357                 :            :         return 0;
    5358                 :            : }
    5359                 :            : 
    5360                 :            : static int
    5361                 :          0 : test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
    5362                 :            : {
    5363                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5364                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5365                 :            : 
    5366                 :            :         int retval;
    5367                 :            : 
    5368                 :            :         uint8_t *plaintext, *ciphertext;
    5369                 :            :         unsigned plaintext_pad_len;
    5370                 :            :         unsigned plaintext_len;
    5371                 :            :         struct rte_cryptodev_info dev_info;
    5372                 :            : 
    5373                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5374                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5375                 :            : 
    5376         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5377         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5378                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    5379                 :          0 :                 return TEST_SKIPPED;
    5380                 :            :         }
    5381                 :            : 
    5382         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5383                 :            :                 return TEST_SKIPPED;
    5384                 :            : 
    5385                 :            :         /* Verify the capabilities */
    5386                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    5387                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    5388                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
    5389         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5390                 :            :                         &cap_idx) == NULL)
    5391                 :            :                 return TEST_SKIPPED;
    5392                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    5393                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    5394         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5395                 :            :                         &cap_idx) == NULL)
    5396                 :            :                 return TEST_SKIPPED;
    5397                 :            : 
    5398                 :            :         /* Create SNOW 3G session */
    5399                 :          0 :         retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
    5400                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    5401                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
    5402                 :            :                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
    5403                 :            :                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    5404                 :            :                         tdata->key.data, tdata->key.len,
    5405                 :          0 :                         tdata->key.data, tdata->key.len,
    5406                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    5407                 :          0 :                         tdata->cipher_iv.len);
    5408         [ #  # ]:          0 :         if (retval != 0)
    5409                 :            :                 return retval;
    5410         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5411                 :            : 
    5412                 :            :         /* clear mbuf payload */
    5413         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    5414                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
    5415                 :            : 
    5416         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    5417                 :            :         /* Append data which is padded to a multiple of */
    5418                 :            :         /* the algorithms block size */
    5419                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    5420                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5421                 :            :                                 plaintext_pad_len);
    5422                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    5423                 :            : 
    5424                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    5425                 :            : 
    5426                 :            :         /* Create SNOW 3G operation */
    5427                 :          0 :         retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
    5428                 :          0 :                         tdata->digest.len, tdata->auth_iv.data,
    5429                 :          0 :                         tdata->auth_iv.len,
    5430                 :            :                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
    5431                 :          0 :                         tdata->cipher_iv.data, tdata->cipher_iv.len,
    5432                 :          0 :                         tdata->validCipherLenInBits.len,
    5433                 :            :                         0,
    5434                 :          0 :                         tdata->validAuthLenInBits.len,
    5435                 :            :                         0
    5436                 :            :                         );
    5437         [ #  # ]:          0 :         if (retval < 0)
    5438                 :            :                 return retval;
    5439                 :            : 
    5440         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5441                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    5442                 :          0 :                                                tdata->cipher_iv.len);
    5443         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5444                 :            :                         return retval;
    5445                 :            :         } else
    5446                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5447                 :            :                         ut_params->op);
    5448         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5449                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    5450         [ #  # ]:          0 :         if (ut_params->obuf)
    5451                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    5452                 :            :         else
    5453                 :            :                 ciphertext = plaintext;
    5454                 :            : 
    5455                 :          0 :         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    5456                 :            :         /* Validate obuf */
    5457   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    5458                 :            :                         ciphertext,
    5459                 :            :                         tdata->ciphertext.data,
    5460                 :            :                         tdata->validDataLenInBits.len,
    5461                 :            :                         "SNOW 3G Ciphertext data not as expected");
    5462                 :            : 
    5463                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    5464                 :            :                                                     uint8_t *,
    5465                 :            :                                                     plaintext_pad_len);
    5466                 :            : 
    5467                 :            :         /* Validate obuf */
    5468         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    5469                 :            :                         ut_params->digest,
    5470                 :            :                         tdata->digest.data,
    5471                 :            :                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
    5472                 :            :                         "SNOW 3G Generated auth tag not as expected");
    5473                 :            :         return 0;
    5474                 :            : }
    5475                 :            : 
    5476                 :            : static int
    5477                 :          0 : test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
    5478                 :            :         uint8_t op_mode, uint8_t verify)
    5479                 :            : {
    5480                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5481                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5482                 :            : 
    5483                 :            :         int retval;
    5484                 :            : 
    5485                 :            :         uint8_t *plaintext = NULL, *ciphertext = NULL;
    5486                 :            :         unsigned int plaintext_pad_len;
    5487                 :            :         unsigned int plaintext_len;
    5488                 :            :         unsigned int ciphertext_pad_len;
    5489                 :            :         unsigned int ciphertext_len;
    5490                 :            :         unsigned int digest_offset;
    5491                 :            : 
    5492                 :            :         struct rte_cryptodev_info dev_info;
    5493                 :            : 
    5494                 :            :         /* Verify the capabilities */
    5495                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    5496                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    5497                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
    5498         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5499                 :            :                         &cap_idx) == NULL)
    5500                 :            :                 return TEST_SKIPPED;
    5501                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    5502                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    5503         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5504                 :            :                         &cap_idx) == NULL)
    5505                 :            :                 return TEST_SKIPPED;
    5506                 :            : 
    5507         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5508                 :            :                 return TEST_SKIPPED;
    5509                 :            : 
    5510                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5511                 :            : 
    5512                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5513                 :            : 
    5514         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE) {
    5515         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    5516                 :            :                         printf("Device doesn't support digest encrypted.\n");
    5517                 :          0 :                         return TEST_SKIPPED;
    5518                 :            :                 }
    5519         [ #  # ]:          0 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    5520                 :            :                         return TEST_SKIPPED;
    5521                 :            :         }
    5522                 :            : 
    5523         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5524         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5525                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    5526                 :          0 :                 return TEST_SKIPPED;
    5527                 :            :         }
    5528                 :            : 
    5529                 :            :         /* Create SNOW 3G session */
    5530                 :          0 :         retval = create_wireless_algo_auth_cipher_session(
    5531                 :          0 :                         ts_params->valid_devs[0],
    5532                 :            :                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
    5533                 :            :                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
    5534                 :            :                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
    5535                 :            :                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
    5536                 :            :                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
    5537                 :            :                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    5538                 :            :                         tdata->key.data, tdata->key.len,
    5539                 :          0 :                         tdata->key.data, tdata->key.len,
    5540                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    5541                 :          0 :                         tdata->cipher_iv.len);
    5542         [ #  # ]:          0 :         if (retval != 0)
    5543                 :            :                 return retval;
    5544                 :            : 
    5545                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5546         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    5547                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5548                 :            : 
    5549                 :            :         /* clear mbuf payload */
    5550         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    5551         [ #  # ]:          0 :                 rte_pktmbuf_tailroom(ut_params->ibuf));
    5552         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    5553                 :          0 :                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
    5554                 :          0 :                         rte_pktmbuf_tailroom(ut_params->obuf));
    5555                 :            : 
    5556         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    5557         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    5558                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    5559                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    5560                 :            : 
    5561         [ #  # ]:          0 :         if (verify) {
    5562                 :          0 :                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5563                 :            :                                         ciphertext_pad_len);
    5564         [ #  # ]:          0 :                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    5565         [ #  # ]:          0 :                 if (op_mode == OUT_OF_PLACE)
    5566                 :          0 :                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
    5567                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    5568                 :            :                         ciphertext_len);
    5569                 :            :         } else {
    5570                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5571                 :            :                                         plaintext_pad_len);
    5572         [ #  # ]:          0 :                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    5573         [ #  # ]:          0 :                 if (op_mode == OUT_OF_PLACE)
    5574                 :          0 :                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
    5575                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    5576                 :            :         }
    5577                 :            : 
    5578                 :            :         /* Create SNOW 3G operation */
    5579                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    5580                 :          0 :                 tdata->digest.data, tdata->digest.len,
    5581                 :          0 :                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    5582                 :          0 :                 tdata->auth_iv.data, tdata->auth_iv.len,
    5583                 :          0 :                 (tdata->digest.offset_bytes == 0 ?
    5584         [ #  # ]:          0 :                 (verify ? ciphertext_pad_len : plaintext_pad_len)
    5585                 :            :                         : tdata->digest.offset_bytes),
    5586                 :          0 :                 tdata->validCipherLenInBits.len,
    5587                 :          0 :                 tdata->cipher.offset_bits,
    5588                 :          0 :                 tdata->validAuthLenInBits.len,
    5589         [ #  # ]:          0 :                 tdata->auth.offset_bits,
    5590                 :            :                 op_mode, 0, verify);
    5591                 :            : 
    5592         [ #  # ]:          0 :         if (retval < 0)
    5593                 :            :                 return retval;
    5594                 :            : 
    5595         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5596                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    5597                 :          0 :                                                tdata->cipher_iv.len);
    5598         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5599                 :            :                         return retval;
    5600                 :            :         } else
    5601                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5602                 :            :                         ut_params->op);
    5603                 :            : 
    5604         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5605                 :            : 
    5606                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    5607         [ #  # ]:          0 :                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    5608                 :            : 
    5609         [ #  # ]:          0 :         if (verify) {
    5610         [ #  # ]:          0 :                 if (ut_params->obuf)
    5611                 :          0 :                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
    5612                 :            :                                                         uint8_t *);
    5613                 :            :                 else
    5614                 :          0 :                         plaintext = ciphertext +
    5615                 :          0 :                                 (tdata->cipher.offset_bits >> 3);
    5616                 :            : 
    5617                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    5618                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    5619                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    5620                 :          0 :                         tdata->plaintext.data,
    5621                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    5622                 :            :         } else {
    5623         [ #  # ]:          0 :                 if (ut_params->obuf)
    5624                 :          0 :                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
    5625                 :            :                                                         uint8_t *);
    5626                 :            :                 else
    5627                 :            :                         ciphertext = plaintext;
    5628                 :            : 
    5629                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    5630                 :            :                         ciphertext_len);
    5631                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    5632                 :          0 :                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
    5633                 :            : 
    5634         [ #  # ]:          0 :                 if (tdata->digest.offset_bytes == 0)
    5635                 :            :                         digest_offset = plaintext_pad_len;
    5636                 :            :                 else
    5637                 :            :                         digest_offset = tdata->digest.offset_bytes;
    5638                 :          0 :                 ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    5639                 :            :                                                     uint8_t *, digest_offset);
    5640                 :            : 
    5641                 :          0 :                 debug_hexdump(stdout, "digest:", ut_params->digest,
    5642                 :          0 :                         tdata->digest.len);
    5643                 :          0 :                 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
    5644                 :          0 :                                 tdata->digest.len);
    5645                 :            :         }
    5646                 :            : 
    5647                 :            :         /* Validate obuf */
    5648         [ #  # ]:          0 :         if (verify) {
    5649   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
          #  #  #  #  #  
             #  #  #  #  
                      # ]
    5650                 :            :                         plaintext,
    5651                 :            :                         tdata->plaintext.data,
    5652                 :            :                         (tdata->plaintext.len - tdata->cipher.offset_bits -
    5653                 :            :                          (tdata->digest.len << 3)),
    5654                 :            :                         tdata->cipher.offset_bits,
    5655                 :            :                         "SNOW 3G Plaintext data not as expected");
    5656                 :            :         } else {
    5657   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
          #  #  #  #  #  
             #  #  #  #  
                      # ]
    5658                 :            :                         ciphertext,
    5659                 :            :                         tdata->ciphertext.data,
    5660                 :            :                         (tdata->validDataLenInBits.len -
    5661                 :            :                          tdata->cipher.offset_bits),
    5662                 :            :                         tdata->cipher.offset_bits,
    5663                 :            :                         "SNOW 3G Ciphertext data not as expected");
    5664                 :            : 
    5665         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    5666                 :            :                         ut_params->digest,
    5667                 :            :                         tdata->digest.data,
    5668                 :            :                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
    5669                 :            :                         "SNOW 3G Generated auth tag not as expected");
    5670                 :            :         }
    5671                 :            :         return 0;
    5672                 :            : }
    5673                 :            : 
    5674                 :            : static int
    5675                 :          0 : test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
    5676                 :            :         uint8_t op_mode, uint8_t verify)
    5677                 :            : {
    5678                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5679                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5680                 :            : 
    5681                 :            :         int retval;
    5682                 :            : 
    5683                 :            :         const uint8_t *plaintext = NULL;
    5684                 :            :         const uint8_t *ciphertext = NULL;
    5685                 :            :         const uint8_t *digest = NULL;
    5686                 :            :         unsigned int plaintext_pad_len;
    5687                 :            :         unsigned int plaintext_len;
    5688                 :            :         unsigned int ciphertext_pad_len;
    5689                 :            :         unsigned int ciphertext_len;
    5690                 :            :         uint8_t buffer[10000];
    5691                 :            :         uint8_t digest_buffer[10000];
    5692                 :            : 
    5693                 :            :         struct rte_cryptodev_info dev_info;
    5694                 :            : 
    5695                 :            :         /* Verify the capabilities */
    5696                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    5697                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    5698                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
    5699         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5700                 :            :                         &cap_idx) == NULL)
    5701                 :            :                 return TEST_SKIPPED;
    5702                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    5703                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
    5704         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5705                 :            :                         &cap_idx) == NULL)
    5706                 :            :                 return TEST_SKIPPED;
    5707                 :            : 
    5708         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5709                 :            :                 return TEST_SKIPPED;
    5710                 :            : 
    5711                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5712                 :            : 
    5713                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5714                 :            : 
    5715         [ #  # ]:          0 :         if (op_mode == IN_PLACE) {
    5716         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    5717                 :            :                         printf("Device doesn't support in-place scatter-gather "
    5718                 :            :                                         "in both input and output mbufs.\n");
    5719                 :          0 :                         return TEST_SKIPPED;
    5720                 :            :                 }
    5721         [ #  # ]:          0 :                 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5722         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5723                 :            :                         printf("Device doesn't support RAW data-path APIs.\n");
    5724                 :          0 :                         return TEST_SKIPPED;
    5725                 :            :                 }
    5726                 :            :         } else {
    5727         [ #  # ]:          0 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    5728                 :            :                         return TEST_SKIPPED;
    5729         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
    5730                 :            :                         printf("Device doesn't support out-of-place scatter-gather "
    5731                 :            :                                         "in both input and output mbufs.\n");
    5732                 :          0 :                         return TEST_SKIPPED;
    5733                 :            :                 }
    5734         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    5735                 :            :                         printf("Device doesn't support digest encrypted.\n");
    5736                 :          0 :                         return TEST_SKIPPED;
    5737                 :            :                 }
    5738                 :            :         }
    5739                 :            : 
    5740                 :            :         /* Create SNOW 3G session */
    5741                 :          0 :         retval = create_wireless_algo_auth_cipher_session(
    5742                 :          0 :                         ts_params->valid_devs[0],
    5743                 :            :                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
    5744                 :            :                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
    5745                 :            :                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
    5746                 :            :                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
    5747                 :            :                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
    5748                 :            :                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
    5749                 :            :                         tdata->key.data, tdata->key.len,
    5750                 :          0 :                         tdata->key.data, tdata->key.len,
    5751                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    5752                 :          0 :                         tdata->cipher_iv.len);
    5753                 :            : 
    5754         [ #  # ]:          0 :         if (retval != 0)
    5755                 :            :                 return retval;
    5756                 :            : 
    5757         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    5758         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    5759                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    5760                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    5761                 :            : 
    5762                 :          0 :         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    5763                 :            :                         plaintext_pad_len, 15, 0);
    5764         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    5765                 :            :                         "Failed to allocate input buffer in mempool");
    5766                 :            : 
    5767         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE) {
    5768                 :          0 :                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
    5769                 :            :                                 plaintext_pad_len, 15, 0);
    5770         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
    5771                 :            :                                 "Failed to allocate output buffer in mempool");
    5772                 :            :         }
    5773                 :            : 
    5774         [ #  # ]:          0 :         if (verify) {
    5775                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
    5776                 :          0 :                         tdata->ciphertext.data);
    5777         [ #  # ]:          0 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    5778                 :            :                                         ciphertext_len, buffer);
    5779                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    5780                 :            :                         ciphertext_len);
    5781                 :            :         } else {
    5782                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
    5783                 :          0 :                         tdata->plaintext.data);
    5784         [ #  # ]:          0 :                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    5785                 :            :                                         plaintext_len, buffer);
    5786                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    5787                 :            :                         plaintext_len);
    5788                 :            :         }
    5789                 :            :         memset(buffer, 0, sizeof(buffer));
    5790                 :            : 
    5791                 :            :         /* Create SNOW 3G operation */
    5792                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    5793                 :          0 :                 tdata->digest.data, tdata->digest.len,
    5794                 :          0 :                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    5795                 :          0 :                 tdata->auth_iv.data, tdata->auth_iv.len,
    5796                 :          0 :                 (tdata->digest.offset_bytes == 0 ?
    5797         [ #  # ]:          0 :                 (verify ? ciphertext_pad_len : plaintext_pad_len)
    5798                 :            :                         : tdata->digest.offset_bytes),
    5799                 :          0 :                 tdata->validCipherLenInBits.len,
    5800                 :          0 :                 tdata->cipher.offset_bits,
    5801                 :          0 :                 tdata->validAuthLenInBits.len,
    5802         [ #  # ]:          0 :                 tdata->auth.offset_bits,
    5803                 :            :                 op_mode, 1, verify);
    5804                 :            : 
    5805         [ #  # ]:          0 :         if (retval < 0)
    5806                 :            :                 return retval;
    5807                 :            : 
    5808         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    5809                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    5810                 :          0 :                                                tdata->cipher_iv.len);
    5811         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    5812                 :            :                         return retval;
    5813                 :            :         } else
    5814                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    5815                 :            :                         ut_params->op);
    5816                 :            : 
    5817         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    5818                 :            : 
    5819                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    5820         [ #  # ]:          0 :                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    5821                 :            : 
    5822         [ #  # ]:          0 :         if (verify) {
    5823         [ #  # ]:          0 :                 if (ut_params->obuf)
    5824                 :            :                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
    5825                 :            :                                         plaintext_len, buffer);
    5826                 :            :                 else
    5827         [ #  # ]:          0 :                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    5828                 :            :                                         plaintext_len, buffer);
    5829                 :            : 
    5830                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    5831                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    5832                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    5833                 :          0 :                         tdata->plaintext.data,
    5834                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    5835                 :            :         } else {
    5836         [ #  # ]:          0 :                 if (ut_params->obuf)
    5837                 :            :                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    5838                 :            :                                         ciphertext_len, buffer);
    5839                 :            :                 else
    5840         [ #  # ]:          0 :                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    5841                 :            :                                         ciphertext_len, buffer);
    5842                 :            : 
    5843                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    5844                 :            :                         ciphertext_len);
    5845                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    5846                 :          0 :                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
    5847                 :            : 
    5848         [ #  # ]:          0 :                 if (ut_params->obuf)
    5849                 :          0 :                         digest = rte_pktmbuf_read(ut_params->obuf,
    5850                 :          0 :                                 (tdata->digest.offset_bytes == 0 ?
    5851                 :            :                                 plaintext_pad_len : tdata->digest.offset_bytes),
    5852         [ #  # ]:          0 :                                 tdata->digest.len, digest_buffer);
    5853                 :            :                 else
    5854         [ #  # ]:          0 :                         digest = rte_pktmbuf_read(ut_params->ibuf,
    5855                 :          0 :                                 (tdata->digest.offset_bytes == 0 ?
    5856                 :            :                                 plaintext_pad_len : tdata->digest.offset_bytes),
    5857         [ #  # ]:          0 :                                 tdata->digest.len, digest_buffer);
    5858                 :            : 
    5859                 :          0 :                 debug_hexdump(stdout, "digest:", digest,
    5860                 :          0 :                         tdata->digest.len);
    5861                 :          0 :                 debug_hexdump(stdout, "digest expected:",
    5862                 :          0 :                         tdata->digest.data, tdata->digest.len);
    5863                 :            :         }
    5864                 :            : 
    5865                 :            :         /* Validate obuf */
    5866         [ #  # ]:          0 :         if (verify) {
    5867   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
          #  #  #  #  #  
             #  #  #  #  
                      # ]
    5868                 :            :                         plaintext,
    5869                 :            :                         tdata->plaintext.data,
    5870                 :            :                         (tdata->plaintext.len - tdata->cipher.offset_bits -
    5871                 :            :                          (tdata->digest.len << 3)),
    5872                 :            :                         tdata->cipher.offset_bits,
    5873                 :            :                         "SNOW 3G Plaintext data not as expected");
    5874                 :            :         } else {
    5875   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
          #  #  #  #  #  
             #  #  #  #  
                      # ]
    5876                 :            :                         ciphertext,
    5877                 :            :                         tdata->ciphertext.data,
    5878                 :            :                         (tdata->validDataLenInBits.len -
    5879                 :            :                          tdata->cipher.offset_bits),
    5880                 :            :                         tdata->cipher.offset_bits,
    5881                 :            :                         "SNOW 3G Ciphertext data not as expected");
    5882                 :            : 
    5883         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    5884                 :            :                         digest,
    5885                 :            :                         tdata->digest.data,
    5886                 :            :                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
    5887                 :            :                         "SNOW 3G Generated auth tag not as expected");
    5888                 :            :         }
    5889                 :            :         return 0;
    5890                 :            : }
    5891                 :            : 
    5892                 :            : static int
    5893                 :          0 : test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
    5894                 :            :         uint8_t op_mode, uint8_t verify)
    5895                 :            : {
    5896                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    5897                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    5898                 :            : 
    5899                 :            :         int retval;
    5900                 :            : 
    5901                 :            :         uint8_t *plaintext = NULL, *ciphertext = NULL;
    5902                 :            :         unsigned int plaintext_pad_len;
    5903                 :            :         unsigned int plaintext_len;
    5904                 :            :         unsigned int ciphertext_pad_len;
    5905                 :            :         unsigned int ciphertext_len;
    5906                 :            :         unsigned int digest_offset;
    5907                 :            : 
    5908                 :            :         struct rte_cryptodev_info dev_info;
    5909                 :            : 
    5910                 :            :         /* Verify the capabilities */
    5911                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    5912                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    5913                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
    5914         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5915                 :            :                         &cap_idx) == NULL)
    5916                 :            :                 return TEST_SKIPPED;
    5917                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    5918                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    5919         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    5920                 :            :                         &cap_idx) == NULL)
    5921                 :            :                 return TEST_SKIPPED;
    5922                 :            : 
    5923                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    5924                 :            : 
    5925                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    5926                 :            : 
    5927         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    5928         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    5929                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    5930                 :          0 :                 return TEST_SKIPPED;
    5931                 :            :         }
    5932                 :            : 
    5933         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    5934                 :            :                 return TEST_SKIPPED;
    5935                 :            : 
    5936         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE) {
    5937         [ #  # ]:          0 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    5938                 :            :                         return TEST_SKIPPED;
    5939         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    5940                 :            :                         printf("Device doesn't support digest encrypted.\n");
    5941                 :          0 :                         return TEST_SKIPPED;
    5942                 :            :                 }
    5943                 :            :         }
    5944                 :            : 
    5945                 :            :         /* Create KASUMI session */
    5946                 :          0 :         retval = create_wireless_algo_auth_cipher_session(
    5947                 :          0 :                         ts_params->valid_devs[0],
    5948                 :            :                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
    5949                 :            :                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
    5950                 :            :                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
    5951                 :            :                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
    5952                 :            :                         RTE_CRYPTO_AUTH_KASUMI_F9,
    5953                 :            :                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    5954                 :            :                         tdata->key.data, tdata->key.len,
    5955                 :          0 :                         tdata->key.data, tdata->key.len,
    5956                 :          0 :                         0, tdata->digest.len,
    5957                 :          0 :                         tdata->cipher_iv.len);
    5958                 :            : 
    5959         [ #  # ]:          0 :         if (retval != 0)
    5960                 :            :                 return retval;
    5961                 :            : 
    5962                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5963         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    5964                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    5965                 :            : 
    5966                 :            :         /* clear mbuf payload */
    5967         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    5968         [ #  # ]:          0 :                 rte_pktmbuf_tailroom(ut_params->ibuf));
    5969         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    5970                 :          0 :                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
    5971                 :          0 :                         rte_pktmbuf_tailroom(ut_params->obuf));
    5972                 :            : 
    5973         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    5974         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    5975                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    5976                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    5977                 :            : 
    5978         [ #  # ]:          0 :         if (verify) {
    5979                 :          0 :                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5980                 :            :                                         ciphertext_pad_len);
    5981         [ #  # ]:          0 :                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    5982         [ #  # ]:          0 :                 if (op_mode == OUT_OF_PLACE)
    5983                 :          0 :                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
    5984                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    5985                 :            :                         ciphertext_len);
    5986                 :            :         } else {
    5987                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    5988                 :            :                                         plaintext_pad_len);
    5989         [ #  # ]:          0 :                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    5990         [ #  # ]:          0 :                 if (op_mode == OUT_OF_PLACE)
    5991                 :          0 :                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
    5992                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    5993                 :            :                         plaintext_len);
    5994                 :            :         }
    5995                 :            : 
    5996                 :            :         /* Create KASUMI operation */
    5997                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    5998                 :          0 :                 tdata->digest.data, tdata->digest.len,
    5999                 :          0 :                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    6000                 :            :                 NULL, 0,
    6001                 :          0 :                 (tdata->digest.offset_bytes == 0 ?
    6002         [ #  # ]:          0 :                 (verify ? ciphertext_pad_len : plaintext_pad_len)
    6003                 :            :                         : tdata->digest.offset_bytes),
    6004                 :          0 :                 tdata->validCipherLenInBits.len,
    6005                 :          0 :                 tdata->validCipherOffsetInBits.len,
    6006         [ #  # ]:          0 :                 tdata->validAuthLenInBits.len,
    6007                 :            :                 0,
    6008                 :            :                 op_mode, 0, verify);
    6009                 :            : 
    6010         [ #  # ]:          0 :         if (retval < 0)
    6011                 :            :                 return retval;
    6012                 :            : 
    6013         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    6014                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    6015                 :          0 :                                                tdata->cipher_iv.len);
    6016         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    6017                 :            :                         return retval;
    6018                 :            :         } else
    6019                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    6020                 :            :                         ut_params->op);
    6021                 :            : 
    6022         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    6023                 :            : 
    6024                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    6025         [ #  # ]:          0 :                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    6026                 :            : 
    6027                 :            : 
    6028         [ #  # ]:          0 :         if (verify) {
    6029         [ #  # ]:          0 :                 if (ut_params->obuf)
    6030                 :          0 :                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
    6031                 :            :                                                         uint8_t *);
    6032                 :            :                 else
    6033                 :            :                         plaintext = ciphertext;
    6034                 :            : 
    6035                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    6036                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    6037                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    6038                 :          0 :                         tdata->plaintext.data,
    6039                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    6040                 :            :         } else {
    6041         [ #  # ]:          0 :                 if (ut_params->obuf)
    6042                 :          0 :                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
    6043                 :            :                                                         uint8_t *);
    6044                 :            :                 else
    6045                 :            :                         ciphertext = plaintext;
    6046                 :            : 
    6047                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    6048                 :            :                         ciphertext_len);
    6049                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    6050                 :          0 :                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
    6051                 :            : 
    6052         [ #  # ]:          0 :                 if (tdata->digest.offset_bytes == 0)
    6053                 :            :                         digest_offset = plaintext_pad_len;
    6054                 :            :                 else
    6055                 :            :                         digest_offset = tdata->digest.offset_bytes;
    6056                 :          0 :                 ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    6057                 :            :                                                     uint8_t *, digest_offset);
    6058                 :            : 
    6059                 :          0 :                 debug_hexdump(stdout, "digest:", ut_params->digest,
    6060                 :          0 :                         tdata->digest.len);
    6061                 :          0 :                 debug_hexdump(stdout, "digest expected:",
    6062                 :          0 :                         tdata->digest.data, tdata->digest.len);
    6063                 :            :         }
    6064                 :            : 
    6065                 :            :         /* Validate obuf */
    6066         [ #  # ]:          0 :         if (verify) {
    6067   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6068                 :            :                         plaintext,
    6069                 :            :                         tdata->plaintext.data,
    6070                 :            :                         tdata->plaintext.len >> 3,
    6071                 :            :                         "KASUMI Plaintext data not as expected");
    6072                 :            :         } else {
    6073   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6074                 :            :                         ciphertext,
    6075                 :            :                         tdata->ciphertext.data,
    6076                 :            :                         tdata->ciphertext.len >> 3,
    6077                 :            :                         "KASUMI Ciphertext data not as expected");
    6078                 :            : 
    6079         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    6080                 :            :                         ut_params->digest,
    6081                 :            :                         tdata->digest.data,
    6082                 :            :                         DIGEST_BYTE_LENGTH_KASUMI_F9,
    6083                 :            :                         "KASUMI Generated auth tag not as expected");
    6084                 :            :         }
    6085                 :            :         return 0;
    6086                 :            : }
    6087                 :            : 
    6088                 :            : static int
    6089                 :          0 : test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
    6090                 :            :         uint8_t op_mode, uint8_t verify)
    6091                 :            : {
    6092                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    6093                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    6094                 :            : 
    6095                 :            :         int retval;
    6096                 :            : 
    6097                 :            :         const uint8_t *plaintext = NULL;
    6098                 :            :         const uint8_t *ciphertext = NULL;
    6099                 :            :         const uint8_t *digest = NULL;
    6100                 :            :         unsigned int plaintext_pad_len;
    6101                 :            :         unsigned int plaintext_len;
    6102                 :            :         unsigned int ciphertext_pad_len;
    6103                 :            :         unsigned int ciphertext_len;
    6104                 :            :         uint8_t buffer[10000];
    6105                 :            :         uint8_t digest_buffer[10000];
    6106                 :            : 
    6107                 :            :         struct rte_cryptodev_info dev_info;
    6108                 :            : 
    6109                 :            :         /* Verify the capabilities */
    6110                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    6111                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    6112                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
    6113         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    6114                 :            :                         &cap_idx) == NULL)
    6115                 :            :                 return TEST_SKIPPED;
    6116                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    6117                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    6118         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    6119                 :            :                         &cap_idx) == NULL)
    6120                 :            :                 return TEST_SKIPPED;
    6121                 :            : 
    6122         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    6123                 :            :                 return TEST_SKIPPED;
    6124                 :            : 
    6125                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    6126                 :            : 
    6127                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    6128                 :            : 
    6129         [ #  # ]:          0 :         if (op_mode == IN_PLACE) {
    6130         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    6131                 :            :                         printf("Device doesn't support in-place scatter-gather "
    6132                 :            :                                         "in both input and output mbufs.\n");
    6133                 :          0 :                         return TEST_SKIPPED;
    6134                 :            :                 }
    6135         [ #  # ]:          0 :                 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    6136         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    6137                 :            :                         printf("Device doesn't support RAW data-path APIs.\n");
    6138                 :          0 :                         return TEST_SKIPPED;
    6139                 :            :                 }
    6140                 :            :         } else {
    6141         [ #  # ]:          0 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    6142                 :            :                         return TEST_SKIPPED;
    6143         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
    6144                 :            :                         printf("Device doesn't support out-of-place scatter-gather "
    6145                 :            :                                         "in both input and output mbufs.\n");
    6146                 :          0 :                         return TEST_SKIPPED;
    6147                 :            :                 }
    6148         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    6149                 :            :                         printf("Device doesn't support digest encrypted.\n");
    6150                 :          0 :                         return TEST_SKIPPED;
    6151                 :            :                 }
    6152                 :            :         }
    6153                 :            : 
    6154                 :            :         /* Create KASUMI session */
    6155                 :          0 :         retval = create_wireless_algo_auth_cipher_session(
    6156                 :          0 :                         ts_params->valid_devs[0],
    6157                 :            :                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
    6158                 :            :                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
    6159                 :            :                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
    6160                 :            :                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
    6161                 :            :                         RTE_CRYPTO_AUTH_KASUMI_F9,
    6162                 :            :                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    6163                 :            :                         tdata->key.data, tdata->key.len,
    6164                 :          0 :                         tdata->key.data, tdata->key.len,
    6165                 :          0 :                         0, tdata->digest.len,
    6166                 :          0 :                         tdata->cipher_iv.len);
    6167                 :            : 
    6168         [ #  # ]:          0 :         if (retval != 0)
    6169                 :            :                 return retval;
    6170                 :            : 
    6171         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    6172         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    6173                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    6174                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    6175                 :            : 
    6176                 :          0 :         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    6177                 :            :                         plaintext_pad_len, 15, 0);
    6178         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    6179                 :            :                         "Failed to allocate input buffer in mempool");
    6180                 :            : 
    6181         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE) {
    6182                 :          0 :                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
    6183                 :            :                                 plaintext_pad_len, 15, 0);
    6184         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
    6185                 :            :                                 "Failed to allocate output buffer in mempool");
    6186                 :            :         }
    6187                 :            : 
    6188         [ #  # ]:          0 :         if (verify) {
    6189                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
    6190                 :          0 :                         tdata->ciphertext.data);
    6191         [ #  # ]:          0 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    6192                 :            :                                         ciphertext_len, buffer);
    6193                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    6194                 :            :                         ciphertext_len);
    6195                 :            :         } else {
    6196                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
    6197                 :          0 :                         tdata->plaintext.data);
    6198         [ #  # ]:          0 :                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    6199                 :            :                                         plaintext_len, buffer);
    6200                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    6201                 :            :                         plaintext_len);
    6202                 :            :         }
    6203                 :            :         memset(buffer, 0, sizeof(buffer));
    6204                 :            : 
    6205                 :            :         /* Create KASUMI operation */
    6206                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    6207                 :          0 :                 tdata->digest.data, tdata->digest.len,
    6208                 :          0 :                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    6209                 :            :                 NULL, 0,
    6210                 :          0 :                 (tdata->digest.offset_bytes == 0 ?
    6211         [ #  # ]:          0 :                 (verify ? ciphertext_pad_len : plaintext_pad_len)
    6212                 :            :                         : tdata->digest.offset_bytes),
    6213                 :          0 :                 tdata->validCipherLenInBits.len,
    6214                 :          0 :                 tdata->validCipherOffsetInBits.len,
    6215         [ #  # ]:          0 :                 tdata->validAuthLenInBits.len,
    6216                 :            :                 0,
    6217                 :            :                 op_mode, 1, verify);
    6218                 :            : 
    6219         [ #  # ]:          0 :         if (retval < 0)
    6220                 :            :                 return retval;
    6221                 :            : 
    6222         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    6223                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    6224                 :          0 :                                                tdata->cipher_iv.len);
    6225         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    6226                 :            :                         return retval;
    6227                 :            :         } else
    6228                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    6229                 :            :                         ut_params->op);
    6230                 :            : 
    6231         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    6232                 :            : 
    6233                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    6234         [ #  # ]:          0 :                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    6235                 :            : 
    6236         [ #  # ]:          0 :         if (verify) {
    6237         [ #  # ]:          0 :                 if (ut_params->obuf)
    6238                 :            :                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
    6239                 :            :                                         plaintext_len, buffer);
    6240                 :            :                 else
    6241         [ #  # ]:          0 :                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    6242                 :            :                                         plaintext_len, buffer);
    6243                 :            : 
    6244                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    6245                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    6246                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    6247                 :          0 :                         tdata->plaintext.data,
    6248                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    6249                 :            :         } else {
    6250         [ #  # ]:          0 :                 if (ut_params->obuf)
    6251                 :            :                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    6252                 :            :                                         ciphertext_len, buffer);
    6253                 :            :                 else
    6254         [ #  # ]:          0 :                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    6255                 :            :                                         ciphertext_len, buffer);
    6256                 :            : 
    6257                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    6258                 :            :                         ciphertext_len);
    6259                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    6260                 :          0 :                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
    6261                 :            : 
    6262         [ #  # ]:          0 :                 if (ut_params->obuf)
    6263                 :          0 :                         digest = rte_pktmbuf_read(ut_params->obuf,
    6264                 :          0 :                                 (tdata->digest.offset_bytes == 0 ?
    6265                 :            :                                 plaintext_pad_len : tdata->digest.offset_bytes),
    6266         [ #  # ]:          0 :                                 tdata->digest.len, digest_buffer);
    6267                 :            :                 else
    6268         [ #  # ]:          0 :                         digest = rte_pktmbuf_read(ut_params->ibuf,
    6269                 :          0 :                                 (tdata->digest.offset_bytes == 0 ?
    6270                 :            :                                 plaintext_pad_len : tdata->digest.offset_bytes),
    6271         [ #  # ]:          0 :                                 tdata->digest.len, digest_buffer);
    6272                 :            : 
    6273                 :          0 :                 debug_hexdump(stdout, "digest:", digest,
    6274                 :          0 :                         tdata->digest.len);
    6275                 :          0 :                 debug_hexdump(stdout, "digest expected:",
    6276                 :          0 :                         tdata->digest.data, tdata->digest.len);
    6277                 :            :         }
    6278                 :            : 
    6279                 :            :         /* Validate obuf */
    6280         [ #  # ]:          0 :         if (verify) {
    6281   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6282                 :            :                         plaintext,
    6283                 :            :                         tdata->plaintext.data,
    6284                 :            :                         tdata->plaintext.len >> 3,
    6285                 :            :                         "KASUMI Plaintext data not as expected");
    6286                 :            :         } else {
    6287   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6288                 :            :                         ciphertext,
    6289                 :            :                         tdata->ciphertext.data,
    6290                 :            :                         tdata->validDataLenInBits.len,
    6291                 :            :                         "KASUMI Ciphertext data not as expected");
    6292                 :            : 
    6293         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    6294                 :            :                         digest,
    6295                 :            :                         tdata->digest.data,
    6296                 :            :                         DIGEST_BYTE_LENGTH_KASUMI_F9,
    6297                 :            :                         "KASUMI Generated auth tag not as expected");
    6298                 :            :         }
    6299                 :            :         return 0;
    6300                 :            : }
    6301                 :            : 
    6302                 :            : static int
    6303                 :          0 : test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
    6304                 :            : {
    6305                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    6306                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    6307                 :            : 
    6308                 :            :         int retval;
    6309                 :            : 
    6310                 :            :         uint8_t *plaintext, *ciphertext;
    6311                 :            :         unsigned plaintext_pad_len;
    6312                 :            :         unsigned plaintext_len;
    6313                 :            :         struct rte_cryptodev_info dev_info;
    6314                 :            : 
    6315                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    6316                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    6317                 :            : 
    6318         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    6319         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    6320                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    6321                 :          0 :                 return TEST_SKIPPED;
    6322                 :            :         }
    6323                 :            : 
    6324         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    6325                 :            :                 return TEST_SKIPPED;
    6326                 :            : 
    6327                 :            :         /* Verify the capabilities */
    6328                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    6329                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    6330                 :          0 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
    6331         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    6332                 :            :                         &cap_idx) == NULL)
    6333                 :            :                 return TEST_SKIPPED;
    6334                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    6335                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
    6336         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    6337                 :            :                         &cap_idx) == NULL)
    6338                 :            :                 return TEST_SKIPPED;
    6339                 :            : 
    6340                 :            :         /* Create KASUMI session */
    6341                 :          0 :         retval = create_wireless_algo_cipher_auth_session(
    6342                 :          0 :                         ts_params->valid_devs[0],
    6343                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    6344                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
    6345                 :            :                         RTE_CRYPTO_AUTH_KASUMI_F9,
    6346                 :            :                         RTE_CRYPTO_CIPHER_KASUMI_F8,
    6347                 :            :                         tdata->key.data, tdata->key.len,
    6348                 :          0 :                         tdata->key.data, tdata->key.len,
    6349                 :          0 :                         0, tdata->digest.len,
    6350                 :          0 :                         tdata->cipher_iv.len);
    6351         [ #  # ]:          0 :         if (retval != 0)
    6352                 :            :                 return retval;
    6353                 :            : 
    6354         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    6355                 :            : 
    6356                 :            :         /* clear mbuf payload */
    6357         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    6358                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
    6359                 :            : 
    6360         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    6361                 :            :         /* Append data which is padded to a multiple of */
    6362                 :            :         /* the algorithms block size */
    6363                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    6364                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6365                 :            :                                 plaintext_pad_len);
    6366                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    6367                 :            : 
    6368                 :          0 :         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    6369                 :            : 
    6370                 :            :         /* Create KASUMI operation */
    6371                 :          0 :         retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
    6372                 :          0 :                                 tdata->digest.len, NULL, 0,
    6373                 :            :                                 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
    6374                 :          0 :                                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    6375                 :          0 :                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
    6376                 :          0 :                                 tdata->validCipherOffsetInBits.len,
    6377                 :          0 :                                 tdata->validAuthLenInBits.len,
    6378                 :            :                                 0
    6379                 :            :                                 );
    6380         [ #  # ]:          0 :         if (retval < 0)
    6381                 :            :                 return retval;
    6382                 :            : 
    6383         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    6384                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    6385                 :          0 :                                                tdata->cipher_iv.len);
    6386         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    6387                 :            :                         return retval;
    6388                 :            :         } else
    6389                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    6390                 :            :                         ut_params->op);
    6391         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    6392                 :            : 
    6393         [ #  # ]:          0 :         if (ut_params->op->sym->m_dst)
    6394                 :          0 :                 ut_params->obuf = ut_params->op->sym->m_dst;
    6395                 :            :         else
    6396                 :          0 :                 ut_params->obuf = ut_params->op->sym->m_src;
    6397                 :            : 
    6398                 :          0 :         ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
    6399                 :            :                                 tdata->validCipherOffsetInBits.len >> 3);
    6400                 :            : 
    6401                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    6402                 :            :                                                     uint8_t *,
    6403                 :            :                                                     plaintext_pad_len);
    6404                 :            : 
    6405                 :          0 :         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
    6406                 :            :                                 (tdata->validCipherOffsetInBits.len >> 3);
    6407                 :            :         /* Validate obuf */
    6408   [ #  #  #  #  :          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6409                 :            :                 ciphertext,
    6410                 :            :                 reference_ciphertext,
    6411                 :            :                 tdata->validCipherLenInBits.len,
    6412                 :            :                 "KASUMI Ciphertext data not as expected");
    6413                 :            : 
    6414                 :            :         /* Validate obuf */
    6415         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    6416                 :            :                 ut_params->digest,
    6417                 :            :                 tdata->digest.data,
    6418                 :            :                 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
    6419                 :            :                 "KASUMI Generated auth tag not as expected");
    6420                 :            :         return 0;
    6421                 :            : }
    6422                 :            : 
    6423                 :            : static int
    6424                 :          0 : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
    6425                 :            :                         const enum rte_crypto_cipher_algorithm cipher_algo,
    6426                 :            :                         const uint16_t key_size, const uint16_t iv_size)
    6427                 :            : {
    6428                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    6429                 :            :         const struct rte_cryptodev_symmetric_capability *cap;
    6430                 :            : 
    6431                 :            :         /* Check if device supports the algorithm */
    6432                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    6433                 :          0 :         cap_idx.algo.cipher = cipher_algo;
    6434                 :            : 
    6435                 :          0 :         cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    6436                 :            :                         &cap_idx);
    6437                 :            : 
    6438         [ #  # ]:          0 :         if (cap == NULL)
    6439                 :            :                 return -1;
    6440                 :            : 
    6441                 :            :         /* Check if device supports key size and IV size */
    6442         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
    6443                 :            :                         iv_size) < 0) {
    6444                 :          0 :                 return -1;
    6445                 :            :         }
    6446                 :            : 
    6447                 :            :         return 0;
    6448                 :            : }
    6449                 :            : 
    6450                 :            : static int
    6451                 :          0 : check_auth_capability(const struct crypto_testsuite_params *ts_params,
    6452                 :            :                         const enum rte_crypto_auth_algorithm auth_algo,
    6453                 :            :                         const uint16_t key_size, const uint16_t iv_size,
    6454                 :            :                         const uint16_t tag_size)
    6455                 :            : {
    6456                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    6457                 :            :         const struct rte_cryptodev_symmetric_capability *cap;
    6458                 :            : 
    6459                 :            :         /* Check if device supports the algorithm */
    6460                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    6461                 :          0 :         cap_idx.algo.auth = auth_algo;
    6462                 :            : 
    6463                 :          0 :         cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
    6464                 :            :                         &cap_idx);
    6465                 :            : 
    6466         [ #  # ]:          0 :         if (cap == NULL)
    6467                 :            :                 return -1;
    6468                 :            : 
    6469                 :            :         /* Check if device supports key size and IV size */
    6470         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
    6471                 :            :                         tag_size, iv_size) < 0) {
    6472                 :          0 :                 return -1;
    6473                 :            :         }
    6474                 :            : 
    6475                 :            :         return 0;
    6476                 :            : }
    6477                 :            : 
    6478                 :            : static int
    6479                 :          0 : test_zuc_cipher(const struct wireless_test_data *tdata,
    6480                 :            :                 enum rte_crypto_cipher_operation direction)
    6481                 :            : {
    6482                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    6483                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    6484                 :            : 
    6485                 :            :         int retval;
    6486                 :            :         uint8_t *plaintext = NULL;
    6487                 :            :         uint8_t *ciphertext = NULL;
    6488                 :            :         unsigned int plaintext_pad_len, ciphertext_pad_len;
    6489                 :            :         unsigned int plaintext_len = 0;
    6490                 :            :         unsigned int ciphertext_len = 0;
    6491                 :            :         struct rte_cryptodev_info dev_info;
    6492                 :            : 
    6493                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    6494                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    6495                 :            : 
    6496         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    6497         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    6498                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    6499                 :          0 :                 return TEST_SKIPPED;
    6500                 :            :         }
    6501                 :            : 
    6502         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    6503                 :            :                 return TEST_SKIPPED;
    6504                 :            : 
    6505                 :            :         /* Check if device supports ZUC EEA3 */
    6506         [ #  # ]:          0 :         if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
    6507                 :          0 :                         tdata->key.len, tdata->cipher_iv.len) < 0)
    6508                 :            :                 return TEST_SKIPPED;
    6509                 :            : 
    6510                 :            :         /* Create ZUC session */
    6511                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    6512                 :            :                                         direction,
    6513                 :            :                                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
    6514                 :          0 :                                         tdata->key.data, tdata->key.len,
    6515                 :          0 :                                         tdata->cipher_iv.len);
    6516         [ #  # ]:          0 :         if (retval != 0)
    6517                 :            :                 return retval;
    6518                 :            : 
    6519         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    6520                 :            : 
    6521                 :            :         /* Clear mbuf payload */
    6522         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    6523                 :            :                rte_pktmbuf_tailroom(ut_params->ibuf));
    6524                 :            : 
    6525         [ #  # ]:          0 :         if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
    6526         [ #  # ]:          0 :                 plaintext_len = ceil_byte_length(tdata->plaintext.len);
    6527                 :            :                 /* Append data which is padded to a multiple */
    6528                 :            :                 /* of the algorithms block size */
    6529                 :          0 :                 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    6530                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6531                 :            :                                 plaintext_pad_len);
    6532                 :          0 :                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    6533                 :            : 
    6534                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    6535                 :            :         } else {
    6536         [ #  # ]:          0 :                 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    6537                 :            :                 /* Append data which is padded to a multiple */
    6538                 :            :                 /* of the algorithms block size */
    6539                 :          0 :                 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
    6540                 :          0 :                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6541                 :            :                                 ciphertext_pad_len);
    6542                 :          0 :                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    6543                 :            : 
    6544                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
    6545                 :            :         }
    6546                 :            : 
    6547                 :            :         /* Create ZUC operation */
    6548                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    6549                 :          0 :                                         tdata->cipher_iv.len,
    6550                 :          0 :                                         tdata->plaintext.len,
    6551                 :          0 :                                         tdata->validCipherOffsetInBits.len);
    6552         [ #  # ]:          0 :         if (retval < 0)
    6553                 :            :                 return retval;
    6554                 :            : 
    6555         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    6556                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    6557                 :          0 :                                                tdata->cipher_iv.len);
    6558         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    6559                 :            :                         return retval;
    6560                 :            :         } else
    6561                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    6562                 :            :                                                 ut_params->op);
    6563         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    6564                 :            : 
    6565                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    6566                 :            : 
    6567         [ #  # ]:          0 :         if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
    6568         [ #  # ]:          0 :                 if (ut_params->obuf)
    6569                 :          0 :                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    6570                 :            :                 else
    6571                 :            :                         ciphertext = plaintext;
    6572                 :            : 
    6573                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    6574                 :            : 
    6575                 :            :                 /* Validate obuf */
    6576   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6577                 :            :                                 ciphertext,
    6578                 :            :                                 tdata->ciphertext.data,
    6579                 :            :                                 tdata->validCipherLenInBits.len,
    6580                 :            :                                 "ZUC Ciphertext data not as expected");
    6581                 :            :         } else {
    6582         [ #  # ]:          0 :                 if (ut_params->obuf)
    6583                 :          0 :                         plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
    6584                 :            :                 else
    6585                 :            :                         plaintext = ciphertext;
    6586                 :            : 
    6587                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
    6588                 :            : 
    6589                 :          0 :                 const uint8_t *reference_plaintext = tdata->plaintext.data +
    6590                 :          0 :                                 (tdata->validCipherOffsetInBits.len >> 3);
    6591                 :            : 
    6592                 :            :                 /* Validate obuf */
    6593   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6594                 :            :                                 plaintext,
    6595                 :            :                                 reference_plaintext,
    6596                 :            :                                 tdata->validCipherLenInBits.len,
    6597                 :            :                                 "ZUC Plaintext data not as expected");
    6598                 :            :         }
    6599                 :            : 
    6600                 :            :         return 0;
    6601                 :            : }
    6602                 :            : 
    6603                 :            : static int
    6604                 :          0 : test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
    6605                 :            :                 enum rte_crypto_cipher_operation direction)
    6606                 :            : {
    6607                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    6608                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    6609                 :            : 
    6610                 :            :         int retval;
    6611                 :            : 
    6612                 :            :         unsigned int plaintext_pad_len, ciphertext_pad_len;
    6613                 :            :         unsigned int plaintext_len = 0;
    6614                 :            :         unsigned int ciphertext_len = 0;
    6615                 :            :         const uint8_t *ciphertext, *plaintext;
    6616                 :            :         uint8_t buffer[2048];
    6617                 :            :         struct rte_cryptodev_info dev_info;
    6618                 :            : 
    6619                 :            :         /* Check if device supports ZUC EEA3 */
    6620         [ #  # ]:          0 :         if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
    6621                 :          0 :                         tdata->key.len, tdata->cipher_iv.len) < 0)
    6622                 :            :                 return TEST_SKIPPED;
    6623                 :            : 
    6624         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    6625                 :            :                 return TEST_SKIPPED;
    6626                 :            : 
    6627                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    6628                 :            : 
    6629                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    6630                 :            : 
    6631         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    6632                 :            :                 printf("Device doesn't support in-place scatter-gather. "
    6633                 :            :                                 "Test Skipped.\n");
    6634                 :          0 :                 return TEST_SKIPPED;
    6635                 :            :         }
    6636                 :            : 
    6637         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    6638         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    6639                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    6640                 :          0 :                 return TEST_SKIPPED;
    6641                 :            :         }
    6642                 :            : 
    6643         [ #  # ]:          0 :         if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
    6644         [ #  # ]:          0 :                 plaintext_len = ceil_byte_length(tdata->plaintext.len);
    6645                 :            : 
    6646                 :            :                 /* Append data which is padded to a multiple */
    6647                 :            :                 /* of the algorithms block size */
    6648                 :          0 :                 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    6649                 :            : 
    6650                 :          0 :                 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    6651                 :            :                                 plaintext_pad_len, 10, 0);
    6652                 :            : 
    6653                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
    6654                 :          0 :                                 tdata->plaintext.data);
    6655                 :            :         } else {
    6656         [ #  # ]:          0 :                 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    6657                 :            : 
    6658                 :            :                 /* Append data which is padded to a multiple */
    6659                 :            :                 /* of the algorithms block size */
    6660                 :          0 :                 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
    6661                 :            : 
    6662                 :          0 :                 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    6663                 :            :                                 ciphertext_pad_len, 10, 0);
    6664                 :            : 
    6665                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
    6666                 :          0 :                                 tdata->ciphertext.data);
    6667                 :            : 
    6668                 :            :         }
    6669                 :            : 
    6670                 :            :         /* Create ZUC session */
    6671                 :          0 :         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
    6672                 :            :                         direction,
    6673                 :            :                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
    6674                 :          0 :                         tdata->key.data, tdata->key.len,
    6675                 :          0 :                         tdata->cipher_iv.len);
    6676         [ #  # ]:          0 :         if (retval < 0)
    6677                 :            :                 return retval;
    6678                 :            : 
    6679                 :            :         /* Clear mbuf payload */
    6680         [ #  # ]:          0 :         if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
    6681                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
    6682                 :            :         else
    6683                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
    6684                 :            : 
    6685                 :            :         /* Create ZUC operation */
    6686                 :          0 :         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
    6687                 :          0 :                         tdata->cipher_iv.len, tdata->plaintext.len,
    6688                 :          0 :                         tdata->validCipherOffsetInBits.len);
    6689         [ #  # ]:          0 :         if (retval < 0)
    6690                 :            :                 return retval;
    6691                 :            : 
    6692         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    6693                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
    6694                 :          0 :                                                tdata->cipher_iv.len);
    6695         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    6696                 :            :                         return retval;
    6697                 :            :         } else
    6698                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    6699                 :            :                                                 ut_params->op);
    6700         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    6701                 :            : 
    6702                 :          0 :         ut_params->obuf = ut_params->op->sym->m_dst;
    6703                 :            : 
    6704         [ #  # ]:          0 :         if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
    6705         [ #  # ]:          0 :                 if (ut_params->obuf)
    6706                 :            :                         ciphertext = rte_pktmbuf_read(ut_params->obuf,
    6707                 :            :                                 0, plaintext_len, buffer);
    6708                 :            :                 else
    6709         [ #  # ]:          0 :                         ciphertext = rte_pktmbuf_read(ut_params->ibuf,
    6710                 :            :                                 0, plaintext_len, buffer);
    6711                 :            : 
    6712                 :            :                 /* Validate obuf */
    6713                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
    6714                 :            : 
    6715                 :            :                 /* Validate obuf */
    6716   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6717                 :            :                         ciphertext,
    6718                 :            :                         tdata->ciphertext.data,
    6719                 :            :                         tdata->validCipherLenInBits.len,
    6720                 :            :                         "ZUC Ciphertext data not as expected");
    6721                 :            :         } else {
    6722         [ #  # ]:          0 :                 if (ut_params->obuf)
    6723                 :            :                         plaintext = rte_pktmbuf_read(ut_params->obuf,
    6724                 :            :                                 0, ciphertext_len, buffer);
    6725                 :            :                 else
    6726         [ #  # ]:          0 :                         plaintext = rte_pktmbuf_read(ut_params->ibuf,
    6727                 :            :                                 0, ciphertext_len, buffer);
    6728                 :            : 
    6729                 :            :                 /* Validate obuf */
    6730                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
    6731                 :            : 
    6732                 :            :                 /* Validate obuf */
    6733   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    6734                 :            :                         plaintext,
    6735                 :            :                         tdata->plaintext.data,
    6736                 :            :                         tdata->validCipherLenInBits.len,
    6737                 :            :                         "ZUC Plaintext data not as expected");
    6738                 :            :                 }
    6739                 :            : 
    6740                 :            :         return 0;
    6741                 :            : }
    6742                 :            : 
    6743                 :            : static int
    6744                 :          0 : test_zuc_authentication(const struct wireless_test_data *tdata,
    6745                 :            :                 enum rte_crypto_auth_operation auth_op)
    6746                 :            : {
    6747                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    6748                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    6749                 :            : 
    6750                 :            :         int retval;
    6751                 :            :         unsigned plaintext_pad_len;
    6752                 :            :         unsigned plaintext_len;
    6753                 :            :         uint8_t *plaintext;
    6754                 :            : 
    6755                 :            :         struct rte_cryptodev_info dev_info;
    6756                 :            : 
    6757                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    6758                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    6759                 :            : 
    6760         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
    6761         [ #  # ]:          0 :                         (tdata->validAuthLenInBits.len % 8 != 0)) {
    6762                 :            :                 printf("Device doesn't support NON-Byte Aligned Data.\n");
    6763                 :          0 :                 return TEST_SKIPPED;
    6764                 :            :         }
    6765                 :            : 
    6766         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    6767         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    6768                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    6769                 :          0 :                 return TEST_SKIPPED;
    6770                 :            :         }
    6771                 :            : 
    6772         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    6773                 :            :                 return TEST_SKIPPED;
    6774                 :            : 
    6775                 :            :         /* Check if device supports ZUC EIA3 */
    6776         [ #  # ]:          0 :         if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
    6777                 :          0 :                         tdata->key.len, tdata->auth_iv.len,
    6778                 :          0 :                         tdata->digest.len) < 0)
    6779                 :            :                 return TEST_SKIPPED;
    6780                 :            : 
    6781                 :            :         /* Create ZUC session */
    6782                 :          0 :         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
    6783                 :          0 :                         tdata->key.data, tdata->key.len,
    6784                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    6785                 :            :                         auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
    6786         [ #  # ]:          0 :         if (retval != 0)
    6787                 :            :                 return retval;
    6788                 :            : 
    6789                 :            :         /* alloc mbuf and set payload */
    6790         [ #  # ]:          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    6791                 :            : 
    6792         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    6793                 :            :         rte_pktmbuf_tailroom(ut_params->ibuf));
    6794                 :            : 
    6795         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    6796                 :            :         /* Append data which is padded to a multiple of */
    6797                 :            :         /* the algorithms block size */
    6798                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
    6799                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6800                 :            :                                 plaintext_pad_len);
    6801                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    6802                 :            : 
    6803                 :            :         /* Create ZUC operation */
    6804                 :          0 :         retval = create_wireless_algo_hash_operation(tdata->digest.data,
    6805                 :          0 :                         tdata->digest.len,
    6806                 :          0 :                         tdata->auth_iv.data, tdata->auth_iv.len,
    6807                 :            :                         plaintext_pad_len,
    6808                 :          0 :                         auth_op, tdata->validAuthLenInBits.len, 0);
    6809         [ #  # ]:          0 :         if (retval < 0)
    6810                 :            :                 return retval;
    6811                 :            : 
    6812         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    6813                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
    6814                 :            :                                                0);
    6815         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    6816                 :            :                         return retval;
    6817                 :            :         } else
    6818                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    6819                 :            :                                 ut_params->op);
    6820         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    6821                 :          0 :         ut_params->obuf = ut_params->op->sym->m_src;
    6822                 :          0 :         ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    6823                 :            :                                                     uint8_t *,
    6824                 :            :                                                     plaintext_pad_len);
    6825                 :            : 
    6826         [ #  # ]:          0 :         if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
    6827                 :            :                 /* Validate obuf */
    6828         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    6829                 :            :                                 ut_params->digest,
    6830                 :            :                                 tdata->digest.data,
    6831                 :            :                                 tdata->digest.len,
    6832                 :            :                                 "ZUC Generated auth tag not as expected");
    6833                 :            :                 return 0;
    6834                 :            :         }
    6835                 :            : 
    6836                 :            :         /* Validate obuf */
    6837         [ #  # ]:          0 :         if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
    6838                 :            :                 return 0;
    6839                 :            :         else
    6840                 :          0 :                 return -1;
    6841                 :            : 
    6842                 :            :         return 0;
    6843                 :            : }
    6844                 :            : 
    6845                 :            : static int
    6846                 :          0 : test_zuc_auth_cipher(const struct wireless_test_data *tdata,
    6847                 :            :         uint8_t op_mode, uint8_t verify)
    6848                 :            : {
    6849                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    6850                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    6851                 :            : 
    6852                 :            :         int retval;
    6853                 :            : 
    6854                 :            :         uint8_t *plaintext = NULL, *ciphertext = NULL;
    6855                 :            :         unsigned int plaintext_pad_len;
    6856                 :            :         unsigned int plaintext_len;
    6857                 :            :         unsigned int ciphertext_pad_len;
    6858                 :            :         unsigned int ciphertext_len;
    6859                 :            :         unsigned int digest_offset;
    6860                 :            : 
    6861                 :            :         struct rte_cryptodev_info dev_info;
    6862                 :            : 
    6863                 :            :         /* Check if device supports ZUC EEA3 */
    6864         [ #  # ]:          0 :         if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
    6865                 :          0 :                         tdata->key.len, tdata->cipher_iv.len) < 0)
    6866                 :            :                 return TEST_SKIPPED;
    6867                 :            : 
    6868                 :            :         /* Check if device supports ZUC EIA3 */
    6869         [ #  # ]:          0 :         if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
    6870                 :          0 :                         tdata->key.len, tdata->auth_iv.len,
    6871                 :          0 :                         tdata->digest.len) < 0)
    6872                 :            :                 return TEST_SKIPPED;
    6873                 :            : 
    6874         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    6875                 :            :                 return TEST_SKIPPED;
    6876                 :            : 
    6877                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    6878                 :            : 
    6879                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    6880                 :            : 
    6881         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    6882                 :            :                 printf("Device doesn't support digest encrypted.\n");
    6883                 :          0 :                 return TEST_SKIPPED;
    6884                 :            :         }
    6885         [ #  # ]:          0 :         if (op_mode == IN_PLACE) {
    6886         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    6887                 :            :                         printf("Device doesn't support in-place scatter-gather "
    6888                 :            :                                         "in both input and output mbufs.\n");
    6889                 :          0 :                         return TEST_SKIPPED;
    6890                 :            :                 }
    6891                 :            : 
    6892         [ #  # ]:          0 :                 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    6893         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    6894                 :            :                         printf("Device doesn't support RAW data-path APIs.\n");
    6895                 :          0 :                         return TEST_SKIPPED;
    6896                 :            :                 }
    6897                 :            :         } else {
    6898         [ #  # ]:          0 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    6899                 :            :                         return TEST_SKIPPED;
    6900         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
    6901                 :            :                         printf("Device doesn't support out-of-place scatter-gather "
    6902                 :            :                                         "in both input and output mbufs.\n");
    6903                 :          0 :                         return TEST_SKIPPED;
    6904                 :            :                 }
    6905                 :            :         }
    6906                 :            : 
    6907                 :            :         /* Create ZUC session */
    6908                 :          0 :         retval = create_wireless_algo_auth_cipher_session(
    6909                 :          0 :                         ts_params->valid_devs[0],
    6910                 :            :                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
    6911                 :            :                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
    6912                 :            :                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
    6913                 :            :                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
    6914                 :            :                         RTE_CRYPTO_AUTH_ZUC_EIA3,
    6915                 :            :                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
    6916                 :            :                         tdata->key.data, tdata->key.len,
    6917                 :          0 :                         tdata->key.data, tdata->key.len,
    6918                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    6919                 :          0 :                         tdata->cipher_iv.len);
    6920                 :            : 
    6921         [ #  # ]:          0 :         if (retval != 0)
    6922                 :            :                 return retval;
    6923                 :            : 
    6924                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    6925         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    6926                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    6927                 :            : 
    6928                 :            :         /* clear mbuf payload */
    6929         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    6930         [ #  # ]:          0 :                 rte_pktmbuf_tailroom(ut_params->ibuf));
    6931         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    6932                 :          0 :                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
    6933                 :          0 :                         rte_pktmbuf_tailroom(ut_params->obuf));
    6934                 :            : 
    6935         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    6936         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    6937                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    6938                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    6939                 :            : 
    6940         [ #  # ]:          0 :         if (verify) {
    6941                 :          0 :                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6942                 :            :                                         ciphertext_pad_len);
    6943                 :          0 :                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    6944                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    6945                 :            :                         ciphertext_len);
    6946                 :            :         } else {
    6947                 :            :                 /* make sure enough space to cover partial digest verify case */
    6948                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    6949                 :            :                                         ciphertext_pad_len);
    6950                 :          0 :                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    6951                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    6952                 :            :                         plaintext_len);
    6953                 :            :         }
    6954                 :            : 
    6955         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    6956                 :          0 :                 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
    6957                 :            : 
    6958                 :            :         /* Create ZUC operation */
    6959                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    6960                 :          0 :                 tdata->digest.data, tdata->digest.len,
    6961                 :          0 :                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    6962                 :          0 :                 tdata->auth_iv.data, tdata->auth_iv.len,
    6963                 :          0 :                 (tdata->digest.offset_bytes == 0 ?
    6964         [ #  # ]:          0 :                 (verify ? ciphertext_pad_len : plaintext_pad_len)
    6965                 :            :                         : tdata->digest.offset_bytes),
    6966                 :          0 :                 tdata->validCipherLenInBits.len,
    6967                 :          0 :                 tdata->validCipherOffsetInBits.len,
    6968         [ #  # ]:          0 :                 tdata->validAuthLenInBits.len,
    6969                 :            :                 0,
    6970                 :            :                 op_mode, 0, verify);
    6971                 :            : 
    6972         [ #  # ]:          0 :         if (retval < 0)
    6973                 :            :                 return retval;
    6974                 :            : 
    6975         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    6976                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    6977                 :          0 :                                                tdata->cipher_iv.len);
    6978         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    6979                 :            :                         return retval;
    6980                 :            :         } else
    6981                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    6982                 :            :                         ut_params->op);
    6983                 :            : 
    6984         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    6985                 :            : 
    6986                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    6987         [ #  # ]:          0 :                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    6988                 :            : 
    6989                 :            : 
    6990         [ #  # ]:          0 :         if (verify) {
    6991         [ #  # ]:          0 :                 if (ut_params->obuf)
    6992                 :          0 :                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
    6993                 :            :                                                         uint8_t *);
    6994                 :            :                 else
    6995                 :            :                         plaintext = ciphertext;
    6996                 :            : 
    6997                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    6998                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    6999                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    7000                 :          0 :                         tdata->plaintext.data,
    7001                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    7002                 :            :         } else {
    7003         [ #  # ]:          0 :                 if (ut_params->obuf)
    7004                 :          0 :                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
    7005                 :            :                                                         uint8_t *);
    7006                 :            :                 else
    7007                 :            :                         ciphertext = plaintext;
    7008                 :            : 
    7009                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    7010                 :            :                         ciphertext_len);
    7011                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    7012                 :          0 :                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
    7013                 :            : 
    7014         [ #  # ]:          0 :                 if (tdata->digest.offset_bytes == 0)
    7015                 :            :                         digest_offset = plaintext_pad_len;
    7016                 :            :                 else
    7017                 :            :                         digest_offset =  tdata->digest.offset_bytes;
    7018                 :          0 :                 ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    7019                 :            :                                             uint8_t *, digest_offset);
    7020                 :            : 
    7021                 :          0 :                 debug_hexdump(stdout, "digest:", ut_params->digest,
    7022                 :          0 :                         tdata->digest.len);
    7023                 :          0 :                 debug_hexdump(stdout, "digest expected:",
    7024                 :          0 :                         tdata->digest.data, tdata->digest.len);
    7025                 :            :         }
    7026                 :            : 
    7027                 :            :         /* Validate obuf */
    7028         [ #  # ]:          0 :         if (verify) {
    7029   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    7030                 :            :                         plaintext,
    7031                 :            :                         tdata->plaintext.data,
    7032                 :            :                         tdata->plaintext.len >> 3,
    7033                 :            :                         "ZUC Plaintext data not as expected");
    7034                 :            :         } else {
    7035   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    7036                 :            :                         ciphertext,
    7037                 :            :                         tdata->ciphertext.data,
    7038                 :            :                         tdata->ciphertext.len >> 3,
    7039                 :            :                         "ZUC Ciphertext data not as expected");
    7040                 :            : 
    7041         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    7042                 :            :                         ut_params->digest,
    7043                 :            :                         tdata->digest.data,
    7044                 :            :                         tdata->digest.len,
    7045                 :            :                         "ZUC Generated auth tag not as expected");
    7046                 :            :         }
    7047                 :            :         return 0;
    7048                 :            : }
    7049                 :            : 
    7050                 :            : static int
    7051                 :          0 : test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
    7052                 :            :         uint8_t op_mode, uint8_t verify)
    7053                 :            : {
    7054                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    7055                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    7056                 :            : 
    7057                 :            :         int retval;
    7058                 :            : 
    7059                 :            :         const uint8_t *plaintext = NULL;
    7060                 :            :         const uint8_t *ciphertext = NULL;
    7061                 :            :         const uint8_t *digest = NULL;
    7062                 :            :         unsigned int plaintext_pad_len;
    7063                 :            :         unsigned int plaintext_len;
    7064                 :            :         unsigned int ciphertext_pad_len;
    7065                 :            :         unsigned int ciphertext_len;
    7066                 :            :         uint8_t buffer[10000];
    7067                 :            :         uint8_t digest_buffer[10000];
    7068                 :            : 
    7069                 :            :         struct rte_cryptodev_info dev_info;
    7070                 :            : 
    7071                 :            :         /* Check if device supports ZUC EEA3 */
    7072         [ #  # ]:          0 :         if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
    7073                 :          0 :                         tdata->key.len, tdata->cipher_iv.len) < 0)
    7074                 :            :                 return TEST_SKIPPED;
    7075                 :            : 
    7076                 :            :         /* Check if device supports ZUC EIA3 */
    7077         [ #  # ]:          0 :         if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
    7078                 :          0 :                         tdata->key.len, tdata->auth_iv.len,
    7079                 :          0 :                         tdata->digest.len) < 0)
    7080                 :            :                 return TEST_SKIPPED;
    7081                 :            : 
    7082         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    7083                 :            :                 return TEST_SKIPPED;
    7084                 :            : 
    7085                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    7086                 :            : 
    7087                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    7088                 :            : 
    7089         [ #  # ]:          0 :         if (op_mode == IN_PLACE) {
    7090         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    7091                 :            :                         printf("Device doesn't support in-place scatter-gather "
    7092                 :            :                                         "in both input and output mbufs.\n");
    7093                 :          0 :                         return TEST_SKIPPED;
    7094                 :            :                 }
    7095                 :            : 
    7096         [ #  # ]:          0 :                 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    7097         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    7098                 :            :                         printf("Device doesn't support RAW data-path APIs.\n");
    7099                 :          0 :                         return TEST_SKIPPED;
    7100                 :            :                 }
    7101                 :            :         } else {
    7102         [ #  # ]:          0 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    7103                 :            :                         return TEST_SKIPPED;
    7104         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
    7105                 :            :                         printf("Device doesn't support out-of-place scatter-gather "
    7106                 :            :                                         "in both input and output mbufs.\n");
    7107                 :          0 :                         return TEST_SKIPPED;
    7108                 :            :                 }
    7109         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    7110                 :            :                         printf("Device doesn't support digest encrypted.\n");
    7111                 :          0 :                         return TEST_SKIPPED;
    7112                 :            :                 }
    7113                 :            :         }
    7114                 :            : 
    7115                 :            :         /* Create ZUC session */
    7116                 :          0 :         retval = create_wireless_algo_auth_cipher_session(
    7117                 :          0 :                         ts_params->valid_devs[0],
    7118                 :            :                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
    7119                 :            :                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
    7120                 :            :                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
    7121                 :            :                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
    7122                 :            :                         RTE_CRYPTO_AUTH_ZUC_EIA3,
    7123                 :            :                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
    7124                 :            :                         tdata->key.data, tdata->key.len,
    7125                 :          0 :                         tdata->key.data, tdata->key.len,
    7126                 :          0 :                         tdata->auth_iv.len, tdata->digest.len,
    7127                 :          0 :                         tdata->cipher_iv.len);
    7128                 :            : 
    7129         [ #  # ]:          0 :         if (retval != 0)
    7130                 :            :                 return retval;
    7131                 :            : 
    7132         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
    7133         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len);
    7134                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    7135                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    7136                 :            : 
    7137                 :          0 :         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    7138                 :            :                         plaintext_pad_len, 15, 0);
    7139         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    7140                 :            :                         "Failed to allocate input buffer in mempool");
    7141                 :            : 
    7142         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE) {
    7143                 :          0 :                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
    7144                 :            :                                 plaintext_pad_len, 15, 0);
    7145         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
    7146                 :            :                                 "Failed to allocate output buffer in mempool");
    7147                 :            :         }
    7148                 :            : 
    7149         [ #  # ]:          0 :         if (verify) {
    7150                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
    7151                 :          0 :                         tdata->ciphertext.data);
    7152         [ #  # ]:          0 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    7153                 :            :                                         ciphertext_len, buffer);
    7154                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    7155                 :            :                         ciphertext_len);
    7156                 :            :         } else {
    7157                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
    7158                 :          0 :                         tdata->plaintext.data);
    7159         [ #  # ]:          0 :                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    7160                 :            :                                         plaintext_len, buffer);
    7161                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    7162                 :            :                         plaintext_len);
    7163                 :            :         }
    7164                 :            :         memset(buffer, 0, sizeof(buffer));
    7165                 :            : 
    7166                 :            :         /* Create ZUC operation */
    7167                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    7168                 :          0 :                 tdata->digest.data, tdata->digest.len,
    7169                 :          0 :                 tdata->cipher_iv.data, tdata->cipher_iv.len,
    7170                 :          0 :                 tdata->auth_iv.data, tdata->auth_iv.len,
    7171                 :          0 :                 (tdata->digest.offset_bytes == 0 ?
    7172         [ #  # ]:          0 :                 (verify ? ciphertext_pad_len : plaintext_pad_len)
    7173                 :            :                         : tdata->digest.offset_bytes),
    7174                 :          0 :                 tdata->validCipherLenInBits.len,
    7175                 :          0 :                 tdata->validCipherOffsetInBits.len,
    7176         [ #  # ]:          0 :                 tdata->validAuthLenInBits.len,
    7177                 :            :                 0,
    7178                 :            :                 op_mode, 1, verify);
    7179                 :            : 
    7180         [ #  # ]:          0 :         if (retval < 0)
    7181                 :            :                 return retval;
    7182                 :            : 
    7183         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    7184                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
    7185                 :          0 :                                                tdata->cipher_iv.len);
    7186         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    7187                 :            :                         return retval;
    7188                 :            :         } else
    7189                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    7190                 :            :                         ut_params->op);
    7191                 :            : 
    7192         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    7193                 :            : 
    7194                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    7195         [ #  # ]:          0 :                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    7196                 :            : 
    7197         [ #  # ]:          0 :         if (verify) {
    7198         [ #  # ]:          0 :                 if (ut_params->obuf)
    7199                 :            :                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
    7200                 :            :                                         plaintext_len, buffer);
    7201                 :            :                 else
    7202         [ #  # ]:          0 :                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    7203                 :            :                                         plaintext_len, buffer);
    7204                 :            : 
    7205                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    7206                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    7207                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    7208                 :          0 :                         tdata->plaintext.data,
    7209                 :          0 :                         (tdata->plaintext.len >> 3) - tdata->digest.len);
    7210                 :            :         } else {
    7211         [ #  # ]:          0 :                 if (ut_params->obuf)
    7212                 :            :                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    7213                 :            :                                         ciphertext_len, buffer);
    7214                 :            :                 else
    7215         [ #  # ]:          0 :                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    7216                 :            :                                         ciphertext_len, buffer);
    7217                 :            : 
    7218                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    7219                 :            :                         ciphertext_len);
    7220                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    7221                 :          0 :                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
    7222                 :            : 
    7223         [ #  # ]:          0 :                 if (ut_params->obuf)
    7224                 :          0 :                         digest = rte_pktmbuf_read(ut_params->obuf,
    7225                 :          0 :                                 (tdata->digest.offset_bytes == 0 ?
    7226                 :            :                                 plaintext_pad_len : tdata->digest.offset_bytes),
    7227         [ #  # ]:          0 :                                 tdata->digest.len, digest_buffer);
    7228                 :            :                 else
    7229         [ #  # ]:          0 :                         digest = rte_pktmbuf_read(ut_params->ibuf,
    7230                 :          0 :                                 (tdata->digest.offset_bytes == 0 ?
    7231                 :            :                                 plaintext_pad_len : tdata->digest.offset_bytes),
    7232         [ #  # ]:          0 :                                 tdata->digest.len, digest_buffer);
    7233                 :            : 
    7234                 :          0 :                 debug_hexdump(stdout, "digest:", digest,
    7235                 :          0 :                         tdata->digest.len);
    7236                 :          0 :                 debug_hexdump(stdout, "digest expected:",
    7237                 :          0 :                         tdata->digest.data, tdata->digest.len);
    7238                 :            :         }
    7239                 :            : 
    7240                 :            :         /* Validate obuf */
    7241         [ #  # ]:          0 :         if (verify) {
    7242   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    7243                 :            :                         plaintext,
    7244                 :            :                         tdata->plaintext.data,
    7245                 :            :                         tdata->plaintext.len >> 3,
    7246                 :            :                         "ZUC Plaintext data not as expected");
    7247                 :            :         } else {
    7248   [ #  #  #  #  :          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    7249                 :            :                         ciphertext,
    7250                 :            :                         tdata->ciphertext.data,
    7251                 :            :                         tdata->validDataLenInBits.len,
    7252                 :            :                         "ZUC Ciphertext data not as expected");
    7253                 :            : 
    7254         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    7255                 :            :                         digest,
    7256                 :            :                         tdata->digest.data,
    7257                 :            :                         tdata->digest.len,
    7258                 :            :                         "ZUC Generated auth tag not as expected");
    7259                 :            :         }
    7260                 :            :         return 0;
    7261                 :            : }
    7262                 :            : 
    7263                 :            : static int
    7264                 :          0 : test_kasumi_encryption_test_case_1(void)
    7265                 :            : {
    7266                 :          0 :         return test_kasumi_encryption(&kasumi_test_case_1);
    7267                 :            : }
    7268                 :            : 
    7269                 :            : static int
    7270                 :          0 : test_kasumi_encryption_test_case_1_sgl(void)
    7271                 :            : {
    7272                 :          0 :         return test_kasumi_encryption_sgl(&kasumi_test_case_1);
    7273                 :            : }
    7274                 :            : 
    7275                 :            : static int
    7276                 :          0 : test_kasumi_encryption_test_case_1_oop(void)
    7277                 :            : {
    7278                 :          0 :         return test_kasumi_encryption_oop(&kasumi_test_case_1);
    7279                 :            : }
    7280                 :            : 
    7281                 :            : static int
    7282                 :          0 : test_kasumi_encryption_test_case_1_oop_sgl(void)
    7283                 :            : {
    7284                 :          0 :         return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
    7285                 :            : }
    7286                 :            : 
    7287                 :            : static int
    7288                 :          0 : test_kasumi_encryption_test_case_2(void)
    7289                 :            : {
    7290                 :          0 :         return test_kasumi_encryption(&kasumi_test_case_2);
    7291                 :            : }
    7292                 :            : 
    7293                 :            : static int
    7294                 :          0 : test_kasumi_encryption_test_case_3(void)
    7295                 :            : {
    7296                 :          0 :         return test_kasumi_encryption(&kasumi_test_case_3);
    7297                 :            : }
    7298                 :            : 
    7299                 :            : static int
    7300                 :          0 : test_kasumi_encryption_test_case_4(void)
    7301                 :            : {
    7302                 :          0 :         return test_kasumi_encryption(&kasumi_test_case_4);
    7303                 :            : }
    7304                 :            : 
    7305                 :            : static int
    7306                 :          0 : test_kasumi_encryption_test_case_5(void)
    7307                 :            : {
    7308                 :          0 :         return test_kasumi_encryption(&kasumi_test_case_5);
    7309                 :            : }
    7310                 :            : 
    7311                 :            : static int
    7312                 :          0 : test_kasumi_decryption_test_case_1(void)
    7313                 :            : {
    7314                 :          0 :         return test_kasumi_decryption(&kasumi_test_case_1);
    7315                 :            : }
    7316                 :            : 
    7317                 :            : static int
    7318                 :          0 : test_kasumi_decryption_test_case_1_oop(void)
    7319                 :            : {
    7320                 :          0 :         return test_kasumi_decryption_oop(&kasumi_test_case_1);
    7321                 :            : }
    7322                 :            : 
    7323                 :            : static int
    7324                 :          0 : test_kasumi_decryption_test_case_2(void)
    7325                 :            : {
    7326                 :          0 :         return test_kasumi_decryption(&kasumi_test_case_2);
    7327                 :            : }
    7328                 :            : 
    7329                 :            : static int
    7330                 :          0 : test_kasumi_decryption_test_case_3(void)
    7331                 :            : {
    7332                 :            :         /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
    7333         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    7334                 :            :                 return TEST_SKIPPED;
    7335                 :          0 :         return test_kasumi_decryption(&kasumi_test_case_3);
    7336                 :            : }
    7337                 :            : 
    7338                 :            : static int
    7339                 :          0 : test_kasumi_decryption_test_case_4(void)
    7340                 :            : {
    7341                 :          0 :         return test_kasumi_decryption(&kasumi_test_case_4);
    7342                 :            : }
    7343                 :            : 
    7344                 :            : static int
    7345                 :          0 : test_kasumi_decryption_test_case_5(void)
    7346                 :            : {
    7347                 :          0 :         return test_kasumi_decryption(&kasumi_test_case_5);
    7348                 :            : }
    7349                 :            : static int
    7350                 :          0 : test_snow3g_encryption_test_case_1(void)
    7351                 :            : {
    7352                 :          0 :         return test_snow3g_encryption(&snow3g_test_case_1);
    7353                 :            : }
    7354                 :            : 
    7355                 :            : static int
    7356                 :          0 : test_snow3g_encryption_test_case_1_oop(void)
    7357                 :            : {
    7358                 :          0 :         return test_snow3g_encryption_oop(&snow3g_test_case_1);
    7359                 :            : }
    7360                 :            : 
    7361                 :            : static int
    7362                 :          0 : test_snow3g_encryption_test_case_1_oop_sgl(void)
    7363                 :            : {
    7364                 :          0 :         return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
    7365                 :            : }
    7366                 :            : 
    7367                 :            : static int
    7368                 :          0 : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
    7369                 :            : {
    7370                 :          0 :         return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
    7371                 :            : }
    7372                 :            : 
    7373                 :            : static int
    7374                 :          0 : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
    7375                 :            : {
    7376                 :          0 :         return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
    7377                 :            : }
    7378                 :            : 
    7379                 :            : static int
    7380                 :          0 : test_snow3g_encryption_test_case_1_offset_oop(void)
    7381                 :            : {
    7382                 :          0 :         return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
    7383                 :            : }
    7384                 :            : 
    7385                 :            : static int
    7386                 :          0 : test_snow3g_encryption_test_case_2(void)
    7387                 :            : {
    7388                 :          0 :         return test_snow3g_encryption(&snow3g_test_case_2);
    7389                 :            : }
    7390                 :            : 
    7391                 :            : static int
    7392                 :          0 : test_snow3g_encryption_test_case_3(void)
    7393                 :            : {
    7394                 :          0 :         return test_snow3g_encryption(&snow3g_test_case_3);
    7395                 :            : }
    7396                 :            : 
    7397                 :            : static int
    7398                 :          0 : test_snow3g_encryption_test_case_4(void)
    7399                 :            : {
    7400                 :          0 :         return test_snow3g_encryption(&snow3g_test_case_4);
    7401                 :            : }
    7402                 :            : 
    7403                 :            : static int
    7404                 :          0 : test_snow3g_encryption_test_case_5(void)
    7405                 :            : {
    7406                 :          0 :         return test_snow3g_encryption(&snow3g_test_case_5);
    7407                 :            : }
    7408                 :            : 
    7409                 :            : static int
    7410                 :          0 : test_snow3g_decryption_test_case_1(void)
    7411                 :            : {
    7412                 :          0 :         return test_snow3g_decryption(&snow3g_test_case_1);
    7413                 :            : }
    7414                 :            : 
    7415                 :            : static int
    7416                 :          0 : test_snow3g_decryption_test_case_1_oop(void)
    7417                 :            : {
    7418                 :          0 :         return test_snow3g_decryption_oop(&snow3g_test_case_1);
    7419                 :            : }
    7420                 :            : 
    7421                 :            : static int
    7422                 :          0 : test_snow3g_decryption_test_case_2(void)
    7423                 :            : {
    7424                 :          0 :         return test_snow3g_decryption(&snow3g_test_case_2);
    7425                 :            : }
    7426                 :            : 
    7427                 :            : static int
    7428                 :          0 : test_snow3g_decryption_test_case_3(void)
    7429                 :            : {
    7430                 :          0 :         return test_snow3g_decryption(&snow3g_test_case_3);
    7431                 :            : }
    7432                 :            : 
    7433                 :            : static int
    7434                 :          0 : test_snow3g_decryption_test_case_4(void)
    7435                 :            : {
    7436                 :          0 :         return test_snow3g_decryption(&snow3g_test_case_4);
    7437                 :            : }
    7438                 :            : 
    7439                 :            : static int
    7440                 :          0 : test_snow3g_decryption_test_case_5(void)
    7441                 :            : {
    7442                 :          0 :         return test_snow3g_decryption(&snow3g_test_case_5);
    7443                 :            : }
    7444                 :            : 
    7445                 :            : /*
    7446                 :            :  * Function prepares snow3g_hash_test_data from snow3g_test_data.
    7447                 :            :  * Pattern digest from snow3g_test_data must be allocated as
    7448                 :            :  * 4 last bytes in plaintext.
    7449                 :            :  */
    7450                 :            : static void
    7451                 :          0 : snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
    7452                 :            :                 struct snow3g_hash_test_data *output)
    7453                 :            : {
    7454         [ #  # ]:          0 :         if ((pattern != NULL) && (output != NULL)) {
    7455                 :          0 :                 output->key.len = pattern->key.len;
    7456                 :            : 
    7457                 :          0 :                 memcpy(output->key.data,
    7458                 :          0 :                 pattern->key.data, pattern->key.len);
    7459                 :            : 
    7460                 :          0 :                 output->auth_iv.len = pattern->auth_iv.len;
    7461                 :            : 
    7462                 :          0 :                 memcpy(output->auth_iv.data,
    7463                 :          0 :                 pattern->auth_iv.data, pattern->auth_iv.len);
    7464                 :            : 
    7465                 :          0 :                 output->plaintext.len = pattern->plaintext.len;
    7466                 :            : 
    7467                 :          0 :                 memcpy(output->plaintext.data,
    7468                 :          0 :                 pattern->plaintext.data, pattern->plaintext.len >> 3);
    7469                 :            : 
    7470                 :          0 :                 output->digest.len = pattern->digest.len;
    7471                 :            : 
    7472                 :          0 :                 memcpy(output->digest.data,
    7473                 :          0 :                 &pattern->plaintext.data[pattern->digest.offset_bytes],
    7474                 :            :                 pattern->digest.len);
    7475                 :            : 
    7476                 :          0 :                 output->validAuthLenInBits.len =
    7477                 :          0 :                 pattern->validAuthLenInBits.len;
    7478                 :            :         }
    7479                 :          0 : }
    7480                 :            : 
    7481                 :            : /*
    7482                 :            :  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
    7483                 :            :  */
    7484                 :            : static int
    7485                 :          0 : test_snow3g_decryption_with_digest_test_case_1(void)
    7486                 :            : {
    7487                 :            :         int ret;
    7488                 :            :         struct snow3g_hash_test_data snow3g_hash_data;
    7489                 :            :         struct rte_cryptodev_info dev_info;
    7490                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    7491                 :            : 
    7492                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    7493                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
    7494                 :            : 
    7495         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    7496                 :            :                 printf("Device doesn't support encrypted digest operations.\n");
    7497                 :          0 :                 return TEST_SKIPPED;
    7498                 :            :         }
    7499                 :            : 
    7500                 :            :         /*
    7501                 :            :          * Function prepare data for hash verification test case.
    7502                 :            :          * Digest is allocated in 4 last bytes in plaintext, pattern.
    7503                 :            :          */
    7504                 :          0 :         snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
    7505                 :            : 
    7506                 :          0 :         ret = test_snow3g_decryption(&snow3g_test_case_7);
    7507         [ #  # ]:          0 :         if (ret != 0)
    7508                 :            :                 return ret;
    7509                 :            : 
    7510                 :          0 :         return test_snow3g_authentication_verify(&snow3g_hash_data);
    7511                 :            : }
    7512                 :            : 
    7513                 :            : static int
    7514                 :          0 : test_snow3g_cipher_auth_test_case_1(void)
    7515                 :            : {
    7516                 :          0 :         return test_snow3g_cipher_auth(&snow3g_test_case_3);
    7517                 :            : }
    7518                 :            : 
    7519                 :            : static int
    7520                 :          0 : test_snow3g_auth_cipher_test_case_1(void)
    7521                 :            : {
    7522                 :          0 :         return test_snow3g_auth_cipher(
    7523                 :            :                 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
    7524                 :            : }
    7525                 :            : 
    7526                 :            : static int
    7527                 :          0 : test_snow3g_auth_cipher_test_case_2(void)
    7528                 :            : {
    7529                 :          0 :         return test_snow3g_auth_cipher(
    7530                 :            :                 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
    7531                 :            : }
    7532                 :            : 
    7533                 :            : static int
    7534                 :          0 : test_snow3g_auth_cipher_test_case_2_oop(void)
    7535                 :            : {
    7536                 :          0 :         return test_snow3g_auth_cipher(
    7537                 :            :                 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
    7538                 :            : }
    7539                 :            : 
    7540                 :            : static int
    7541                 :          0 : test_snow3g_auth_cipher_part_digest_enc(void)
    7542                 :            : {
    7543                 :          0 :         return test_snow3g_auth_cipher(
    7544                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7545                 :            :                         IN_PLACE, 0);
    7546                 :            : }
    7547                 :            : 
    7548                 :            : static int
    7549                 :          0 : test_snow3g_auth_cipher_part_digest_enc_oop(void)
    7550                 :            : {
    7551                 :          0 :         return test_snow3g_auth_cipher(
    7552                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7553                 :            :                         OUT_OF_PLACE, 0);
    7554                 :            : }
    7555                 :            : 
    7556                 :            : static int
    7557                 :          0 : test_snow3g_auth_cipher_test_case_3_sgl(void)
    7558                 :            : {
    7559                 :            :         /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
    7560         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    7561                 :            :                 return TEST_SKIPPED;
    7562                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7563                 :            :                 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
    7564                 :            : }
    7565                 :            : 
    7566                 :            : static int
    7567                 :          0 : test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
    7568                 :            : {
    7569                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7570                 :            :                 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
    7571                 :            : }
    7572                 :            : 
    7573                 :            : static int
    7574                 :          0 : test_snow3g_auth_cipher_part_digest_enc_sgl(void)
    7575                 :            : {
    7576                 :            :         /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
    7577         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    7578                 :            :                 return TEST_SKIPPED;
    7579                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7580                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7581                 :            :                         IN_PLACE, 0);
    7582                 :            : }
    7583                 :            : 
    7584                 :            : static int
    7585                 :          0 : test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
    7586                 :            : {
    7587                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7588                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7589                 :            :                         OUT_OF_PLACE, 0);
    7590                 :            : }
    7591                 :            : 
    7592                 :            : static int
    7593                 :          0 : test_snow3g_auth_cipher_total_digest_enc_1(void)
    7594                 :            : {
    7595                 :          0 :         return test_snow3g_auth_cipher(
    7596                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
    7597                 :            : }
    7598                 :            : 
    7599                 :            : static int
    7600                 :          0 : test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
    7601                 :            : {
    7602                 :          0 :         return test_snow3g_auth_cipher(
    7603                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
    7604                 :            : }
    7605                 :            : 
    7606                 :            : static int
    7607                 :          0 : test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
    7608                 :            : {
    7609                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7610                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
    7611                 :            : }
    7612                 :            : 
    7613                 :            : static int
    7614                 :          0 : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
    7615                 :            : {
    7616                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7617                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
    7618                 :            : }
    7619                 :            : 
    7620                 :            : static int
    7621                 :          0 : test_snow3g_auth_cipher_verify_test_case_1(void)
    7622                 :            : {
    7623                 :          0 :         return test_snow3g_auth_cipher(
    7624                 :            :                 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
    7625                 :            : }
    7626                 :            : 
    7627                 :            : static int
    7628                 :          0 : test_snow3g_auth_cipher_verify_test_case_2(void)
    7629                 :            : {
    7630                 :          0 :         return test_snow3g_auth_cipher(
    7631                 :            :                 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
    7632                 :            : }
    7633                 :            : 
    7634                 :            : static int
    7635                 :          0 : test_snow3g_auth_cipher_verify_test_case_2_oop(void)
    7636                 :            : {
    7637                 :          0 :         return test_snow3g_auth_cipher(
    7638                 :            :                 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
    7639                 :            : }
    7640                 :            : 
    7641                 :            : static int
    7642                 :          0 : test_snow3g_auth_cipher_verify_part_digest_enc(void)
    7643                 :            : {
    7644                 :          0 :         return test_snow3g_auth_cipher(
    7645                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7646                 :            :                         IN_PLACE, 1);
    7647                 :            : }
    7648                 :            : 
    7649                 :            : static int
    7650                 :          0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
    7651                 :            : {
    7652                 :          0 :         return test_snow3g_auth_cipher(
    7653                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7654                 :            :                         OUT_OF_PLACE, 1);
    7655                 :            : }
    7656                 :            : 
    7657                 :            : static int
    7658                 :          0 : test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
    7659                 :            : {
    7660                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7661                 :            :                 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
    7662                 :            : }
    7663                 :            : 
    7664                 :            : static int
    7665                 :          0 : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
    7666                 :            : {
    7667                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7668                 :            :                 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
    7669                 :            : }
    7670                 :            : 
    7671                 :            : static int
    7672                 :          0 : test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
    7673                 :            : {
    7674                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7675                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7676                 :            :                         IN_PLACE, 1);
    7677                 :            : }
    7678                 :            : 
    7679                 :            : static int
    7680                 :          0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
    7681                 :            : {
    7682                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7683                 :            :                 &snow3g_auth_cipher_partial_digest_encryption,
    7684                 :            :                         OUT_OF_PLACE, 1);
    7685                 :            : }
    7686                 :            : 
    7687                 :            : static int
    7688                 :          0 : test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
    7689                 :            : {
    7690                 :          0 :         return test_snow3g_auth_cipher(
    7691                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
    7692                 :            : }
    7693                 :            : 
    7694                 :            : static int
    7695                 :          0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
    7696                 :            : {
    7697                 :          0 :         return test_snow3g_auth_cipher(
    7698                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
    7699                 :            : }
    7700                 :            : 
    7701                 :            : static int
    7702                 :          0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
    7703                 :            : {
    7704                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7705                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
    7706                 :            : }
    7707                 :            : 
    7708                 :            : static int
    7709                 :          0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
    7710                 :            : {
    7711                 :          0 :         return test_snow3g_auth_cipher_sgl(
    7712                 :            :                 &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
    7713                 :            : }
    7714                 :            : 
    7715                 :            : static int
    7716                 :          0 : test_snow3g_auth_cipher_with_digest_test_case_1(void)
    7717                 :            : {
    7718                 :          0 :         return test_snow3g_auth_cipher(
    7719                 :            :                 &snow3g_test_case_7, IN_PLACE, 0);
    7720                 :            : }
    7721                 :            : 
    7722                 :            : static int
    7723                 :          0 : test_kasumi_auth_cipher_test_case_1(void)
    7724                 :            : {
    7725                 :          0 :         return test_kasumi_auth_cipher(
    7726                 :            :                 &kasumi_test_case_3, IN_PLACE, 0);
    7727                 :            : }
    7728                 :            : 
    7729                 :            : static int
    7730                 :          0 : test_kasumi_auth_cipher_test_case_2(void)
    7731                 :            : {
    7732                 :          0 :         return test_kasumi_auth_cipher(
    7733                 :            :                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
    7734                 :            : }
    7735                 :            : 
    7736                 :            : static int
    7737                 :          0 : test_kasumi_auth_cipher_test_case_2_oop(void)
    7738                 :            : {
    7739                 :          0 :         return test_kasumi_auth_cipher(
    7740                 :            :                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
    7741                 :            : }
    7742                 :            : 
    7743                 :            : static int
    7744                 :          0 : test_kasumi_auth_cipher_test_case_2_sgl(void)
    7745                 :            : {
    7746                 :          0 :         return test_kasumi_auth_cipher_sgl(
    7747                 :            :                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
    7748                 :            : }
    7749                 :            : 
    7750                 :            : static int
    7751                 :          0 : test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
    7752                 :            : {
    7753                 :          0 :         return test_kasumi_auth_cipher_sgl(
    7754                 :            :                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
    7755                 :            : }
    7756                 :            : 
    7757                 :            : static int
    7758                 :          0 : test_kasumi_auth_cipher_verify_test_case_1(void)
    7759                 :            : {
    7760                 :          0 :         return test_kasumi_auth_cipher(
    7761                 :            :                 &kasumi_test_case_3, IN_PLACE, 1);
    7762                 :            : }
    7763                 :            : 
    7764                 :            : static int
    7765                 :          0 : test_kasumi_auth_cipher_verify_test_case_2(void)
    7766                 :            : {
    7767                 :          0 :         return test_kasumi_auth_cipher(
    7768                 :            :                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
    7769                 :            : }
    7770                 :            : 
    7771                 :            : static int
    7772                 :          0 : test_kasumi_auth_cipher_verify_test_case_2_oop(void)
    7773                 :            : {
    7774                 :          0 :         return test_kasumi_auth_cipher(
    7775                 :            :                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
    7776                 :            : }
    7777                 :            : 
    7778                 :            : static int
    7779                 :          0 : test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
    7780                 :            : {
    7781                 :          0 :         return test_kasumi_auth_cipher_sgl(
    7782                 :            :                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
    7783                 :            : }
    7784                 :            : 
    7785                 :            : static int
    7786                 :          0 : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
    7787                 :            : {
    7788                 :          0 :         return test_kasumi_auth_cipher_sgl(
    7789                 :            :                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
    7790                 :            : }
    7791                 :            : 
    7792                 :            : static int
    7793                 :          0 : test_kasumi_cipher_auth_test_case_1(void)
    7794                 :            : {
    7795                 :          0 :         return test_kasumi_cipher_auth(&kasumi_test_case_6);
    7796                 :            : }
    7797                 :            : 
    7798                 :            : static int
    7799                 :          0 : test_zuc_encryption_test_case_1(void)
    7800                 :            : {
    7801                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_193b,
    7802                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    7803                 :            : }
    7804                 :            : 
    7805                 :            : static int
    7806                 :          0 : test_zuc_encryption_test_case_2(void)
    7807                 :            : {
    7808                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_800b,
    7809                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    7810                 :            : }
    7811                 :            : 
    7812                 :            : static int
    7813                 :          0 : test_zuc_encryption_test_case_3(void)
    7814                 :            : {
    7815                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_1570b,
    7816                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    7817                 :            : }
    7818                 :            : 
    7819                 :            : static int
    7820                 :          0 : test_zuc_encryption_test_case_4(void)
    7821                 :            : {
    7822                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_2798b,
    7823                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    7824                 :            : }
    7825                 :            : 
    7826                 :            : static int
    7827                 :          0 : test_zuc_encryption_test_case_5(void)
    7828                 :            : {
    7829                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_4019b,
    7830                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    7831                 :            : }
    7832                 :            : 
    7833                 :            : static int
    7834                 :          0 : test_zuc_encryption_test_case_6_sgl(void)
    7835                 :            : {
    7836                 :          0 :         return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
    7837                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    7838                 :            : }
    7839                 :            : 
    7840                 :            : static int
    7841                 :          0 : test_zuc_decryption_test_case_1(void)
    7842                 :            : {
    7843                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_193b,
    7844                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    7845                 :            : }
    7846                 :            : 
    7847                 :            : static int
    7848                 :          0 : test_zuc_decryption_test_case_2(void)
    7849                 :            : {
    7850                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_800b,
    7851                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    7852                 :            : }
    7853                 :            : 
    7854                 :            : static int
    7855                 :          0 : test_zuc_decryption_test_case_3(void)
    7856                 :            : {
    7857                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_1570b,
    7858                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    7859                 :            : }
    7860                 :            : 
    7861                 :            : static int
    7862                 :          0 : test_zuc_decryption_test_case_4(void)
    7863                 :            : {
    7864                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_2798b,
    7865                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    7866                 :            : }
    7867                 :            : 
    7868                 :            : static int
    7869                 :          0 : test_zuc_decryption_test_case_5(void)
    7870                 :            : {
    7871                 :          0 :         return test_zuc_cipher(&zuc_test_case_cipher_4019b,
    7872                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    7873                 :            : }
    7874                 :            : 
    7875                 :            : static int
    7876                 :          0 : test_zuc_decryption_test_case_6_sgl(void)
    7877                 :            : {
    7878                 :          0 :         return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
    7879                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    7880                 :            : }
    7881                 :            : 
    7882                 :            : static int
    7883                 :          0 : test_zuc_hash_generate_test_case_1(void)
    7884                 :            : {
    7885                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_1b,
    7886                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7887                 :            : }
    7888                 :            : 
    7889                 :            : static int
    7890                 :          0 : test_zuc_hash_generate_test_case_2(void)
    7891                 :            : {
    7892                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_90b,
    7893                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7894                 :            : }
    7895                 :            : 
    7896                 :            : static int
    7897                 :          0 : test_zuc_hash_generate_test_case_3(void)
    7898                 :            : {
    7899                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_577b,
    7900                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7901                 :            : }
    7902                 :            : 
    7903                 :            : static int
    7904                 :          0 : test_zuc_hash_generate_test_case_4(void)
    7905                 :            : {
    7906                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_2079b,
    7907                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7908                 :            : }
    7909                 :            : 
    7910                 :            : static int
    7911                 :          0 : test_zuc_hash_generate_test_case_5(void)
    7912                 :            : {
    7913                 :          0 :         return test_zuc_authentication(&zuc_test_auth_5670b,
    7914                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7915                 :            : }
    7916                 :            : 
    7917                 :            : static int
    7918                 :          0 : test_zuc_hash_generate_test_case_6(void)
    7919                 :            : {
    7920                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_128b,
    7921                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7922                 :            : }
    7923                 :            : 
    7924                 :            : static int
    7925                 :          0 : test_zuc_hash_generate_test_case_7(void)
    7926                 :            : {
    7927                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_2080b,
    7928                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7929                 :            : }
    7930                 :            : 
    7931                 :            : static int
    7932                 :          0 : test_zuc_hash_generate_test_case_8(void)
    7933                 :            : {
    7934                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_584b,
    7935                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    7936                 :            : }
    7937                 :            : 
    7938                 :            : static int
    7939                 :          0 : test_zuc_hash_verify_test_case_1(void)
    7940                 :            : {
    7941                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_1b,
    7942                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    7943                 :            : }
    7944                 :            : 
    7945                 :            : static int
    7946                 :          0 : test_zuc_hash_verify_test_case_2(void)
    7947                 :            : {
    7948                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_90b,
    7949                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    7950                 :            : }
    7951                 :            : 
    7952                 :            : static int
    7953                 :          0 : test_zuc_hash_verify_test_case_3(void)
    7954                 :            : {
    7955                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_577b,
    7956                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    7957                 :            : }
    7958                 :            : 
    7959                 :            : static int
    7960                 :          0 : test_zuc_hash_verify_test_case_4(void)
    7961                 :            : {
    7962                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_2079b,
    7963                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    7964                 :            : }
    7965                 :            : 
    7966                 :            : static int
    7967                 :          0 : test_zuc_hash_verify_test_case_5(void)
    7968                 :            : {
    7969                 :          0 :         return test_zuc_authentication(&zuc_test_auth_5670b,
    7970                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    7971                 :            : }
    7972                 :            : 
    7973                 :            : static int
    7974                 :          0 : test_zuc_hash_verify_test_case_6(void)
    7975                 :            : {
    7976                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_128b,
    7977                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    7978                 :            : }
    7979                 :            : 
    7980                 :            : static int
    7981                 :          0 : test_zuc_hash_verify_test_case_7(void)
    7982                 :            : {
    7983                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_2080b,
    7984                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    7985                 :            : }
    7986                 :            : 
    7987                 :            : static int
    7988                 :          0 : test_zuc_hash_verify_test_case_8(void)
    7989                 :            : {
    7990                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_584b,
    7991                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    7992                 :            : }
    7993                 :            : 
    7994                 :            : static int
    7995                 :          0 : test_zuc_cipher_auth_test_case_1(void)
    7996                 :            : {
    7997                 :          0 :         return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
    7998                 :            : }
    7999                 :            : 
    8000                 :            : static int
    8001                 :          0 : test_zuc_cipher_auth_test_case_2(void)
    8002                 :            : {
    8003                 :          0 :         return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
    8004                 :            : }
    8005                 :            : 
    8006                 :            : static int
    8007                 :          0 : test_zuc_auth_cipher_test_case_1(void)
    8008                 :            : {
    8009                 :          0 :         return test_zuc_auth_cipher(
    8010                 :            :                 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
    8011                 :            : }
    8012                 :            : 
    8013                 :            : static int
    8014                 :          0 : test_zuc_auth_cipher_test_case_1_oop(void)
    8015                 :            : {
    8016                 :          0 :         return test_zuc_auth_cipher(
    8017                 :            :                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
    8018                 :            : }
    8019                 :            : 
    8020                 :            : static int
    8021                 :          0 : test_zuc_auth_cipher_test_case_1_sgl(void)
    8022                 :            : {
    8023                 :          0 :         return test_zuc_auth_cipher_sgl(
    8024                 :            :                 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
    8025                 :            : }
    8026                 :            : 
    8027                 :            : static int
    8028                 :          0 : test_zuc_auth_cipher_test_case_1_oop_sgl(void)
    8029                 :            : {
    8030                 :          0 :         return test_zuc_auth_cipher_sgl(
    8031                 :            :                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
    8032                 :            : }
    8033                 :            : 
    8034                 :            : static int
    8035                 :          0 : test_zuc_auth_cipher_test_case_2(void)
    8036                 :            : {
    8037                 :          0 :         return test_zuc_auth_cipher(
    8038                 :            :                 &zuc_auth_cipher_test_case_2, IN_PLACE, 0);
    8039                 :            : }
    8040                 :            : 
    8041                 :            : static int
    8042                 :          0 : test_zuc_auth_cipher_test_case_2_oop(void)
    8043                 :            : {
    8044                 :          0 :         return test_zuc_auth_cipher(
    8045                 :            :                 &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
    8046                 :            : }
    8047                 :            : 
    8048                 :            : static int
    8049                 :          0 : test_zuc_auth_cipher_verify_test_case_1(void)
    8050                 :            : {
    8051                 :          0 :         return test_zuc_auth_cipher(
    8052                 :            :                 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
    8053                 :            : }
    8054                 :            : 
    8055                 :            : static int
    8056                 :          0 : test_zuc_auth_cipher_verify_test_case_1_oop(void)
    8057                 :            : {
    8058                 :          0 :         return test_zuc_auth_cipher(
    8059                 :            :                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
    8060                 :            : }
    8061                 :            : 
    8062                 :            : static int
    8063                 :          0 : test_zuc_auth_cipher_verify_test_case_1_sgl(void)
    8064                 :            : {
    8065                 :          0 :         return test_zuc_auth_cipher_sgl(
    8066                 :            :                 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
    8067                 :            : }
    8068                 :            : 
    8069                 :            : static int
    8070                 :          0 : test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
    8071                 :            : {
    8072                 :          0 :         return test_zuc_auth_cipher_sgl(
    8073                 :            :                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
    8074                 :            : }
    8075                 :            : 
    8076                 :            : static int
    8077                 :          0 : test_zuc_auth_cipher_verify_test_case_2(void)
    8078                 :            : {
    8079                 :          0 :         return test_zuc_auth_cipher(
    8080                 :            :                 &zuc_auth_cipher_test_case_2, IN_PLACE, 1);
    8081                 :            : }
    8082                 :            : 
    8083                 :            : static int
    8084                 :          0 : test_zuc_auth_cipher_verify_test_case_2_oop(void)
    8085                 :            : {
    8086                 :          0 :         return test_zuc_auth_cipher(
    8087                 :            :                 &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
    8088                 :            : }
    8089                 :            : 
    8090                 :            : static int
    8091                 :          0 : test_zuc256_encryption_test_case_1(void)
    8092                 :            : {
    8093                 :          0 :         return test_zuc_cipher(&zuc256_test_case_cipher_1,
    8094                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    8095                 :            : }
    8096                 :            : 
    8097                 :            : static int
    8098                 :          0 : test_zuc256_encryption_test_case_2(void)
    8099                 :            : {
    8100                 :          0 :         return test_zuc_cipher(&zuc256_test_case_cipher_2,
    8101                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT);
    8102                 :            : }
    8103                 :            : 
    8104                 :            : static int
    8105                 :          0 : test_zuc256_decryption_test_case_1(void)
    8106                 :            : {
    8107                 :          0 :         return test_zuc_cipher(&zuc256_test_case_cipher_1,
    8108                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    8109                 :            : }
    8110                 :            : 
    8111                 :            : static int
    8112                 :          0 : test_zuc256_decryption_test_case_2(void)
    8113                 :            : {
    8114                 :          0 :         return test_zuc_cipher(&zuc256_test_case_cipher_2,
    8115                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
    8116                 :            : }
    8117                 :            : 
    8118                 :            : static int
    8119                 :          0 : test_zuc256_hash_generate_4b_tag_test_case_1(void)
    8120                 :            : {
    8121                 :          0 :         return test_zuc_authentication(&zuc256_test_case_auth_1,
    8122                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    8123                 :            : }
    8124                 :            : 
    8125                 :            : static int
    8126                 :          0 : test_zuc256_hash_generate_4b_tag_test_case_2(void)
    8127                 :            : {
    8128                 :          0 :         return test_zuc_authentication(&zuc256_test_case_auth_2,
    8129                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    8130                 :            : }
    8131                 :            : 
    8132                 :            : static int
    8133                 :          0 : test_zuc256_hash_generate_4b_tag_test_case_3(void)
    8134                 :            : {
    8135                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
    8136                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    8137                 :            : }
    8138                 :            : 
    8139                 :            : static int
    8140                 :          0 : test_zuc256_hash_generate_8b_tag_test_case_1(void)
    8141                 :            : {
    8142                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
    8143                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    8144                 :            : }
    8145                 :            : 
    8146                 :            : static int
    8147                 :          0 : test_zuc256_hash_generate_16b_tag_test_case_1(void)
    8148                 :            : {
    8149                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
    8150                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE);
    8151                 :            : }
    8152                 :            : 
    8153                 :            : static int
    8154                 :          0 : test_zuc256_hash_verify_4b_tag_test_case_1(void)
    8155                 :            : {
    8156                 :          0 :         return test_zuc_authentication(&zuc256_test_case_auth_1,
    8157                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8158                 :            : }
    8159                 :            : 
    8160                 :            : static int
    8161                 :          0 : test_zuc256_hash_verify_4b_tag_test_case_2(void)
    8162                 :            : {
    8163                 :          0 :         return test_zuc_authentication(&zuc256_test_case_auth_2,
    8164                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8165                 :            : }
    8166                 :            : 
    8167                 :            : static int
    8168                 :          0 : test_zuc256_hash_verify_4b_tag_test_case_3(void)
    8169                 :            : {
    8170                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
    8171                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8172                 :            : }
    8173                 :            : 
    8174                 :            : static int
    8175                 :          0 : test_zuc256_hash_verify_8b_tag_test_case_1(void)
    8176                 :            : {
    8177                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
    8178                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8179                 :            : }
    8180                 :            : 
    8181                 :            : static int
    8182                 :          0 : test_zuc256_hash_verify_16b_tag_test_case_1(void)
    8183                 :            : {
    8184                 :          0 :         return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
    8185                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
    8186                 :            : }
    8187                 :            : 
    8188                 :            : static int
    8189                 :          0 : test_zuc256_cipher_auth_4b_tag_test_case_1(void)
    8190                 :            : {
    8191                 :          0 :         return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
    8192                 :            : }
    8193                 :            : 
    8194                 :            : static int
    8195                 :          0 : test_zuc256_cipher_auth_4b_tag_test_case_2(void)
    8196                 :            : {
    8197                 :          0 :         return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
    8198                 :            : }
    8199                 :            : 
    8200                 :            : static int
    8201                 :          0 : test_zuc256_cipher_auth_8b_tag_test_case_1(void)
    8202                 :            : {
    8203                 :          0 :         return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
    8204                 :            : }
    8205                 :            : 
    8206                 :            : static int
    8207                 :          0 : test_zuc256_cipher_auth_16b_tag_test_case_1(void)
    8208                 :            : {
    8209                 :          0 :         return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
    8210                 :            : }
    8211                 :            : 
    8212                 :            : static int
    8213                 :          0 : test_zuc256_auth_cipher_4b_tag_test_case_1(void)
    8214                 :            : {
    8215                 :          0 :         return test_zuc_auth_cipher(
    8216                 :            :                 &zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
    8217                 :            : }
    8218                 :            : 
    8219                 :            : static int
    8220                 :          0 : test_zuc256_auth_cipher_4b_tag_test_case_2(void)
    8221                 :            : {
    8222                 :          0 :         return test_zuc_auth_cipher(
    8223                 :            :                 &zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
    8224                 :            : }
    8225                 :            : 
    8226                 :            : static int
    8227                 :          0 : test_zuc256_auth_cipher_8b_tag_test_case_1(void)
    8228                 :            : {
    8229                 :          0 :         return test_zuc_auth_cipher(
    8230                 :            :                 &zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
    8231                 :            : }
    8232                 :            : 
    8233                 :            : static int
    8234                 :          0 : test_zuc256_auth_cipher_16b_tag_test_case_1(void)
    8235                 :            : {
    8236                 :          0 :         return test_zuc_auth_cipher(
    8237                 :            :                 &zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
    8238                 :            : }
    8239                 :            : 
    8240                 :            : static int
    8241                 :          0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
    8242                 :            : {
    8243                 :          0 :         return test_zuc_auth_cipher(
    8244                 :            :                 &zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
    8245                 :            : }
    8246                 :            : 
    8247                 :            : static int
    8248                 :          0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
    8249                 :            : {
    8250                 :          0 :         return test_zuc_auth_cipher(
    8251                 :            :                 &zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
    8252                 :            : }
    8253                 :            : 
    8254                 :            : static int
    8255                 :          0 : test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
    8256                 :            : {
    8257                 :          0 :         return test_zuc_auth_cipher(
    8258                 :            :                 &zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
    8259                 :            : }
    8260                 :            : 
    8261                 :            : static int
    8262                 :          0 : test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
    8263                 :            : {
    8264                 :          0 :         return test_zuc_auth_cipher(
    8265                 :            :                 &zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
    8266                 :            : }
    8267                 :            : 
    8268                 :            : static int
    8269                 :         50 : test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
    8270                 :            : {
    8271                 :         50 :         uint8_t dev_id = testsuite_params.valid_devs[0];
    8272                 :            : 
    8273                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    8274                 :            : 
    8275                 :            :         /* Check if device supports particular cipher algorithm */
    8276                 :         50 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    8277                 :         50 :         cap_idx.algo.cipher = tdata->cipher_algo;
    8278         [ +  + ]:         50 :         if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
    8279                 :            :                 return TEST_SKIPPED;
    8280                 :            : 
    8281                 :            :         /* Check if device supports particular hash algorithm */
    8282                 :         24 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    8283                 :         24 :         cap_idx.algo.auth = tdata->auth_algo;
    8284         [ +  + ]:         24 :         if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
    8285                 :         12 :                 return TEST_SKIPPED;
    8286                 :            : 
    8287                 :            :         return 0;
    8288                 :            : }
    8289                 :            : 
    8290                 :            : static int
    8291                 :         44 : test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
    8292                 :            :         uint8_t op_mode, uint8_t verify)
    8293                 :            : {
    8294                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    8295                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    8296                 :            : 
    8297                 :            :         int retval;
    8298                 :            : 
    8299                 :            :         uint8_t *plaintext = NULL, *ciphertext = NULL;
    8300                 :            :         unsigned int plaintext_pad_len;
    8301                 :            :         unsigned int plaintext_len;
    8302                 :            :         unsigned int ciphertext_pad_len;
    8303                 :            :         unsigned int ciphertext_len;
    8304                 :            :         unsigned int digest_offset;
    8305                 :            : 
    8306                 :            :         struct rte_cryptodev_info dev_info;
    8307                 :            :         struct rte_crypto_op *op;
    8308                 :            : 
    8309                 :            :         /* Check if device supports particular algorithms separately */
    8310         [ +  + ]:         44 :         if (test_mixed_check_if_unsupported(tdata))
    8311                 :            :                 return TEST_SKIPPED;
    8312         [ +  - ]:          8 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    8313                 :            :                 return TEST_SKIPPED;
    8314                 :            : 
    8315         [ +  - ]:          8 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    8316                 :            :                 return TEST_SKIPPED;
    8317                 :            : 
    8318                 :          8 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    8319                 :            : 
    8320                 :          8 :         uint64_t feat_flags = dev_info.feature_flags;
    8321                 :            : 
    8322         [ +  - ]:          8 :         if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    8323                 :            :                 printf("Device doesn't support digest encrypted.\n");
    8324                 :          8 :                 return TEST_SKIPPED;
    8325                 :            :         }
    8326                 :            : 
    8327                 :            :         /* Create the session */
    8328         [ #  # ]:          0 :         if (verify)
    8329                 :          0 :                 retval = create_wireless_algo_cipher_auth_session(
    8330                 :          0 :                                 ts_params->valid_devs[0],
    8331                 :            :                                 RTE_CRYPTO_CIPHER_OP_DECRYPT,
    8332                 :            :                                 RTE_CRYPTO_AUTH_OP_VERIFY,
    8333                 :          0 :                                 tdata->auth_algo,
    8334                 :          0 :                                 tdata->cipher_algo,
    8335                 :          0 :                                 tdata->auth_key.data, tdata->auth_key.len,
    8336                 :          0 :                                 tdata->cipher_key.data, tdata->cipher_key.len,
    8337                 :          0 :                                 tdata->auth_iv.len, tdata->digest_enc.len,
    8338                 :          0 :                                 tdata->cipher_iv.len);
    8339                 :            :         else
    8340                 :          0 :                 retval = create_wireless_algo_auth_cipher_session(
    8341                 :          0 :                                 ts_params->valid_devs[0],
    8342                 :            :                                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    8343                 :            :                                 RTE_CRYPTO_AUTH_OP_GENERATE,
    8344                 :          0 :                                 tdata->auth_algo,
    8345                 :          0 :                                 tdata->cipher_algo,
    8346                 :          0 :                                 tdata->auth_key.data, tdata->auth_key.len,
    8347                 :          0 :                                 tdata->cipher_key.data, tdata->cipher_key.len,
    8348                 :          0 :                                 tdata->auth_iv.len, tdata->digest_enc.len,
    8349                 :          0 :                                 tdata->cipher_iv.len);
    8350         [ #  # ]:          0 :         if (retval != 0)
    8351                 :            :                 return retval;
    8352                 :            : 
    8353                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    8354         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    8355                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    8356                 :            : 
    8357                 :            :         /* clear mbuf payload */
    8358         [ #  # ]:          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    8359         [ #  # ]:          0 :                 rte_pktmbuf_tailroom(ut_params->ibuf));
    8360         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE) {
    8361                 :            : 
    8362                 :          0 :                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
    8363                 :          0 :                                 rte_pktmbuf_tailroom(ut_params->obuf));
    8364                 :            :         }
    8365                 :            : 
    8366         [ #  # ]:          0 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
    8367         [ #  # ]:          0 :         plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
    8368                 :          0 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    8369                 :          0 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    8370                 :            : 
    8371         [ #  # ]:          0 :         if (verify) {
    8372                 :          0 :                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    8373                 :            :                                 ciphertext_pad_len);
    8374                 :          0 :                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
    8375                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    8376                 :            :                                 ciphertext_len);
    8377                 :            :         } else {
    8378                 :            :                 /* make sure enough space to cover partial digest verify case */
    8379                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    8380                 :            :                                 ciphertext_pad_len);
    8381                 :          0 :                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
    8382                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
    8383                 :            :         }
    8384                 :            : 
    8385         [ #  # ]:          0 :         if (op_mode == OUT_OF_PLACE)
    8386                 :          0 :                 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
    8387                 :            : 
    8388                 :            :         /* Create the operation */
    8389                 :          0 :         retval = create_wireless_algo_auth_cipher_operation(
    8390                 :          0 :                         tdata->digest_enc.data, tdata->digest_enc.len,
    8391                 :          0 :                         tdata->cipher_iv.data, tdata->cipher_iv.len,
    8392                 :          0 :                         tdata->auth_iv.data, tdata->auth_iv.len,
    8393                 :          0 :                         (tdata->digest_enc.offset == 0 ?
    8394                 :            :                                 plaintext_pad_len
    8395                 :            :                                 : tdata->digest_enc.offset),
    8396                 :          0 :                         tdata->validCipherLen.len_bits,
    8397                 :          0 :                         tdata->cipher.offset_bits,
    8398                 :          0 :                         tdata->validAuthLen.len_bits,
    8399         [ #  # ]:          0 :                         tdata->auth.offset_bits,
    8400                 :            :                         op_mode, 0, verify);
    8401                 :            : 
    8402         [ #  # ]:          0 :         if (retval < 0)
    8403                 :            :                 return retval;
    8404                 :            : 
    8405                 :          0 :         op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
    8406                 :            : 
    8407                 :            :         /* Check if the op failed because the device doesn't */
    8408                 :            :         /* support this particular combination of algorithms */
    8409   [ #  #  #  # ]:          0 :         if (op == NULL && ut_params->op->status ==
    8410                 :            :                         RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
    8411                 :            :                 printf("Device doesn't support this mixed combination. "
    8412                 :            :                                 "Test Skipped.\n");
    8413                 :          0 :                 return TEST_SKIPPED;
    8414                 :            :         }
    8415                 :          0 :         ut_params->op = op;
    8416                 :            : 
    8417         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    8418                 :            : 
    8419                 :          0 :         ut_params->obuf = (op_mode == IN_PLACE ?
    8420         [ #  # ]:          0 :                         ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    8421                 :            : 
    8422         [ #  # ]:          0 :         if (verify) {
    8423         [ #  # ]:          0 :                 if (ut_params->obuf)
    8424                 :          0 :                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
    8425                 :            :                                                         uint8_t *);
    8426                 :            :                 else
    8427                 :          0 :                         plaintext = ciphertext +
    8428                 :          0 :                                         (tdata->cipher.offset_bits >> 3);
    8429                 :            : 
    8430                 :          0 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    8431                 :          0 :                                 tdata->plaintext.len_bits >> 3);
    8432                 :          0 :                 debug_hexdump(stdout, "plaintext expected:",
    8433                 :          0 :                                 tdata->plaintext.data,
    8434                 :          0 :                                 tdata->plaintext.len_bits >> 3);
    8435                 :            :         } else {
    8436         [ #  # ]:          0 :                 if (ut_params->obuf)
    8437                 :          0 :                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
    8438                 :            :                                         uint8_t *);
    8439                 :            :                 else
    8440                 :            :                         ciphertext = plaintext;
    8441                 :            : 
    8442                 :          0 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    8443                 :            :                                 ciphertext_len);
    8444                 :          0 :                 debug_hexdump(stdout, "ciphertext expected:",
    8445                 :          0 :                                 tdata->ciphertext.data,
    8446                 :          0 :                                 tdata->ciphertext.len_bits >> 3);
    8447                 :            : 
    8448         [ #  # ]:          0 :                 if (tdata->digest_enc.offset == 0)
    8449                 :            :                         digest_offset = plaintext_pad_len;
    8450                 :            :                 else
    8451                 :            :                         digest_offset = tdata->digest_enc.offset;
    8452                 :            : 
    8453                 :          0 :                 ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
    8454                 :            :                                             uint8_t *, digest_offset);
    8455                 :            : 
    8456                 :          0 :                 debug_hexdump(stdout, "digest:", ut_params->digest,
    8457                 :          0 :                                 tdata->digest_enc.len);
    8458                 :          0 :                 debug_hexdump(stdout, "digest expected:",
    8459                 :            :                                 tdata->digest_enc.data,
    8460                 :          0 :                                 tdata->digest_enc.len);
    8461                 :            :         }
    8462                 :            : 
    8463         [ #  # ]:          0 :         if (!verify) {
    8464         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    8465                 :            :                                 ut_params->digest,
    8466                 :            :                                 tdata->digest_enc.data,
    8467                 :            :                                 tdata->digest_enc.len,
    8468                 :            :                                 "Generated auth tag not as expected");
    8469                 :            :         }
    8470                 :            : 
    8471         [ #  # ]:          0 :         if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
    8472         [ #  # ]:          0 :                 if (verify) {
    8473   [ #  #  #  #  :          0 :                         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    8474                 :            :                                         plaintext,
    8475                 :            :                                         tdata->plaintext.data,
    8476                 :            :                                         tdata->plaintext.len_bits >> 3,
    8477                 :            :                                         "Plaintext data not as expected");
    8478                 :            :                 } else {
    8479   [ #  #  #  #  :          0 :                         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   #  # ]
    8480                 :            :                                         ciphertext,
    8481                 :            :                                         tdata->ciphertext.data,
    8482                 :            :                                         tdata->validDataLen.len_bits,
    8483                 :            :                                         "Ciphertext data not as expected");
    8484                 :            :                 }
    8485                 :            :         }
    8486                 :            : 
    8487         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    8488                 :            :                         "crypto op processing failed");
    8489                 :            : 
    8490                 :            :         return 0;
    8491                 :            : }
    8492                 :            : 
    8493                 :            : static int
    8494                 :          6 : test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
    8495                 :            :         uint8_t op_mode, uint8_t verify)
    8496                 :            : {
    8497                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    8498                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    8499                 :            : 
    8500                 :            :         int retval;
    8501                 :            : 
    8502                 :            :         const uint8_t *plaintext = NULL;
    8503                 :            :         const uint8_t *ciphertext = NULL;
    8504                 :            :         const uint8_t *digest = NULL;
    8505                 :            :         unsigned int plaintext_pad_len;
    8506                 :            :         unsigned int plaintext_len;
    8507                 :            :         unsigned int ciphertext_pad_len;
    8508                 :            :         unsigned int ciphertext_len;
    8509                 :            :         uint8_t buffer[10000];
    8510                 :            :         uint8_t digest_buffer[10000];
    8511                 :            : 
    8512                 :            :         struct rte_cryptodev_info dev_info;
    8513                 :            :         struct rte_crypto_op *op;
    8514                 :            : 
    8515                 :            :         /* Check if device supports particular algorithms */
    8516         [ +  + ]:          6 :         if (test_mixed_check_if_unsupported(tdata))
    8517                 :            :                 return TEST_SKIPPED;
    8518         [ +  - ]:          4 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
    8519                 :            :                 return TEST_SKIPPED;
    8520                 :            : 
    8521                 :          4 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    8522                 :            : 
    8523                 :          4 :         uint64_t feat_flags = dev_info.feature_flags;
    8524                 :            : 
    8525         [ +  + ]:          4 :         if (op_mode == IN_PLACE) {
    8526         [ -  + ]:          2 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
    8527                 :            :                         printf("Device doesn't support in-place scatter-gather "
    8528                 :            :                                         "in both input and output mbufs.\n");
    8529                 :          0 :                         return TEST_SKIPPED;
    8530                 :            :                 }
    8531                 :            :         } else {
    8532         [ +  - ]:          2 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
    8533                 :            :                         printf("Device doesn't support out-of-place scatter-gather "
    8534                 :            :                                         "in both input and output mbufs.\n");
    8535                 :          2 :                         return TEST_SKIPPED;
    8536                 :            :                 }
    8537         [ #  # ]:          0 :                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
    8538                 :            :                         printf("Device doesn't support digest encrypted.\n");
    8539                 :          0 :                         return TEST_SKIPPED;
    8540                 :            :                 }
    8541                 :            :         }
    8542                 :            : 
    8543         [ +  - ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    8544                 :            :                 return TEST_SKIPPED;
    8545                 :            : 
    8546                 :            :         /* Create the session */
    8547         [ +  + ]:          2 :         if (verify)
    8548                 :          1 :                 retval = create_wireless_algo_cipher_auth_session(
    8549                 :          1 :                                 ts_params->valid_devs[0],
    8550                 :            :                                 RTE_CRYPTO_CIPHER_OP_DECRYPT,
    8551                 :            :                                 RTE_CRYPTO_AUTH_OP_VERIFY,
    8552                 :          1 :                                 tdata->auth_algo,
    8553                 :          1 :                                 tdata->cipher_algo,
    8554                 :          1 :                                 tdata->auth_key.data, tdata->auth_key.len,
    8555                 :          1 :                                 tdata->cipher_key.data, tdata->cipher_key.len,
    8556                 :          1 :                                 tdata->auth_iv.len, tdata->digest_enc.len,
    8557                 :          1 :                                 tdata->cipher_iv.len);
    8558                 :            :         else
    8559                 :          1 :                 retval = create_wireless_algo_auth_cipher_session(
    8560                 :          1 :                                 ts_params->valid_devs[0],
    8561                 :            :                                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
    8562                 :            :                                 RTE_CRYPTO_AUTH_OP_GENERATE,
    8563                 :          1 :                                 tdata->auth_algo,
    8564                 :          1 :                                 tdata->cipher_algo,
    8565                 :          1 :                                 tdata->auth_key.data, tdata->auth_key.len,
    8566                 :          1 :                                 tdata->cipher_key.data, tdata->cipher_key.len,
    8567                 :          1 :                                 tdata->auth_iv.len, tdata->digest_enc.len,
    8568                 :          1 :                                 tdata->cipher_iv.len);
    8569         [ +  - ]:          2 :         if (retval != 0)
    8570                 :            :                 return retval;
    8571                 :            : 
    8572         [ -  + ]:          2 :         ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
    8573         [ -  + ]:          2 :         plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
    8574                 :          2 :         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
    8575                 :          2 :         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
    8576                 :            : 
    8577                 :          2 :         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
    8578                 :            :                         ciphertext_pad_len, 15, 0);
    8579         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
    8580                 :            :                         "Failed to allocate input buffer in mempool");
    8581                 :            : 
    8582         [ -  + ]:          2 :         if (op_mode == OUT_OF_PLACE) {
    8583                 :          0 :                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
    8584                 :            :                                 plaintext_pad_len, 15, 0);
    8585         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
    8586                 :            :                                 "Failed to allocate output buffer in mempool");
    8587                 :            :         }
    8588                 :            : 
    8589         [ +  + ]:          2 :         if (verify) {
    8590                 :          1 :                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
    8591                 :          1 :                         tdata->ciphertext.data);
    8592         [ -  + ]:          1 :                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    8593                 :            :                                         ciphertext_len, buffer);
    8594                 :          1 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    8595                 :            :                         ciphertext_len);
    8596                 :            :         } else {
    8597                 :          1 :                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
    8598                 :          1 :                         tdata->plaintext.data);
    8599         [ -  + ]:          1 :                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    8600                 :            :                                         plaintext_len, buffer);
    8601                 :          1 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    8602                 :            :                         plaintext_len);
    8603                 :            :         }
    8604                 :            :         memset(buffer, 0, sizeof(buffer));
    8605                 :            : 
    8606                 :            :         /* Create the operation */
    8607                 :          4 :         retval = create_wireless_algo_auth_cipher_operation(
    8608                 :          2 :                         tdata->digest_enc.data, tdata->digest_enc.len,
    8609                 :          2 :                         tdata->cipher_iv.data, tdata->cipher_iv.len,
    8610                 :          2 :                         tdata->auth_iv.data, tdata->auth_iv.len,
    8611                 :          2 :                         (tdata->digest_enc.offset == 0 ?
    8612                 :            :                                 plaintext_pad_len
    8613                 :            :                                 : tdata->digest_enc.offset),
    8614                 :          2 :                         tdata->validCipherLen.len_bits,
    8615                 :          2 :                         tdata->cipher.offset_bits,
    8616                 :          2 :                         tdata->validAuthLen.len_bits,
    8617         [ +  - ]:          2 :                         tdata->auth.offset_bits,
    8618                 :            :                         op_mode, 1, verify);
    8619                 :            : 
    8620         [ +  - ]:          2 :         if (retval < 0)
    8621                 :            :                 return retval;
    8622                 :            : 
    8623                 :          2 :         op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
    8624                 :            : 
    8625                 :            :         /* Check if the op failed because the device doesn't */
    8626                 :            :         /* support this particular combination of algorithms */
    8627   [ -  +  -  - ]:          2 :         if (op == NULL && ut_params->op->status ==
    8628                 :            :                         RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
    8629                 :            :                 printf("Device doesn't support this mixed combination. "
    8630                 :            :                                 "Test Skipped.\n");
    8631                 :          0 :                 return TEST_SKIPPED;
    8632                 :            :         }
    8633                 :          2 :         ut_params->op = op;
    8634                 :            : 
    8635         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
    8636                 :            : 
    8637                 :          2 :         ut_params->obuf = (op_mode == IN_PLACE ?
    8638         [ +  - ]:          2 :                         ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
    8639                 :            : 
    8640         [ +  + ]:          2 :         if (verify) {
    8641         [ +  - ]:          1 :                 if (ut_params->obuf)
    8642                 :            :                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
    8643                 :            :                                         plaintext_len, buffer);
    8644                 :            :                 else
    8645         [ #  # ]:          0 :                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
    8646                 :            :                                         plaintext_len, buffer);
    8647                 :            : 
    8648                 :          1 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    8649                 :          1 :                                 (tdata->plaintext.len_bits >> 3) -
    8650                 :          1 :                                 tdata->digest_enc.len);
    8651                 :          1 :                 debug_hexdump(stdout, "plaintext expected:",
    8652                 :          1 :                                 tdata->plaintext.data,
    8653                 :          1 :                                 (tdata->plaintext.len_bits >> 3) -
    8654                 :          1 :                                 tdata->digest_enc.len);
    8655                 :            :         } else {
    8656         [ +  - ]:          1 :                 if (ut_params->obuf)
    8657                 :            :                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
    8658                 :            :                                         ciphertext_len, buffer);
    8659                 :            :                 else
    8660         [ #  # ]:          0 :                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
    8661                 :            :                                         ciphertext_len, buffer);
    8662                 :            : 
    8663                 :          1 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    8664                 :            :                         ciphertext_len);
    8665                 :          1 :                 debug_hexdump(stdout, "ciphertext expected:",
    8666                 :          1 :                         tdata->ciphertext.data,
    8667                 :          1 :                         tdata->ciphertext.len_bits >> 3);
    8668                 :            : 
    8669         [ +  - ]:          1 :                 if (ut_params->obuf)
    8670                 :          1 :                         digest = rte_pktmbuf_read(ut_params->obuf,
    8671                 :          1 :                                         (tdata->digest_enc.offset == 0 ?
    8672                 :            :                                                 plaintext_pad_len :
    8673                 :            :                                                 tdata->digest_enc.offset),
    8674         [ +  - ]:          1 :                                         tdata->digest_enc.len, digest_buffer);
    8675                 :            :                 else
    8676         [ #  # ]:          0 :                         digest = rte_pktmbuf_read(ut_params->ibuf,
    8677                 :          0 :                                         (tdata->digest_enc.offset == 0 ?
    8678                 :            :                                                 plaintext_pad_len :
    8679                 :            :                                                 tdata->digest_enc.offset),
    8680         [ #  # ]:          0 :                                         tdata->digest_enc.len, digest_buffer);
    8681                 :            : 
    8682                 :          1 :                 debug_hexdump(stdout, "digest:", digest,
    8683                 :          1 :                                 tdata->digest_enc.len);
    8684                 :          1 :                 debug_hexdump(stdout, "digest expected:",
    8685                 :          1 :                                 tdata->digest_enc.data, tdata->digest_enc.len);
    8686                 :            :         }
    8687                 :            : 
    8688         [ +  + ]:          2 :         if (!verify) {
    8689         [ -  + ]:          1 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
    8690                 :            :                                 digest,
    8691                 :            :                                 tdata->digest_enc.data,
    8692                 :            :                                 tdata->digest_enc.len,
    8693                 :            :                                 "Generated auth tag not as expected");
    8694                 :            :         }
    8695                 :            : 
    8696         [ +  - ]:          2 :         if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
    8697         [ +  + ]:          2 :                 if (verify) {
    8698   [ -  +  +  -  :          1 :                         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   -  + ]
    8699                 :            :                                         plaintext,
    8700                 :            :                                         tdata->plaintext.data,
    8701                 :            :                                         tdata->plaintext.len_bits >> 3,
    8702                 :            :                                         "Plaintext data not as expected");
    8703                 :            :                 } else {
    8704   [ -  +  -  +  :          1 :                         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
                   -  - ]
    8705                 :            :                                         ciphertext,
    8706                 :            :                                         tdata->ciphertext.data,
    8707                 :            :                                         tdata->validDataLen.len_bits,
    8708                 :            :                                         "Ciphertext data not as expected");
    8709                 :            :                 }
    8710                 :            :         }
    8711                 :            : 
    8712         [ -  + ]:          2 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    8713                 :            :                         "crypto op processing failed");
    8714                 :            : 
    8715                 :            :         return 0;
    8716                 :            : }
    8717                 :            : 
    8718                 :            : /** AUTH AES CMAC + CIPHER AES CTR */
    8719                 :            : 
    8720                 :            : static int
    8721                 :          1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
    8722                 :            : {
    8723                 :          1 :         return test_mixed_auth_cipher(
    8724                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
    8725                 :            : }
    8726                 :            : 
    8727                 :            : static int
    8728                 :          1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
    8729                 :            : {
    8730                 :          1 :         return test_mixed_auth_cipher(
    8731                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
    8732                 :            : }
    8733                 :            : 
    8734                 :            : static int
    8735                 :          1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
    8736                 :            : {
    8737                 :          1 :         return test_mixed_auth_cipher_sgl(
    8738                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
    8739                 :            : }
    8740                 :            : 
    8741                 :            : static int
    8742                 :          1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
    8743                 :            : {
    8744                 :          1 :         return test_mixed_auth_cipher_sgl(
    8745                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
    8746                 :            : }
    8747                 :            : 
    8748                 :            : static int
    8749                 :          1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
    8750                 :            : {
    8751                 :          1 :         return test_mixed_auth_cipher(
    8752                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
    8753                 :            : }
    8754                 :            : 
    8755                 :            : static int
    8756                 :          1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
    8757                 :            : {
    8758                 :          1 :         return test_mixed_auth_cipher(
    8759                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
    8760                 :            : }
    8761                 :            : 
    8762                 :            : static int
    8763                 :          1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
    8764                 :            : {
    8765                 :          1 :         return test_mixed_auth_cipher(
    8766                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
    8767                 :            : }
    8768                 :            : 
    8769                 :            : static int
    8770                 :          1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
    8771                 :            : {
    8772                 :          1 :         return test_mixed_auth_cipher(
    8773                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
    8774                 :            : }
    8775                 :            : 
    8776                 :            : static int
    8777                 :          1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
    8778                 :            : {
    8779                 :          1 :         return test_mixed_auth_cipher(
    8780                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
    8781                 :            : }
    8782                 :            : 
    8783                 :            : static int
    8784                 :          1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
    8785                 :            : {
    8786                 :          1 :         return test_mixed_auth_cipher_sgl(
    8787                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
    8788                 :            : }
    8789                 :            : 
    8790                 :            : static int
    8791                 :          1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
    8792                 :            : {
    8793                 :          1 :         return test_mixed_auth_cipher_sgl(
    8794                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
    8795                 :            : }
    8796                 :            : 
    8797                 :            : static int
    8798                 :          1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
    8799                 :            : {
    8800                 :          1 :         return test_mixed_auth_cipher(
    8801                 :            :                 &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
    8802                 :            : }
    8803                 :            : 
    8804                 :            : /** MIXED AUTH + CIPHER */
    8805                 :            : 
    8806                 :            : static int
    8807                 :          1 : test_auth_zuc_cipher_snow_test_case_1(void)
    8808                 :            : {
    8809                 :          1 :         return test_mixed_auth_cipher(
    8810                 :            :                 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
    8811                 :            : }
    8812                 :            : 
    8813                 :            : static int
    8814                 :          1 : test_verify_auth_zuc_cipher_snow_test_case_1(void)
    8815                 :            : {
    8816                 :          1 :         return test_mixed_auth_cipher(
    8817                 :            :                 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
    8818                 :            : }
    8819                 :            : 
    8820                 :            : static int
    8821                 :          1 : test_auth_zuc_cipher_snow_test_case_1_inplace(void)
    8822                 :            : {
    8823                 :          1 :         return test_mixed_auth_cipher(
    8824                 :            :                 &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
    8825                 :            : }
    8826                 :            : 
    8827                 :            : static int
    8828                 :          1 : test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
    8829                 :            : {
    8830                 :          1 :         return test_mixed_auth_cipher(
    8831                 :            :                 &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
    8832                 :            : }
    8833                 :            : 
    8834                 :            : 
    8835                 :            : static int
    8836                 :          1 : test_auth_aes_cmac_cipher_snow_test_case_1(void)
    8837                 :            : {
    8838                 :          1 :         return test_mixed_auth_cipher(
    8839                 :            :                 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
    8840                 :            : }
    8841                 :            : 
    8842                 :            : static int
    8843                 :          1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
    8844                 :            : {
    8845                 :          1 :         return test_mixed_auth_cipher(
    8846                 :            :                 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
    8847                 :            : }
    8848                 :            : 
    8849                 :            : static int
    8850                 :          1 : test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
    8851                 :            : {
    8852                 :          1 :         return test_mixed_auth_cipher(
    8853                 :            :                 &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
    8854                 :            : }
    8855                 :            : 
    8856                 :            : static int
    8857                 :          1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
    8858                 :            : {
    8859                 :          1 :         return test_mixed_auth_cipher(
    8860                 :            :                 &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
    8861                 :            : }
    8862                 :            : 
    8863                 :            : static int
    8864                 :          1 : test_auth_zuc_cipher_aes_ctr_test_case_1(void)
    8865                 :            : {
    8866                 :          1 :         return test_mixed_auth_cipher(
    8867                 :            :                 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
    8868                 :            : }
    8869                 :            : 
    8870                 :            : static int
    8871                 :          1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
    8872                 :            : {
    8873                 :          1 :         return test_mixed_auth_cipher(
    8874                 :            :                 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
    8875                 :            : }
    8876                 :            : 
    8877                 :            : static int
    8878                 :          1 : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
    8879                 :            : {
    8880                 :          1 :         return test_mixed_auth_cipher(
    8881                 :            :                 &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
    8882                 :            : }
    8883                 :            : 
    8884                 :            : static int
    8885                 :          1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
    8886                 :            : {
    8887                 :          1 :         return test_mixed_auth_cipher(
    8888                 :            :                 &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
    8889                 :            : }
    8890                 :            : 
    8891                 :            : static int
    8892                 :          1 : test_auth_snow_cipher_aes_ctr_test_case_1(void)
    8893                 :            : {
    8894                 :          1 :         return test_mixed_auth_cipher(
    8895                 :            :                 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
    8896                 :            : }
    8897                 :            : 
    8898                 :            : static int
    8899                 :          1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
    8900                 :            : {
    8901                 :          1 :         return test_mixed_auth_cipher(
    8902                 :            :                 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
    8903                 :            : }
    8904                 :            : 
    8905                 :            : static int
    8906                 :          1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
    8907                 :            : {
    8908                 :          1 :         return test_mixed_auth_cipher_sgl(
    8909                 :            :                 &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
    8910                 :            : }
    8911                 :            : 
    8912                 :            : static int
    8913                 :          1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
    8914                 :            : {
    8915                 :          1 :         return test_mixed_auth_cipher(
    8916                 :            :                 &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
    8917                 :            : }
    8918                 :            : 
    8919                 :            : static int
    8920                 :          1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
    8921                 :            : {
    8922                 :          1 :         return test_mixed_auth_cipher_sgl(
    8923                 :            :                 &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
    8924                 :            : }
    8925                 :            : 
    8926                 :            : static int
    8927                 :          1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
    8928                 :            : {
    8929                 :          1 :         return test_mixed_auth_cipher(
    8930                 :            :                 &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
    8931                 :            : }
    8932                 :            : 
    8933                 :            : static int
    8934                 :          1 : test_auth_snow_cipher_zuc_test_case_1(void)
    8935                 :            : {
    8936                 :          1 :         return test_mixed_auth_cipher(
    8937                 :            :                 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
    8938                 :            : }
    8939                 :            : 
    8940                 :            : static int
    8941                 :          1 : test_verify_auth_snow_cipher_zuc_test_case_1(void)
    8942                 :            : {
    8943                 :          1 :         return test_mixed_auth_cipher(
    8944                 :            :                 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
    8945                 :            : }
    8946                 :            : 
    8947                 :            : static int
    8948                 :          1 : test_auth_snow_cipher_zuc_test_case_1_inplace(void)
    8949                 :            : {
    8950                 :          1 :         return test_mixed_auth_cipher(
    8951                 :            :                 &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
    8952                 :            : }
    8953                 :            : 
    8954                 :            : static int
    8955                 :          1 : test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
    8956                 :            : {
    8957                 :          1 :         return test_mixed_auth_cipher(
    8958                 :            :                 &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
    8959                 :            : }
    8960                 :            : 
    8961                 :            : static int
    8962                 :          1 : test_auth_aes_cmac_cipher_zuc_test_case_1(void)
    8963                 :            : {
    8964                 :          1 :         return test_mixed_auth_cipher(
    8965                 :            :                 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
    8966                 :            : }
    8967                 :            : 
    8968                 :            : static int
    8969                 :          1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
    8970                 :            : {
    8971                 :          1 :         return test_mixed_auth_cipher(
    8972                 :            :                 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
    8973                 :            : }
    8974                 :            : static int
    8975                 :          1 : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
    8976                 :            : {
    8977                 :          1 :         return test_mixed_auth_cipher(
    8978                 :            :                 &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
    8979                 :            : }
    8980                 :            : 
    8981                 :            : static int
    8982                 :          1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
    8983                 :            : {
    8984                 :          1 :         return test_mixed_auth_cipher(
    8985                 :            :                 &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
    8986                 :            : }
    8987                 :            : 
    8988                 :            : static int
    8989                 :          1 : test_auth_null_cipher_snow_test_case_1(void)
    8990                 :            : {
    8991                 :          1 :         return test_mixed_auth_cipher(
    8992                 :            :                 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
    8993                 :            : }
    8994                 :            : 
    8995                 :            : static int
    8996                 :          1 : test_verify_auth_null_cipher_snow_test_case_1(void)
    8997                 :            : {
    8998                 :          1 :         return test_mixed_auth_cipher(
    8999                 :            :                 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
    9000                 :            : }
    9001                 :            : 
    9002                 :            : static int
    9003                 :          1 : test_auth_null_cipher_zuc_test_case_1(void)
    9004                 :            : {
    9005                 :          1 :         return test_mixed_auth_cipher(
    9006                 :            :                 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
    9007                 :            : }
    9008                 :            : 
    9009                 :            : static int
    9010                 :          1 : test_verify_auth_null_cipher_zuc_test_case_1(void)
    9011                 :            : {
    9012                 :          1 :         return test_mixed_auth_cipher(
    9013                 :            :                 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
    9014                 :            : }
    9015                 :            : 
    9016                 :            : static int
    9017                 :          1 : test_auth_snow_cipher_null_test_case_1(void)
    9018                 :            : {
    9019                 :          1 :         return test_mixed_auth_cipher(
    9020                 :            :                 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
    9021                 :            : }
    9022                 :            : 
    9023                 :            : static int
    9024                 :          1 : test_verify_auth_snow_cipher_null_test_case_1(void)
    9025                 :            : {
    9026                 :          1 :         return test_mixed_auth_cipher(
    9027                 :            :                 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
    9028                 :            : }
    9029                 :            : 
    9030                 :            : static int
    9031                 :          1 : test_auth_zuc_cipher_null_test_case_1(void)
    9032                 :            : {
    9033                 :          1 :         return test_mixed_auth_cipher(
    9034                 :            :                 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
    9035                 :            : }
    9036                 :            : 
    9037                 :            : static int
    9038                 :          1 : test_verify_auth_zuc_cipher_null_test_case_1(void)
    9039                 :            : {
    9040                 :          1 :         return test_mixed_auth_cipher(
    9041                 :            :                 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
    9042                 :            : }
    9043                 :            : 
    9044                 :            : static int
    9045                 :          1 : test_auth_null_cipher_aes_ctr_test_case_1(void)
    9046                 :            : {
    9047                 :          1 :         return test_mixed_auth_cipher(
    9048                 :            :                 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
    9049                 :            : }
    9050                 :            : 
    9051                 :            : static int
    9052                 :          1 : test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
    9053                 :            : {
    9054                 :          1 :         return test_mixed_auth_cipher(
    9055                 :            :                 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
    9056                 :            : }
    9057                 :            : 
    9058                 :            : static int
    9059                 :          1 : test_auth_aes_cmac_cipher_null_test_case_1(void)
    9060                 :            : {
    9061                 :          1 :         return test_mixed_auth_cipher(
    9062                 :            :                 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
    9063                 :            : }
    9064                 :            : 
    9065                 :            : static int
    9066                 :          1 : test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
    9067                 :            : {
    9068                 :          1 :         return test_mixed_auth_cipher(
    9069                 :            :                 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
    9070                 :            : }
    9071                 :            : 
    9072                 :            : /* ***** AEAD algorithm Tests ***** */
    9073                 :            : 
    9074                 :            : static int
    9075                 :         85 : create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
    9076                 :            :                 enum rte_crypto_aead_operation op,
    9077                 :            :                 const uint8_t *key, const uint8_t key_len,
    9078                 :            :                 const uint16_t aad_len, const uint8_t auth_len,
    9079                 :            :                 uint8_t iv_len)
    9080                 :         85 : {
    9081                 :         85 :         uint8_t aead_key[key_len];
    9082                 :            : 
    9083                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    9084                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    9085                 :            : 
    9086                 :            :         memcpy(aead_key, key, key_len);
    9087                 :            : 
    9088                 :            :         /* Setup AEAD Parameters */
    9089                 :         85 :         ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
    9090                 :         85 :         ut_params->aead_xform.next = NULL;
    9091                 :         85 :         ut_params->aead_xform.aead.algo = algo;
    9092                 :         85 :         ut_params->aead_xform.aead.op = op;
    9093                 :         85 :         ut_params->aead_xform.aead.key.data = aead_key;
    9094                 :         85 :         ut_params->aead_xform.aead.key.length = key_len;
    9095                 :         85 :         ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
    9096                 :         85 :         ut_params->aead_xform.aead.iv.length = iv_len;
    9097                 :         85 :         ut_params->aead_xform.aead.digest_length = auth_len;
    9098                 :         85 :         ut_params->aead_xform.aead.aad_length = aad_len;
    9099                 :            : 
    9100                 :         85 :         debug_hexdump(stdout, "key:", key, key_len);
    9101                 :            : 
    9102                 :            :         /* Create Crypto session*/
    9103                 :         85 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
    9104                 :            :                         &ut_params->aead_xform, ts_params->session_mpool);
    9105   [ -  +  -  - ]:         85 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
    9106                 :            :                 return TEST_SKIPPED;
    9107         [ -  + ]:         85 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
    9108                 :            :         return 0;
    9109                 :            : }
    9110                 :            : 
    9111                 :            : static int
    9112                 :          2 : create_aead_xform(struct rte_crypto_op *op,
    9113                 :            :                 enum rte_crypto_aead_algorithm algo,
    9114                 :            :                 enum rte_crypto_aead_operation aead_op,
    9115                 :            :                 uint8_t *key, const uint8_t key_len,
    9116                 :            :                 const uint8_t aad_len, const uint8_t auth_len,
    9117                 :            :                 uint8_t iv_len)
    9118                 :            : {
    9119         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
    9120                 :            :                         "failed to allocate space for crypto transform");
    9121                 :            : 
    9122                 :            :         struct rte_crypto_sym_op *sym_op = op->sym;
    9123                 :            : 
    9124                 :            :         /* Setup AEAD Parameters */
    9125                 :          2 :         sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
    9126                 :          2 :         sym_op->xform->next = NULL;
    9127                 :          2 :         sym_op->xform->aead.algo = algo;
    9128                 :          2 :         sym_op->xform->aead.op = aead_op;
    9129                 :          2 :         sym_op->xform->aead.key.data = key;
    9130                 :          2 :         sym_op->xform->aead.key.length = key_len;
    9131                 :          2 :         sym_op->xform->aead.iv.offset = IV_OFFSET;
    9132                 :          2 :         sym_op->xform->aead.iv.length = iv_len;
    9133                 :          2 :         sym_op->xform->aead.digest_length = auth_len;
    9134                 :          2 :         sym_op->xform->aead.aad_length = aad_len;
    9135                 :            : 
    9136                 :          2 :         debug_hexdump(stdout, "key:", key, key_len);
    9137                 :            : 
    9138                 :            :         return 0;
    9139                 :            : }
    9140                 :            : 
    9141                 :            : static int
    9142                 :         86 : create_aead_operation(enum rte_crypto_aead_operation op,
    9143                 :            :                 const struct aead_test_data *tdata)
    9144                 :            : {
    9145                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    9146                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    9147                 :            : 
    9148                 :            :         uint8_t *plaintext, *ciphertext;
    9149                 :            :         unsigned int aad_pad_len, plaintext_pad_len;
    9150                 :            : 
    9151                 :            :         /* Generate Crypto op data structure */
    9152                 :         86 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    9153                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    9154         [ -  + ]:         86 :         TEST_ASSERT_NOT_NULL(ut_params->op,
    9155                 :            :                         "Failed to allocate symmetric crypto operation struct");
    9156                 :            : 
    9157                 :            :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
    9158                 :            : 
    9159                 :            :         /* Append aad data */
    9160         [ +  + ]:         86 :         if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
    9161                 :         18 :                 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
    9162                 :         18 :                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    9163                 :            :                                 aad_pad_len);
    9164         [ -  + ]:         18 :                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
    9165                 :            :                                 "no room to append aad");
    9166                 :            : 
    9167                 :         18 :                 sym_op->aead.aad.phys_addr =
    9168                 :         18 :                                 rte_pktmbuf_iova(ut_params->ibuf);
    9169                 :            :                 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
    9170                 :         18 :                 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
    9171                 :         18 :                 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
    9172                 :         18 :                         tdata->aad.len);
    9173                 :            : 
    9174                 :            :                 /* Append IV at the end of the crypto operation*/
    9175                 :         18 :                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
    9176                 :            :                                 uint8_t *, IV_OFFSET);
    9177                 :            : 
    9178                 :            :                 /* Copy IV 1 byte after the IV pointer, according to the API */
    9179         [ -  + ]:         18 :                 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
    9180                 :         18 :                 debug_hexdump(stdout, "iv:", iv_ptr + 1,
    9181                 :         18 :                         tdata->iv.len);
    9182                 :            :         } else {
    9183                 :         68 :                 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
    9184                 :         68 :                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    9185                 :            :                                 aad_pad_len);
    9186         [ -  + ]:         68 :                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
    9187                 :            :                                 "no room to append aad");
    9188                 :            : 
    9189                 :         68 :                 sym_op->aead.aad.phys_addr =
    9190                 :         68 :                                 rte_pktmbuf_iova(ut_params->ibuf);
    9191                 :         68 :                 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
    9192                 :         68 :                 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
    9193                 :         68 :                         tdata->aad.len);
    9194                 :            : 
    9195                 :            :                 /* Append IV at the end of the crypto operation*/
    9196                 :         68 :                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
    9197                 :            :                                 uint8_t *, IV_OFFSET);
    9198                 :            : 
    9199         [ -  + ]:         68 :                 if (tdata->iv.len == 0) {
    9200         [ #  # ]:          0 :                         rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
    9201                 :          0 :                         debug_hexdump(stdout, "iv:", iv_ptr,
    9202                 :            :                                 AES_GCM_J0_LENGTH);
    9203                 :            :                 } else {
    9204         [ -  + ]:         68 :                         rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
    9205                 :         68 :                         debug_hexdump(stdout, "iv:", iv_ptr,
    9206                 :         68 :                                 tdata->iv.len);
    9207                 :            :                 }
    9208                 :            :         }
    9209                 :            : 
    9210                 :            :         /* Append plaintext/ciphertext */
    9211         [ +  + ]:         86 :         if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
    9212                 :         43 :                 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
    9213                 :         43 :                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    9214                 :            :                                 plaintext_pad_len);
    9215         [ -  + ]:         43 :                 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
    9216                 :            : 
    9217                 :         43 :                 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
    9218                 :         43 :                 debug_hexdump(stdout, "plaintext:", plaintext,
    9219                 :         43 :                                 tdata->plaintext.len);
    9220                 :            : 
    9221         [ +  + ]:         43 :                 if (ut_params->obuf) {
    9222                 :            :                         ciphertext = (uint8_t *)rte_pktmbuf_append(
    9223                 :            :                                         ut_params->obuf,
    9224                 :          1 :                                         plaintext_pad_len + aad_pad_len);
    9225         [ -  + ]:          1 :                         TEST_ASSERT_NOT_NULL(ciphertext,
    9226                 :            :                                         "no room to append ciphertext");
    9227                 :            : 
    9228                 :          1 :                         memset(ciphertext + aad_pad_len, 0,
    9229                 :          1 :                                         tdata->ciphertext.len);
    9230                 :            :                 }
    9231                 :            :         } else {
    9232                 :         43 :                 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
    9233                 :         43 :                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    9234                 :            :                                 plaintext_pad_len);
    9235         [ -  + ]:         43 :                 TEST_ASSERT_NOT_NULL(ciphertext,
    9236                 :            :                                 "no room to append ciphertext");
    9237                 :            : 
    9238                 :         43 :                 memcpy(ciphertext, tdata->ciphertext.data,
    9239                 :         43 :                                 tdata->ciphertext.len);
    9240                 :         43 :                 debug_hexdump(stdout, "ciphertext:", ciphertext,
    9241                 :         43 :                                 tdata->ciphertext.len);
    9242                 :            : 
    9243         [ +  + ]:         43 :                 if (ut_params->obuf) {
    9244                 :            :                         plaintext = (uint8_t *)rte_pktmbuf_append(
    9245                 :            :                                         ut_params->obuf,
    9246                 :          1 :                                         plaintext_pad_len + aad_pad_len);
    9247         [ -  + ]:          1 :                         TEST_ASSERT_NOT_NULL(plaintext,
    9248                 :            :                                         "no room to append plaintext");
    9249                 :            : 
    9250                 :          1 :                         memset(plaintext + aad_pad_len, 0,
    9251                 :          1 :                                         tdata->plaintext.len);
    9252                 :            :                 }
    9253                 :            :         }
    9254                 :            : 
    9255                 :            :         /* Append digest data */
    9256         [ +  + ]:         86 :         if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
    9257                 :         42 :                 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
    9258                 :         43 :                                 ut_params->obuf ? ut_params->obuf :
    9259                 :            :                                                 ut_params->ibuf,
    9260         [ +  + ]:         43 :                                                 tdata->auth_tag.len);
    9261         [ -  + ]:         43 :                 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
    9262                 :            :                                 "no room to append digest");
    9263         [ +  + ]:         43 :                 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
    9264         [ +  + ]:         43 :                 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
    9265                 :            :                                 ut_params->obuf ? ut_params->obuf :
    9266                 :            :                                                 ut_params->ibuf,
    9267                 :            :                                                 plaintext_pad_len +
    9268                 :            :                                                 aad_pad_len);
    9269                 :            :         } else {
    9270                 :         86 :                 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
    9271                 :         43 :                                 ut_params->ibuf, tdata->auth_tag.len);
    9272         [ -  + ]:         43 :                 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
    9273                 :            :                                 "no room to append digest");
    9274         [ -  + ]:         43 :                 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
    9275                 :            :                                 ut_params->ibuf,
    9276                 :            :                                 plaintext_pad_len + aad_pad_len);
    9277                 :            : 
    9278                 :         43 :                 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
    9279         [ -  + ]:         43 :                         tdata->auth_tag.len);
    9280                 :         43 :                 debug_hexdump(stdout, "digest:",
    9281                 :         43 :                         sym_op->aead.digest.data,
    9282                 :         43 :                         tdata->auth_tag.len);
    9283                 :            :         }
    9284                 :            : 
    9285                 :         86 :         sym_op->aead.data.length = tdata->plaintext.len;
    9286                 :         86 :         sym_op->aead.data.offset = aad_pad_len;
    9287                 :            : 
    9288                 :         86 :         return 0;
    9289                 :            : }
    9290                 :            : 
    9291                 :            : static int
    9292                 :         42 : test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
    9293                 :            : {
    9294                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    9295                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    9296                 :            : 
    9297                 :            :         int retval;
    9298                 :            :         uint8_t *ciphertext, *auth_tag;
    9299                 :            :         uint16_t plaintext_pad_len;
    9300                 :            :         uint32_t i;
    9301                 :            :         struct rte_cryptodev_info dev_info;
    9302                 :            : 
    9303                 :         42 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    9304                 :         42 :         uint64_t feat_flags = dev_info.feature_flags;
    9305                 :            : 
    9306         [ -  + ]:         42 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    9307         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    9308                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
    9309                 :          0 :                 return TEST_SKIPPED;
    9310                 :            :         }
    9311                 :            : 
    9312                 :            :         /* Verify the capabilities */
    9313                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
    9314                 :            :         const struct rte_cryptodev_symmetric_capability *capability;
    9315                 :         42 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
    9316                 :         42 :         cap_idx.algo.aead = tdata->algo;
    9317                 :         42 :         capability = rte_cryptodev_sym_capability_get(
    9318                 :         42 :                         ts_params->valid_devs[0], &cap_idx);
    9319         [ +  - ]:         42 :         if (capability == NULL)
    9320                 :            :                 return TEST_SKIPPED;
    9321         [ +  + ]:         42 :         if (rte_cryptodev_sym_capability_check_aead(
    9322                 :         42 :                         capability, tdata->key.len, tdata->auth_tag.len,
    9323                 :         42 :                         tdata->aad.len, tdata->iv.len))
    9324                 :            :                 return TEST_SKIPPED;
    9325                 :            : 
    9326                 :            :         /* Create AEAD session */
    9327                 :         41 :         retval = create_aead_session(ts_params->valid_devs[0],
    9328                 :         41 :                         tdata->algo,
    9329                 :            :                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
    9330                 :         41 :                         tdata->key.data, tdata->key.len,
    9331                 :         41 :                         tdata->aad.len, tdata->auth_tag.len,
    9332                 :         41 :                         tdata->iv.len);
    9333         [ +  - ]:         41 :         if (retval != TEST_SUCCESS)
    9334                 :            :                 return retval;
    9335                 :            : 
    9336         [ +  + ]:         41 :         if (tdata->aad.len > MBUF_SIZE) {
    9337         [ -  + ]:          2 :                 if (use_ext_mbuf) {
    9338                 :          0 :                         ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
    9339                 :            :                                                           AEAD_TEXT_MAX_LENGTH,
    9340                 :            :                                                           1 /* nb_segs */,
    9341                 :            :                                                           NULL);
    9342                 :            :                 } else {
    9343                 :          2 :                         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
    9344                 :            :                 }
    9345                 :            :                 /* Populate full size of add data */
    9346         [ +  + ]:       4088 :                 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
    9347                 :       4086 :                         memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
    9348                 :            :         } else {
    9349         [ +  + ]:         39 :                 if (use_ext_mbuf) {
    9350                 :          1 :                         ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
    9351                 :            :                                                           AEAD_TEXT_MAX_LENGTH,
    9352                 :            :                                                           1 /* nb_segs */,
    9353                 :            :                                                           NULL);
    9354                 :            :                 } else {
    9355                 :         38 :                         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9356                 :            :                 }
    9357                 :            :         }
    9358                 :            : 
    9359                 :            :         /* clear mbuf payload */
    9360                 :         41 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    9361                 :         41 :                         rte_pktmbuf_tailroom(ut_params->ibuf));
    9362                 :            : 
    9363                 :            :         /* Create AEAD operation */
    9364                 :         41 :         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
    9365         [ +  - ]:         41 :         if (retval < 0)
    9366                 :            :                 return retval;
    9367                 :            : 
    9368         [ +  - ]:         41 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
    9369                 :            : 
    9370                 :         41 :         ut_params->op->sym->m_src = ut_params->ibuf;
    9371                 :            : 
    9372                 :            :         /* Process crypto operation */
    9373         [ -  + ]:         41 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
    9374                 :          0 :                 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
    9375         [ -  + ]:         41 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    9376                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
    9377                 :            :                                                0);
    9378         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
    9379                 :            :                         return retval;
    9380                 :            :         } else
    9381         [ -  + ]:         41 :                 TEST_ASSERT_NOT_NULL(
    9382                 :            :                         process_crypto_request(ts_params->valid_devs[0],
    9383                 :            :                         ut_params->op), "failed to process sym crypto op");
    9384                 :            : 
    9385         [ -  + ]:         41 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
    9386                 :            :                         "crypto op processing failed");
    9387                 :            : 
    9388                 :         41 :         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
    9389                 :            : 
    9390         [ -  + ]:         41 :         if (ut_params->op->sym->m_dst) {
    9391                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
    9392                 :            :                                 uint8_t *);
    9393                 :          0 :                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
    9394                 :            :                                 uint8_t *, plaintext_pad_len);
    9395                 :            :         } else {
    9396                 :         41 :                 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
    9397                 :            :                                 uint8_t *,
    9398                 :            :                                 ut_params->op->sym->cipher.data.offset);
    9399                 :         41 :                 auth_tag = ciphertext + plaintext_pad_len;
    9400                 :            :         }
    9401                 :            : 
    9402                 :         41 :         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
    9403                 :         41 :         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
    9404                 :            : 
    9405                 :            :         /* Validate obuf */
    9406         [ +  + ]:         44 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    9407                 :            :                         ciphertext,
    9408                 :            :                         tdata->ciphertext.data,
    9409                 :            :                         tdata->ciphertext.len,
    9410                 :            :                         "Ciphertext data not as expected");
    9411                 :            : 
    9412         [ +  + ]:         41 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
    9413                 :            :                         auth_tag,
    9414                 :            :                         tdata->auth_tag.data,
    9415                 :            :                         tdata->auth_tag.len,
    9416                 :            :                         "Generated auth tag not as expected");
    9417                 :            : 
    9418                 :            :         return 0;
    9419                 :            : 
    9420                 :            : }
    9421                 :            : 
    9422                 :            : static int
    9423                 :            : test_authenticated_encryption(const struct aead_test_data *tdata)
    9424                 :            : {
    9425                 :         41 :         return test_authenticated_encryption_helper(tdata, false);
    9426                 :            : }
    9427                 :            : 
    9428                 :            : #ifdef RTE_LIB_SECURITY
    9429                 :            : static int
    9430                 :          0 : security_proto_supported(enum rte_security_session_action_type action,
    9431                 :            :         enum rte_security_session_protocol proto)
    9432                 :            : {
    9433                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    9434                 :            : 
    9435                 :            :         const struct rte_security_capability *capabilities;
    9436                 :            :         const struct rte_security_capability *capability;
    9437                 :            :         uint16_t i = 0;
    9438                 :            : 
    9439                 :          0 :         void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
    9440                 :            : 
    9441                 :            : 
    9442                 :          0 :         capabilities = rte_security_capabilities_get(ctx);
    9443                 :            : 
    9444         [ #  # ]:          0 :         if (capabilities == NULL)
    9445                 :            :                 return -ENOTSUP;
    9446                 :            : 
    9447         [ #  # ]:          0 :         while ((capability = &capabilities[i++])->action !=
    9448                 :            :                         RTE_SECURITY_ACTION_TYPE_NONE) {
    9449         [ #  # ]:          0 :                 if (capability->action == action &&
    9450         [ #  # ]:          0 :                                 capability->protocol == proto)
    9451                 :            :                         return 0;
    9452                 :            :         }
    9453                 :            : 
    9454                 :            :         return -ENOTSUP;
    9455                 :            : }
    9456                 :            : 
    9457                 :            : /* Basic algorithm run function for async inplace mode.
    9458                 :            :  * Creates a session from input parameters and runs one operation
    9459                 :            :  * on input_vec. Checks the output of the crypto operation against
    9460                 :            :  * output_vec.
    9461                 :            :  */
    9462                 :          0 : static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
    9463                 :            :                            enum rte_crypto_auth_operation opa,
    9464                 :            :                            const uint8_t *input_vec, unsigned int input_vec_len,
    9465                 :            :                            const uint8_t *output_vec,
    9466                 :            :                            unsigned int output_vec_len,
    9467                 :            :                            enum rte_crypto_cipher_algorithm cipher_alg,
    9468                 :            :                            const uint8_t *cipher_key, uint32_t cipher_key_len,
    9469                 :            :                            enum rte_crypto_auth_algorithm auth_alg,
    9470                 :            :                            const uint8_t *auth_key, uint32_t auth_key_len,
    9471                 :            :                            uint8_t bearer, enum rte_security_pdcp_domain domain,
    9472                 :            :                            uint8_t packet_direction, uint8_t sn_size,
    9473                 :            :                            uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
    9474                 :            : {
    9475                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    9476                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    9477                 :            :         uint8_t *plaintext;
    9478                 :            :         int ret = TEST_SUCCESS;
    9479                 :          0 :         void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
    9480                 :            :         struct rte_cryptodev_info dev_info;
    9481                 :            :         uint64_t feat_flags;
    9482                 :            : 
    9483                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    9484                 :          0 :         feat_flags = dev_info.feature_flags;
    9485                 :            : 
    9486                 :            :         /* Verify the capabilities */
    9487                 :            :         struct rte_security_capability_idx sec_cap_idx;
    9488                 :            : 
    9489                 :          0 :         sec_cap_idx.action = ut_params->type;
    9490                 :          0 :         sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
    9491                 :          0 :         sec_cap_idx.pdcp.domain = domain;
    9492         [ #  # ]:          0 :         if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
    9493                 :            :                 return TEST_SKIPPED;
    9494                 :            : 
    9495                 :            :         /* Generate test mbuf data */
    9496                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9497                 :            : 
    9498                 :            :         /* clear mbuf payload */
    9499                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    9500                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
    9501                 :            : 
    9502                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    9503                 :            :                                                   input_vec_len);
    9504         [ #  # ]:          0 :         memcpy(plaintext, input_vec, input_vec_len);
    9505                 :            : 
    9506         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    9507         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    9508                 :            :                 printf("Device does not support RAW data-path APIs.\n");
    9509                 :          0 :                 return TEST_SKIPPED;
    9510                 :            :         }
    9511                 :            :         /* Out of place support */
    9512         [ #  # ]:          0 :         if (oop) {
    9513                 :            :                 /*
    9514                 :            :                  * For out-of-place we need to alloc another mbuf
    9515                 :            :                  */
    9516                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9517                 :          0 :                 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
    9518                 :            :         }
    9519                 :            : 
    9520                 :            :         /* Setup Cipher Parameters */
    9521                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    9522                 :          0 :         ut_params->cipher_xform.cipher.algo = cipher_alg;
    9523                 :          0 :         ut_params->cipher_xform.cipher.op = opc;
    9524                 :          0 :         ut_params->cipher_xform.cipher.key.data = cipher_key;
    9525                 :          0 :         ut_params->cipher_xform.cipher.key.length = cipher_key_len;
    9526         [ #  # ]:          0 :         ut_params->cipher_xform.cipher.iv.length =
    9527                 :            :                                 packet_direction ? 4 : 0;
    9528                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
    9529                 :            : 
    9530                 :            :         /* Setup HMAC Parameters if ICV header is required */
    9531         [ #  # ]:          0 :         if (auth_alg != 0) {
    9532                 :          0 :                 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    9533                 :          0 :                 ut_params->auth_xform.next = NULL;
    9534                 :          0 :                 ut_params->auth_xform.auth.algo = auth_alg;
    9535                 :          0 :                 ut_params->auth_xform.auth.op = opa;
    9536                 :          0 :                 ut_params->auth_xform.auth.key.data = auth_key;
    9537                 :          0 :                 ut_params->auth_xform.auth.key.length = auth_key_len;
    9538                 :            : 
    9539                 :          0 :                 ut_params->cipher_xform.next = &ut_params->auth_xform;
    9540                 :            :         } else {
    9541                 :          0 :                 ut_params->cipher_xform.next = NULL;
    9542                 :            :         }
    9543                 :            : 
    9544                 :          0 :         struct rte_security_session_conf sess_conf = {
    9545                 :          0 :                 .action_type = ut_params->type,
    9546                 :            :                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
    9547                 :            :                 {.pdcp = {
    9548                 :            :                         .bearer = bearer,
    9549                 :            :                         .domain = domain,
    9550                 :            :                         .pkt_dir = packet_direction,
    9551                 :            :                         .sn_size = sn_size,
    9552         [ #  # ]:          0 :                         .hfn = packet_direction ? 0 : hfn,
    9553                 :            :                         /**
    9554                 :            :                          * hfn can be set as pdcp_test_hfn[i]
    9555                 :            :                          * if hfn_ovrd is not set. Here, PDCP
    9556                 :            :                          * packet direction is just used to
    9557                 :            :                          * run half of the cases with session
    9558                 :            :                          * HFN and other half with per packet
    9559                 :            :                          * HFN.
    9560                 :            :                          */
    9561                 :            :                         .hfn_threshold = hfn_threshold,
    9562                 :          0 :                         .hfn_ovrd = packet_direction ? 1 : 0,
    9563                 :            :                         .sdap_enabled = sdap,
    9564                 :            :                 } },
    9565                 :            :                 .crypto_xform = &ut_params->cipher_xform
    9566                 :            :         };
    9567                 :            : 
    9568                 :            :         /* Create security session */
    9569                 :          0 :         ut_params->sec_session = rte_security_session_create(ctx,
    9570                 :            :                                 &sess_conf, ts_params->session_mpool);
    9571                 :            : 
    9572         [ #  # ]:          0 :         if (!ut_params->sec_session) {
    9573                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9574                 :            :                         __func__, i, __LINE__, "Failed to allocate session");
    9575                 :            :                 ret = TEST_FAILED;
    9576                 :          0 :                 goto on_err;
    9577                 :            :         }
    9578                 :            : 
    9579                 :            :         /* Generate crypto op data structure */
    9580                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    9581                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    9582         [ #  # ]:          0 :         if (!ut_params->op) {
    9583                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9584                 :            :                         __func__, i, __LINE__,
    9585                 :            :                         "Failed to allocate symmetric crypto operation struct");
    9586                 :            :                 ret = TEST_FAILED;
    9587                 :          0 :                 goto on_err;
    9588                 :            :         }
    9589                 :            : 
    9590                 :            :         uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
    9591                 :            :                                         uint32_t *, IV_OFFSET);
    9592         [ #  # ]:          0 :         *per_pkt_hfn = packet_direction ? hfn : 0;
    9593                 :            : 
    9594         [ #  # ]:          0 :         rte_security_attach_session(ut_params->op, ut_params->sec_session);
    9595                 :            : 
    9596                 :            :         /* set crypto operation source mbuf */
    9597                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
    9598         [ #  # ]:          0 :         if (oop)
    9599                 :          0 :                 ut_params->op->sym->m_dst = ut_params->obuf;
    9600                 :            : 
    9601                 :            :         /* Process crypto operation */
    9602         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    9603                 :            :                 /* filling lengths */
    9604                 :          0 :                 ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
    9605                 :          0 :                 ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
    9606                 :            : 
    9607                 :          0 :                 ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
    9608         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
    9609                 :            :                         return ret;
    9610                 :            :         } else {
    9611                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
    9612                 :            :         }
    9613         [ #  # ]:          0 :         if (ut_params->op == NULL) {
    9614                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9615                 :            :                         __func__, i, __LINE__,
    9616                 :            :                         "failed to process sym crypto op");
    9617                 :            :                 ret = TEST_FAILED;
    9618                 :          0 :                 goto on_err;
    9619                 :            :         }
    9620                 :            : 
    9621         [ #  # ]:          0 :         if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    9622                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9623                 :            :                         __func__, i, __LINE__, "crypto op processing failed");
    9624                 :            :                 ret = TEST_FAILED;
    9625                 :          0 :                 goto on_err;
    9626                 :            :         }
    9627                 :            : 
    9628                 :            :         /* Validate obuf */
    9629                 :          0 :         uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
    9630                 :            :                         uint8_t *);
    9631         [ #  # ]:          0 :         if (oop) {
    9632                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
    9633                 :            :                                 uint8_t *);
    9634                 :            :         }
    9635                 :            : 
    9636         [ #  # ]:          0 :         if (memcmp(ciphertext, output_vec, output_vec_len)) {
    9637                 :            :                 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
    9638                 :          0 :                 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
    9639                 :          0 :                 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
    9640                 :            :                 ret = TEST_FAILED;
    9641                 :          0 :                 goto on_err;
    9642                 :            :         }
    9643                 :            : 
    9644                 :          0 : on_err:
    9645                 :          0 :         rte_crypto_op_free(ut_params->op);
    9646                 :          0 :         ut_params->op = NULL;
    9647                 :            : 
    9648         [ #  # ]:          0 :         if (ut_params->sec_session)
    9649                 :          0 :                 rte_security_session_destroy(ctx, ut_params->sec_session);
    9650                 :          0 :         ut_params->sec_session = NULL;
    9651                 :            : 
    9652                 :          0 :         rte_pktmbuf_free(ut_params->ibuf);
    9653                 :          0 :         ut_params->ibuf = NULL;
    9654         [ #  # ]:          0 :         if (oop) {
    9655                 :          0 :                 rte_pktmbuf_free(ut_params->obuf);
    9656                 :          0 :                 ut_params->obuf = NULL;
    9657                 :            :         }
    9658                 :            : 
    9659                 :            :         return ret;
    9660                 :            : }
    9661                 :            : 
    9662                 :            : static int
    9663                 :          0 : test_pdcp_proto_SGL(int i, int oop,
    9664                 :            :         enum rte_crypto_cipher_operation opc,
    9665                 :            :         enum rte_crypto_auth_operation opa,
    9666                 :            :         uint8_t *input_vec,
    9667                 :            :         unsigned int input_vec_len,
    9668                 :            :         uint8_t *output_vec,
    9669                 :            :         unsigned int output_vec_len,
    9670                 :            :         uint32_t fragsz,
    9671                 :            :         uint32_t fragsz_oop)
    9672                 :            : {
    9673                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
    9674                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
    9675                 :            :         uint8_t *plaintext;
    9676                 :            :         struct rte_mbuf *buf, *buf_oop = NULL;
    9677                 :            :         int ret = TEST_SUCCESS;
    9678                 :            :         int to_trn = 0;
    9679                 :            :         int to_trn_tbl[16];
    9680                 :            :         int segs = 1;
    9681                 :            :         unsigned int trn_data = 0;
    9682                 :            :         struct rte_cryptodev_info dev_info;
    9683                 :            :         uint64_t feat_flags;
    9684                 :          0 :         void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
    9685                 :            :         struct rte_mbuf *temp_mbuf;
    9686                 :            : 
    9687                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
    9688                 :          0 :         feat_flags = dev_info.feature_flags;
    9689                 :            : 
    9690         [ #  # ]:          0 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
    9691         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
    9692                 :            :                 printf("Device does not support RAW data-path APIs.\n");
    9693                 :          0 :                 return -ENOTSUP;
    9694                 :            :         }
    9695                 :            :         /* Verify the capabilities */
    9696                 :            :         struct rte_security_capability_idx sec_cap_idx;
    9697                 :            : 
    9698                 :          0 :         sec_cap_idx.action = ut_params->type;
    9699                 :          0 :         sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
    9700                 :          0 :         sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
    9701         [ #  # ]:          0 :         if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
    9702                 :            :                 return TEST_SKIPPED;
    9703                 :            : 
    9704                 :            :         if (fragsz > input_vec_len)
    9705                 :            :                 fragsz = input_vec_len;
    9706                 :            : 
    9707                 :          0 :         uint16_t plaintext_len = fragsz;
    9708         [ #  # ]:          0 :         uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
    9709                 :            : 
    9710         [ #  # ]:          0 :         if (fragsz_oop > output_vec_len)
    9711                 :          0 :                 frag_size_oop = output_vec_len;
    9712                 :            : 
    9713                 :            :         int ecx = 0;
    9714         [ #  # ]:          0 :         if (input_vec_len % fragsz != 0) {
    9715         [ #  # ]:          0 :                 if (input_vec_len / fragsz + 1 > 16)
    9716                 :            :                         return 1;
    9717         [ #  # ]:          0 :         } else if (input_vec_len / fragsz > 16)
    9718                 :            :                 return 1;
    9719                 :            : 
    9720                 :            :         /* Out of place support */
    9721         [ #  # ]:          0 :         if (oop) {
    9722                 :            :                 /*
    9723                 :            :                  * For out-of-place we need to alloc another mbuf
    9724                 :            :                  */
    9725                 :          0 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9726                 :            :                 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
    9727                 :          0 :                 buf_oop = ut_params->obuf;
    9728                 :            :         }
    9729                 :            : 
    9730                 :            :         /* Generate test mbuf data */
    9731                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9732                 :            : 
    9733                 :            :         /* clear mbuf payload */
    9734                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
    9735                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
    9736                 :            : 
    9737                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
    9738                 :            :                                                   plaintext_len);
    9739                 :          0 :         memcpy(plaintext, input_vec, plaintext_len);
    9740                 :            :         trn_data += plaintext_len;
    9741                 :            : 
    9742                 :          0 :         buf = ut_params->ibuf;
    9743                 :            : 
    9744                 :            :         /*
    9745                 :            :          * Loop until no more fragments
    9746                 :            :          */
    9747                 :            : 
    9748         [ #  # ]:          0 :         while (trn_data < input_vec_len) {
    9749                 :          0 :                 ++segs;
    9750                 :          0 :                 to_trn = (input_vec_len - trn_data < fragsz) ?
    9751                 :          0 :                                 (input_vec_len - trn_data) : fragsz;
    9752                 :            : 
    9753                 :          0 :                 to_trn_tbl[ecx++] = to_trn;
    9754                 :            : 
    9755         [ #  # ]:          0 :                 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9756                 :            :                 buf = buf->next;
    9757                 :            : 
    9758         [ #  # ]:          0 :                 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
    9759                 :            :                                 rte_pktmbuf_tailroom(buf));
    9760                 :            : 
    9761                 :            :                 /* OOP */
    9762         [ #  # ]:          0 :                 if (oop && !fragsz_oop) {
    9763                 :          0 :                         buf_oop->next =
    9764                 :          0 :                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9765                 :            :                         buf_oop = buf_oop->next;
    9766                 :          0 :                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
    9767                 :            :                                         0, rte_pktmbuf_tailroom(buf_oop));
    9768                 :          0 :                         rte_pktmbuf_append(buf_oop, to_trn);
    9769                 :            :                 }
    9770                 :            : 
    9771                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
    9772                 :            :                                 to_trn);
    9773                 :            : 
    9774                 :          0 :                 memcpy(plaintext, input_vec + trn_data, to_trn);
    9775                 :          0 :                 trn_data += to_trn;
    9776                 :            :         }
    9777                 :            : 
    9778                 :          0 :         ut_params->ibuf->nb_segs = segs;
    9779                 :            : 
    9780                 :            :         segs = 1;
    9781         [ #  # ]:          0 :         if (fragsz_oop && oop) {
    9782                 :            :                 to_trn = 0;
    9783                 :            :                 ecx = 0;
    9784                 :            : 
    9785                 :          0 :                 trn_data = frag_size_oop;
    9786         [ #  # ]:          0 :                 while (trn_data < output_vec_len) {
    9787                 :          0 :                         ++segs;
    9788                 :          0 :                         to_trn =
    9789                 :          0 :                                 (output_vec_len - trn_data <
    9790                 :            :                                                 frag_size_oop) ?
    9791                 :          0 :                                 (output_vec_len - trn_data) :
    9792                 :            :                                                 frag_size_oop;
    9793                 :            : 
    9794                 :          0 :                         to_trn_tbl[ecx++] = to_trn;
    9795                 :            : 
    9796                 :          0 :                         buf_oop->next =
    9797                 :          0 :                                 rte_pktmbuf_alloc(ts_params->mbuf_pool);
    9798                 :            :                         buf_oop = buf_oop->next;
    9799                 :          0 :                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
    9800                 :            :                                         0, rte_pktmbuf_tailroom(buf_oop));
    9801                 :          0 :                         rte_pktmbuf_append(buf_oop, to_trn);
    9802                 :            : 
    9803                 :          0 :                         trn_data += to_trn;
    9804                 :            :                 }
    9805                 :          0 :                 ut_params->obuf->nb_segs = segs;
    9806                 :            :         }
    9807                 :            : 
    9808                 :            :         /* Setup Cipher Parameters */
    9809                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
    9810                 :          0 :         ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
    9811                 :          0 :         ut_params->cipher_xform.cipher.op = opc;
    9812                 :          0 :         ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
    9813                 :          0 :         ut_params->cipher_xform.cipher.key.length =
    9814                 :          0 :                                         pdcp_test_params[i].cipher_key_len;
    9815                 :          0 :         ut_params->cipher_xform.cipher.iv.length = 0;
    9816                 :            : 
    9817                 :            :         /* Setup HMAC Parameters if ICV header is required */
    9818         [ #  # ]:          0 :         if (pdcp_test_params[i].auth_alg != 0) {
    9819                 :          0 :                 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
    9820                 :          0 :                 ut_params->auth_xform.next = NULL;
    9821                 :          0 :                 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
    9822                 :          0 :                 ut_params->auth_xform.auth.op = opa;
    9823                 :          0 :                 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
    9824                 :          0 :                 ut_params->auth_xform.auth.key.length =
    9825                 :          0 :                                         pdcp_test_params[i].auth_key_len;
    9826                 :            : 
    9827                 :          0 :                 ut_params->cipher_xform.next = &ut_params->auth_xform;
    9828                 :            :         } else {
    9829                 :          0 :                 ut_params->cipher_xform.next = NULL;
    9830                 :            :         }
    9831                 :            : 
    9832                 :          0 :         struct rte_security_session_conf sess_conf = {
    9833                 :          0 :                 .action_type = ut_params->type,
    9834                 :            :                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
    9835                 :            :                 {.pdcp = {
    9836                 :          0 :                         .bearer = pdcp_test_bearer[i],
    9837                 :          0 :                         .domain = pdcp_test_params[i].domain,
    9838                 :          0 :                         .pkt_dir = pdcp_test_packet_direction[i],
    9839                 :          0 :                         .sn_size = pdcp_test_data_sn_size[i],
    9840                 :          0 :                         .hfn = pdcp_test_hfn[i],
    9841                 :          0 :                         .hfn_threshold = pdcp_test_hfn_threshold[i],
    9842                 :            :                         .hfn_ovrd = 0,
    9843                 :            :                 } },
    9844                 :            :                 .crypto_xform = &ut_params->cipher_xform
    9845                 :            :         };
    9846                 :            : 
    9847                 :            :         /* Create security session */
    9848                 :          0 :         ut_params->sec_session = rte_security_session_create(ctx,
    9849                 :            :                                 &sess_conf, ts_params->session_mpool);
    9850                 :            : 
    9851         [ #  # ]:          0 :         if (!ut_params->sec_session) {
    9852                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9853                 :            :                         __func__, i, __LINE__, "Failed to allocate session");
    9854                 :            :                 ret = TEST_FAILED;
    9855                 :          0 :                 goto on_err;
    9856                 :            :         }
    9857                 :            : 
    9858                 :            :         /* Generate crypto op data structure */
    9859                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
    9860                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
    9861         [ #  # ]:          0 :         if (!ut_params->op) {
    9862                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9863                 :            :                         __func__, i, __LINE__,
    9864                 :            :                         "Failed to allocate symmetric crypto operation struct");
    9865                 :            :                 ret = TEST_FAILED;
    9866                 :          0 :                 goto on_err;
    9867                 :            :         }
    9868                 :            : 
    9869         [ #  # ]:          0 :         rte_security_attach_session(ut_params->op, ut_params->sec_session);
    9870                 :            : 
    9871                 :            :         /* set crypto operation source mbuf */
    9872                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
    9873         [ #  # ]:          0 :         if (oop)
    9874                 :          0 :                 ut_params->op->sym->m_dst = ut_params->obuf;
    9875                 :            : 
    9876                 :            :         /* Process crypto operation */
    9877                 :          0 :         temp_mbuf = ut_params->op->sym->m_src;
    9878         [ #  # ]:          0 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
    9879                 :            :                 /* filling lengths */
    9880         [ #  # ]:          0 :                 while (temp_mbuf) {
    9881                 :          0 :                         ut_params->op->sym->cipher.data.length
    9882                 :          0 :                                 += temp_mbuf->pkt_len;
    9883                 :          0 :                         ut_params->op->sym->auth.data.length
    9884                 :          0 :                                 += temp_mbuf->pkt_len;
    9885                 :          0 :                         temp_mbuf = temp_mbuf->next;
    9886                 :            :                 }
    9887                 :            : 
    9888                 :          0 :                 ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
    9889         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
    9890                 :            :                         return ret;
    9891                 :            :         } else {
    9892                 :          0 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
    9893                 :            :                                                         ut_params->op);
    9894                 :            :         }
    9895         [ #  # ]:          0 :         if (ut_params->op == NULL) {
    9896                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9897                 :            :                         __func__, i, __LINE__,
    9898                 :            :                         "failed to process sym crypto op");
    9899                 :            :                 ret = TEST_FAILED;
    9900                 :          0 :                 goto on_err;
    9901                 :            :         }
    9902                 :            : 
    9903         [ #  # ]:          0 :         if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
    9904                 :            :                 printf("TestCase %s()-%d line %d failed %s: ",
    9905                 :            :                         __func__, i, __LINE__, "crypto op processing failed");
    9906                 :            :                 ret = TEST_FAILED;
    9907                 :          0 :                 goto on_err;
    9908                 :            :         }
    9909                 :            : 
    9910                 :            :         /* Validate obuf */
    9911                 :          0 :         uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
    9912                 :            :                         uint8_t *);
    9913         [ #  # ]:          0 :         if (oop) {
    9914                 :          0 :                 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
    9915                 :            :                                 uint8_t *);
    9916                 :            :         }
    9917         [ #  # ]:          0 :         if (fragsz_oop)
    9918                 :          0 :                 fragsz = frag_size_oop;
    9919         [ #  # ]:          0 :         if (memcmp(ciphertext, output_vec, fragsz)) {
    9920                 :            :                 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
    9921                 :          0 :                 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
    9922                 :          0 :                 rte_hexdump(stdout, "reference", output_vec, fragsz);
    9923                 :            :                 ret = TEST_FAILED;
    9924                 :          0 :                 goto on_err;
    9925                 :            :         }
    9926                 :            : 
    9927                 :          0 :         buf = ut_params->op->sym->m_src->next;
    9928         [ #  # ]:          0 :         if (oop)
    9929                 :          0 :                 buf = ut_params->op->sym->m_dst->next;
    9930                 :            : 
    9931                 :            :         unsigned int off = fragsz;
    9932                 :            : 
    9933                 :            :         ecx = 0;
    9934         [ #  # ]:          0 :         while (buf) {
    9935                 :          0 :                 ciphertext = rte_pktmbuf_mtod(buf,
    9936                 :            :                                 uint8_t *);
    9937         [ #  # ]:          0 :                 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
    9938                 :            :                         printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
    9939                 :          0 :                         rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
    9940                 :          0 :                         rte_hexdump(stdout, "reference", output_vec + off,
    9941                 :            :                                         to_trn_tbl[ecx]);
    9942                 :            :                         ret = TEST_FAILED;
    9943                 :          0 :                         goto on_err;
    9944                 :            :                 }
    9945                 :          0 :                 off += to_trn_tbl[ecx++];
    9946                 :          0 :                 buf = buf->next;
    9947                 :            :         }
    9948                 :          0 : on_err:
    9949                 :          0 :         rte_crypto_op_free(ut_params->op);
    9950                 :          0 :         ut_params->op = NULL;
    9951                 :            : 
    9952         [ #  # ]:          0 :         if (ut_params->sec_session)
    9953                 :          0 :                 rte_security_session_destroy(ctx, ut_params->sec_session);
    9954                 :          0 :         ut_params->sec_session = NULL;
    9955                 :            : 
    9956                 :          0 :         rte_pktmbuf_free(ut_params->ibuf);
    9957                 :          0 :         ut_params->ibuf = NULL;
    9958         [ #  # ]:          0 :         if (oop) {
    9959                 :          0 :                 rte_pktmbuf_free(ut_params->obuf);
    9960                 :          0 :                 ut_params->obuf = NULL;
    9961                 :            :         }
    9962                 :            : 
    9963                 :            :         return ret;
    9964                 :            : }
    9965                 :            : 
    9966                 :            : int
    9967                 :          0 : test_pdcp_proto_cplane_encap(int i)
    9968                 :            : {
    9969                 :          0 :         return test_pdcp_proto(
    9970                 :            :                 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
    9971                 :          0 :                 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
    9972                 :          0 :                 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
    9973                 :          0 :                 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
    9974                 :          0 :                 pdcp_test_params[i].cipher_key_len,
    9975                 :          0 :                 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
    9976                 :          0 :                 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
    9977                 :          0 :                 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
    9978                 :          0 :                 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
    9979                 :            :                 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
    9980                 :            : }
    9981                 :            : 
    9982                 :            : int
    9983                 :          0 : test_pdcp_proto_uplane_encap(int i)
    9984                 :            : {
    9985                 :          0 :         return test_pdcp_proto(
    9986                 :            :                 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
    9987                 :          0 :                 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
    9988                 :          0 :                 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
    9989                 :          0 :                 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
    9990                 :          0 :                 pdcp_test_params[i].cipher_key_len,
    9991                 :          0 :                 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
    9992                 :          0 :                 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
    9993                 :          0 :                 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
    9994                 :          0 :                 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
    9995                 :            :                 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
    9996                 :            : }
    9997                 :            : 
    9998                 :            : int
    9999                 :          0 : test_pdcp_proto_uplane_encap_with_int(int i)
   10000                 :            : {
   10001                 :          0 :         return test_pdcp_proto(
   10002                 :            :                 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
   10003                 :          0 :                 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
   10004                 :          0 :                 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
   10005                 :          0 :                 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
   10006                 :          0 :                 pdcp_test_params[i].cipher_key_len,
   10007                 :          0 :                 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
   10008                 :          0 :                 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
   10009                 :          0 :                 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
   10010                 :          0 :                 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
   10011                 :            :                 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
   10012                 :            : }
   10013                 :            : 
   10014                 :            : int
   10015                 :          0 : test_pdcp_proto_cplane_decap(int i)
   10016                 :            : {
   10017                 :          0 :         return test_pdcp_proto(
   10018                 :            :                 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
   10019                 :          0 :                 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
   10020                 :          0 :                 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
   10021                 :          0 :                 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
   10022                 :          0 :                 pdcp_test_params[i].cipher_key_len,
   10023                 :          0 :                 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
   10024                 :          0 :                 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
   10025                 :          0 :                 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
   10026                 :          0 :                 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
   10027                 :            :                 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
   10028                 :            : }
   10029                 :            : 
   10030                 :            : int
   10031                 :          0 : test_pdcp_proto_uplane_decap(int i)
   10032                 :            : {
   10033                 :          0 :         return test_pdcp_proto(
   10034                 :            :                 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
   10035                 :          0 :                 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
   10036                 :          0 :                 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
   10037                 :          0 :                 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
   10038                 :          0 :                 pdcp_test_params[i].cipher_key_len,
   10039                 :          0 :                 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
   10040                 :          0 :                 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
   10041                 :          0 :                 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
   10042                 :          0 :                 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
   10043                 :            :                 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
   10044                 :            : }
   10045                 :            : 
   10046                 :            : int
   10047                 :          0 : test_pdcp_proto_uplane_decap_with_int(int i)
   10048                 :            : {
   10049                 :          0 :         return test_pdcp_proto(
   10050                 :            :                 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
   10051                 :          0 :                 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
   10052                 :          0 :                 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
   10053                 :          0 :                 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
   10054                 :          0 :                 pdcp_test_params[i].cipher_key_len,
   10055                 :          0 :                 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
   10056                 :          0 :                 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
   10057                 :          0 :                 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
   10058                 :          0 :                 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
   10059                 :            :                 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
   10060                 :            : }
   10061                 :            : 
   10062                 :            : static int
   10063                 :          0 : test_PDCP_PROTO_SGL_in_place_32B(void)
   10064                 :            : {
   10065                 :            :         /* i can be used for running any PDCP case
   10066                 :            :          * In this case it is uplane 12-bit AES-SNOW DL encap
   10067                 :            :          */
   10068                 :            :         int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
   10069                 :          0 :         return test_pdcp_proto_SGL(i, IN_PLACE,
   10070                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
   10071                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
   10072                 :            :                         pdcp_test_data_in[i],
   10073                 :            :                         pdcp_test_data_in_len[i],
   10074                 :            :                         pdcp_test_data_out[i],
   10075                 :          0 :                         pdcp_test_data_in_len[i]+4,
   10076                 :            :                         32, 0);
   10077                 :            : }
   10078                 :            : static int
   10079                 :          0 : test_PDCP_PROTO_SGL_oop_32B_128B(void)
   10080                 :            : {
   10081                 :            :         /* i can be used for running any PDCP case
   10082                 :            :          * In this case it is uplane 18-bit NULL-NULL DL encap
   10083                 :            :          */
   10084                 :            :         int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
   10085                 :          0 :         return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
   10086                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
   10087                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
   10088                 :            :                         pdcp_test_data_in[i],
   10089                 :            :                         pdcp_test_data_in_len[i],
   10090                 :            :                         pdcp_test_data_out[i],
   10091                 :          0 :                         pdcp_test_data_in_len[i]+4,
   10092                 :            :                         32, 128);
   10093                 :            : }
   10094                 :            : static int
   10095                 :          0 : test_PDCP_PROTO_SGL_oop_32B_40B(void)
   10096                 :            : {
   10097                 :            :         /* i can be used for running any PDCP case
   10098                 :            :          * In this case it is uplane 18-bit AES DL encap
   10099                 :            :          */
   10100                 :            :         int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
   10101                 :            :                         + DOWNLINK;
   10102                 :          0 :         return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
   10103                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
   10104                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
   10105                 :            :                         pdcp_test_data_in[i],
   10106                 :            :                         pdcp_test_data_in_len[i],
   10107                 :            :                         pdcp_test_data_out[i],
   10108                 :            :                         pdcp_test_data_in_len[i],
   10109                 :            :                         32, 40);
   10110                 :            : }
   10111                 :            : static int
   10112                 :          0 : test_PDCP_PROTO_SGL_oop_128B_32B(void)
   10113                 :            : {
   10114                 :            :         /* i can be used for running any PDCP case
   10115                 :            :          * In this case it is cplane 12-bit AES-ZUC DL encap
   10116                 :            :          */
   10117                 :            :         int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
   10118                 :          0 :         return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
   10119                 :            :                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
   10120                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE,
   10121                 :            :                         pdcp_test_data_in[i],
   10122                 :            :                         pdcp_test_data_in_len[i],
   10123                 :            :                         pdcp_test_data_out[i],
   10124                 :          0 :                         pdcp_test_data_in_len[i]+4,
   10125                 :            :                         128, 32);
   10126                 :            : }
   10127                 :            : 
   10128                 :            : static int
   10129                 :          0 : test_PDCP_SDAP_PROTO_encap_all(void)
   10130                 :            : {
   10131                 :            :         int i = 0, size = 0;
   10132                 :            :         int err, all_err = TEST_SUCCESS;
   10133                 :            :         const struct pdcp_sdap_test *cur_test;
   10134                 :            : 
   10135                 :            :         size = RTE_DIM(list_pdcp_sdap_tests);
   10136                 :            : 
   10137         [ #  # ]:          0 :         for (i = 0; i < size; i++) {
   10138                 :            :                 cur_test = &list_pdcp_sdap_tests[i];
   10139                 :          0 :                 err = test_pdcp_proto(
   10140                 :            :                         i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
   10141                 :          0 :                         RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
   10142                 :          0 :                         cur_test->in_len, cur_test->data_out,
   10143                 :          0 :                         cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
   10144                 :          0 :                         cur_test->param.cipher_alg, cur_test->cipher_key,
   10145                 :          0 :                         cur_test->param.cipher_key_len,
   10146                 :          0 :                         cur_test->param.auth_alg,
   10147                 :          0 :                         cur_test->auth_key, cur_test->param.auth_key_len,
   10148                 :          0 :                         cur_test->bearer, cur_test->param.domain,
   10149                 :          0 :                         cur_test->packet_direction, cur_test->sn_size,
   10150                 :          0 :                         cur_test->hfn,
   10151         [ #  # ]:          0 :                         cur_test->hfn_threshold, SDAP_ENABLED);
   10152         [ #  # ]:          0 :                 if (err) {
   10153                 :            :                         printf("\t%d) %s: Encapsulation failed\n",
   10154                 :          0 :                                         cur_test->test_idx,
   10155                 :          0 :                                         cur_test->param.name);
   10156                 :            :                         err = TEST_FAILED;
   10157                 :            :                 } else {
   10158                 :          0 :                         printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
   10159                 :          0 :                                         cur_test->param.name);
   10160                 :            :                         err = TEST_SUCCESS;
   10161                 :            :                 }
   10162                 :          0 :                 all_err += err;
   10163                 :            :         }
   10164                 :            : 
   10165                 :          0 :         printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
   10166                 :            : 
   10167         [ #  # ]:          0 :         return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
   10168                 :            : }
   10169                 :            : 
   10170                 :            : static int
   10171                 :          0 : test_PDCP_PROTO_short_mac(void)
   10172                 :            : {
   10173                 :            :         int i = 0, size = 0;
   10174                 :            :         int err, all_err = TEST_SUCCESS;
   10175                 :            :         const struct pdcp_short_mac_test *cur_test;
   10176                 :            : 
   10177                 :            :         size = RTE_DIM(list_pdcp_smac_tests);
   10178                 :            : 
   10179         [ #  # ]:          0 :         for (i = 0; i < size; i++) {
   10180                 :            :                 cur_test = &list_pdcp_smac_tests[i];
   10181                 :          0 :                 err = test_pdcp_proto(
   10182                 :            :                         i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
   10183                 :          0 :                         RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
   10184                 :          0 :                         cur_test->in_len, cur_test->data_out,
   10185                 :          0 :                         cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
   10186                 :            :                         RTE_CRYPTO_CIPHER_NULL, NULL,
   10187                 :          0 :                         0, cur_test->param.auth_alg,
   10188                 :          0 :                         cur_test->auth_key, cur_test->param.auth_key_len,
   10189         [ #  # ]:          0 :                         0, cur_test->param.domain, 0, 0,
   10190                 :            :                         0, 0, 0);
   10191         [ #  # ]:          0 :                 if (err) {
   10192                 :            :                         printf("\t%d) %s: Short MAC test failed\n",
   10193                 :          0 :                                         cur_test->test_idx,
   10194                 :          0 :                                         cur_test->param.name);
   10195                 :            :                         err = TEST_FAILED;
   10196                 :            :                 } else {
   10197                 :            :                         printf("\t%d) %s: Short MAC test PASS\n",
   10198                 :          0 :                                         cur_test->test_idx,
   10199                 :          0 :                                         cur_test->param.name);
   10200                 :          0 :                         rte_hexdump(stdout, "MAC I",
   10201                 :          0 :                                     cur_test->data_out + cur_test->in_len + 2,
   10202                 :            :                                     2);
   10203                 :            :                         err = TEST_SUCCESS;
   10204                 :            :                 }
   10205                 :          0 :                 all_err += err;
   10206                 :            :         }
   10207                 :            : 
   10208                 :          0 :         printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
   10209                 :            : 
   10210         [ #  # ]:          0 :         return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
   10211                 :            : 
   10212                 :            : }
   10213                 :            : 
   10214                 :            : static int
   10215                 :          0 : test_PDCP_SDAP_PROTO_decap_all(void)
   10216                 :            : {
   10217                 :            :         int i = 0, size = 0;
   10218                 :            :         int err, all_err = TEST_SUCCESS;
   10219                 :            :         const struct pdcp_sdap_test *cur_test;
   10220                 :            : 
   10221                 :            :         size = RTE_DIM(list_pdcp_sdap_tests);
   10222                 :            : 
   10223         [ #  # ]:          0 :         for (i = 0; i < size; i++) {
   10224                 :            :                 cur_test = &list_pdcp_sdap_tests[i];
   10225                 :          0 :                 err = test_pdcp_proto(
   10226                 :            :                         i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
   10227                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY,
   10228                 :          0 :                         cur_test->data_out,
   10229                 :          0 :                         cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
   10230                 :          0 :                         cur_test->data_in, cur_test->in_len,
   10231                 :          0 :                         cur_test->param.cipher_alg,
   10232                 :          0 :                         cur_test->cipher_key, cur_test->param.cipher_key_len,
   10233                 :          0 :                         cur_test->param.auth_alg, cur_test->auth_key,
   10234                 :          0 :                         cur_test->param.auth_key_len, cur_test->bearer,
   10235                 :          0 :                         cur_test->param.domain, cur_test->packet_direction,
   10236                 :          0 :                         cur_test->sn_size, cur_test->hfn,
   10237         [ #  # ]:          0 :                         cur_test->hfn_threshold, SDAP_ENABLED);
   10238         [ #  # ]:          0 :                 if (err) {
   10239                 :            :                         printf("\t%d) %s: Decapsulation failed\n",
   10240                 :          0 :                                         cur_test->test_idx,
   10241                 :          0 :                                         cur_test->param.name);
   10242                 :            :                         err = TEST_FAILED;
   10243                 :            :                 } else {
   10244                 :          0 :                         printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
   10245                 :          0 :                                         cur_test->param.name);
   10246                 :            :                         err = TEST_SUCCESS;
   10247                 :            :                 }
   10248                 :          0 :                 all_err += err;
   10249                 :            :         }
   10250                 :            : 
   10251                 :          0 :         printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
   10252                 :            : 
   10253         [ #  # ]:          0 :         return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
   10254                 :            : }
   10255                 :            : 
   10256                 :            : static int
   10257                 :          0 : test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
   10258                 :            :                                struct crypto_unittest_params *ut_params,
   10259                 :            :                                struct rte_security_ipsec_xform *ipsec_xform,
   10260                 :            :                                const struct ipsec_test_data *td,
   10261                 :            :                                const struct ipsec_test_flags *flags,
   10262                 :            :                                int pkt_num)
   10263                 :            : {
   10264                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
   10265                 :            :         enum rte_security_ipsec_sa_direction dir;
   10266                 :            :         int ret;
   10267                 :            : 
   10268                 :          0 :         dir = ipsec_xform->direction;
   10269                 :            : 
   10270                 :            :         /* Generate crypto op data structure */
   10271                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   10272                 :            :                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   10273         [ #  # ]:          0 :         if (!ut_params->op) {
   10274                 :            :                 printf("Could not allocate crypto op");
   10275                 :          0 :                 return TEST_FAILED;
   10276                 :            :         }
   10277                 :            : 
   10278                 :            :         /* Attach session to operation */
   10279         [ #  # ]:          0 :         rte_security_attach_session(ut_params->op, ut_params->sec_session);
   10280                 :            : 
   10281                 :            :         /* Set crypto operation mbufs */
   10282                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
   10283                 :          0 :         ut_params->op->sym->m_dst = NULL;
   10284                 :            : 
   10285                 :            :         /* Copy IV in crypto operation when IV generation is disabled */
   10286         [ #  # ]:          0 :         if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
   10287         [ #  # ]:          0 :             ipsec_xform->options.iv_gen_disable == 1) {
   10288                 :          0 :                 uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
   10289                 :            :                                                         uint8_t *,
   10290                 :            :                                                         IV_OFFSET);
   10291                 :            :                 int len;
   10292                 :            : 
   10293         [ #  # ]:          0 :                 if (td->aead)
   10294                 :          0 :                         len = td->xform.aead.aead.iv.length;
   10295         [ #  # ]:          0 :                 else if (td->aes_gmac)
   10296                 :          0 :                         len = td->xform.chain.auth.auth.iv.length;
   10297                 :            :                 else
   10298                 :          0 :                         len = td->xform.chain.cipher.cipher.iv.length;
   10299                 :            : 
   10300                 :          0 :                 memcpy(iv, td->iv.data, len);
   10301                 :            :         }
   10302                 :            : 
   10303                 :            :         /* Process crypto operation */
   10304                 :          0 :         process_crypto_request(dev_id, ut_params->op);
   10305                 :            : 
   10306                 :          0 :         ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
   10307                 :            : 
   10308                 :          0 :         rte_crypto_op_free(ut_params->op);
   10309                 :          0 :         ut_params->op = NULL;
   10310                 :            : 
   10311                 :          0 :         return ret;
   10312                 :            : }
   10313                 :            : 
   10314                 :            : static int
   10315                 :          0 : test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
   10316                 :            :                           struct crypto_unittest_params *ut_params,
   10317                 :            :                           void *ctx)
   10318                 :            : {
   10319                 :            :         uint64_t timeout, userdata;
   10320                 :            :         struct rte_ether_hdr *hdr;
   10321                 :            :         struct rte_mbuf *m;
   10322                 :            :         void **sec_sess;
   10323                 :            :         int ret;
   10324                 :            : 
   10325                 :            :         RTE_SET_USED(ts_params);
   10326                 :            : 
   10327         [ #  # ]:          0 :         hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
   10328                 :          0 :         hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
   10329                 :            : 
   10330                 :          0 :         ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
   10331                 :          0 :         ut_params->ibuf->port = 0;
   10332                 :            : 
   10333                 :          0 :         sec_sess = &ut_params->sec_session;
   10334                 :          0 :         ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
   10335                 :            : 
   10336         [ #  # ]:          0 :         if (ret != 1)
   10337                 :            :                 return TEST_FAILED;
   10338                 :            : 
   10339                 :          0 :         ut_params->ibuf = NULL;
   10340                 :            : 
   10341                 :            :         /* Add a timeout for 1 s */
   10342                 :          0 :         timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
   10343                 :            : 
   10344                 :            :         do {
   10345                 :            :                 /* Get packet from port 0, queue 0 */
   10346                 :          0 :                 ret = rte_eth_rx_burst(0, 0, &m, 1);
   10347   [ #  #  #  # ]:          0 :         } while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
   10348                 :            : 
   10349         [ #  # ]:          0 :         if (ret == 0) {
   10350                 :            :                 printf("Could not receive packets from ethdev\n");
   10351                 :          0 :                 return TEST_FAILED;
   10352                 :            :         }
   10353                 :            : 
   10354         [ #  # ]:          0 :         if (m == NULL) {
   10355                 :            :                 printf("Received mbuf is NULL\n");
   10356                 :          0 :                 return TEST_FAILED;
   10357                 :            :         }
   10358                 :            : 
   10359                 :          0 :         ut_params->ibuf = m;
   10360                 :            : 
   10361         [ #  # ]:          0 :         if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
   10362                 :            :                 printf("Received packet is not Rx security processed\n");
   10363                 :          0 :                 return TEST_FAILED;
   10364                 :            :         }
   10365                 :            : 
   10366         [ #  # ]:          0 :         if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
   10367                 :            :                 printf("Received packet has failed Rx security processing\n");
   10368                 :          0 :                 return TEST_FAILED;
   10369                 :            :         }
   10370                 :            : 
   10371                 :            :         /*
   10372                 :            :          * 'ut_params' is set as userdata. Verify that the field is returned
   10373                 :            :          * correctly.
   10374                 :            :          */
   10375                 :          0 :         userdata = *(uint64_t *)rte_security_dynfield(m);
   10376         [ #  # ]:          0 :         if (userdata != (uint64_t)ut_params) {
   10377                 :            :                 printf("Userdata retrieved not matching expected\n");
   10378                 :          0 :                 return TEST_FAILED;
   10379                 :            :         }
   10380                 :            : 
   10381                 :            :         /* Trim L2 header */
   10382                 :            :         rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
   10383                 :            : 
   10384                 :            :         return TEST_SUCCESS;
   10385                 :            : }
   10386                 :            : 
   10387                 :            : static int
   10388                 :          0 : test_ipsec_proto_process(const struct ipsec_test_data td[],
   10389                 :            :                          struct ipsec_test_data res_d[],
   10390                 :            :                          int nb_td,
   10391                 :            :                          bool silent,
   10392                 :            :                          const struct ipsec_test_flags *flags)
   10393                 :            : {
   10394                 :            :         uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
   10395                 :            :                                 0x0000, 0x001a};
   10396                 :            :         uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
   10397                 :            :                                 0xe82c, 0x4887};
   10398                 :            :         const struct rte_ipv4_hdr *ipv4 =
   10399                 :            :                         (const struct rte_ipv4_hdr *)td[0].output_text.data;
   10400         [ #  # ]:          0 :         int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
   10401                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   10402                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   10403                 :            :         struct rte_security_capability_idx sec_cap_idx;
   10404                 :            :         const struct rte_security_capability *sec_cap;
   10405                 :            :         struct rte_security_ipsec_xform ipsec_xform;
   10406                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
   10407                 :            :         enum rte_security_ipsec_sa_direction dir;
   10408                 :            :         struct ipsec_test_data *res_d_tmp = NULL;
   10409                 :            :         uint8_t input_text[IPSEC_TEXT_MAX_LEN];
   10410                 :            :         int salt_len, i, ret = TEST_SUCCESS;
   10411                 :            :         void *ctx;
   10412                 :            :         uint32_t src, dst;
   10413                 :            :         uint32_t verify;
   10414                 :            : 
   10415                 :          0 :         ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
   10416                 :          0 :         gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
   10417                 :            : 
   10418                 :            :         /* Use first test data to create session */
   10419                 :            : 
   10420                 :            :         /* Copy IPsec xform */
   10421         [ #  # ]:          0 :         memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
   10422                 :            : 
   10423                 :          0 :         dir = ipsec_xform.direction;
   10424                 :          0 :         verify = flags->tunnel_hdr_verify;
   10425                 :            : 
   10426                 :            :         memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
   10427                 :            :         memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
   10428                 :            : 
   10429         [ #  # ]:          0 :         if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
   10430         [ #  # ]:          0 :                 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
   10431                 :          0 :                         src += 1;
   10432         [ #  # ]:          0 :                 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
   10433                 :          0 :                         dst += 1;
   10434                 :            :         }
   10435                 :            : 
   10436         [ #  # ]:          0 :         if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
   10437         [ #  # ]:          0 :                 if (td->ipsec_xform.tunnel.type ==
   10438                 :            :                                 RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
   10439                 :            :                         memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
   10440                 :            :                                sizeof(src));
   10441                 :            :                         memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
   10442                 :            :                                sizeof(dst));
   10443                 :            : 
   10444         [ #  # ]:          0 :                         if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
   10445                 :          0 :                                 ipsec_xform.tunnel.ipv4.df = 0;
   10446                 :            : 
   10447         [ #  # ]:          0 :                         if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
   10448                 :          0 :                                 ipsec_xform.tunnel.ipv4.df = 1;
   10449                 :            : 
   10450         [ #  # ]:          0 :                         if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
   10451                 :          0 :                                 ipsec_xform.tunnel.ipv4.dscp = 0;
   10452                 :            : 
   10453         [ #  # ]:          0 :                         if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
   10454                 :          0 :                                 ipsec_xform.tunnel.ipv4.dscp =
   10455                 :            :                                                 TEST_IPSEC_DSCP_VAL;
   10456                 :            : 
   10457                 :            :                 } else {
   10458         [ #  # ]:          0 :                         if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
   10459                 :          0 :                                 ipsec_xform.tunnel.ipv6.dscp = 0;
   10460                 :            : 
   10461         [ #  # ]:          0 :                         if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
   10462                 :          0 :                                 ipsec_xform.tunnel.ipv6.dscp =
   10463                 :            :                                                 TEST_IPSEC_DSCP_VAL;
   10464                 :            : 
   10465                 :            :                         memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
   10466                 :            :                                sizeof(v6_src));
   10467                 :            :                         memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
   10468                 :            :                                sizeof(v6_dst));
   10469                 :            :                 }
   10470                 :            :         }
   10471                 :            : 
   10472                 :          0 :         ctx = rte_cryptodev_get_sec_ctx(dev_id);
   10473                 :            : 
   10474                 :          0 :         sec_cap_idx.action = ut_params->type;
   10475                 :          0 :         sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
   10476                 :          0 :         sec_cap_idx.ipsec.proto = ipsec_xform.proto;
   10477                 :          0 :         sec_cap_idx.ipsec.mode = ipsec_xform.mode;
   10478                 :          0 :         sec_cap_idx.ipsec.direction = ipsec_xform.direction;
   10479                 :            : 
   10480         [ #  # ]:          0 :         if (flags->udp_encap)
   10481                 :          0 :                 ipsec_xform.options.udp_encap = 1;
   10482                 :            : 
   10483                 :          0 :         sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
   10484         [ #  # ]:          0 :         if (sec_cap == NULL)
   10485                 :            :                 return TEST_SKIPPED;
   10486                 :            : 
   10487                 :            :         /* Copy cipher session parameters */
   10488         [ #  # ]:          0 :         if (td[0].aead) {
   10489                 :          0 :                 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
   10490                 :            :                        sizeof(ut_params->aead_xform));
   10491                 :          0 :                 ut_params->aead_xform.aead.key.data = td[0].key.data;
   10492                 :          0 :                 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
   10493                 :            : 
   10494                 :            :                 /* Verify crypto capabilities */
   10495         [ #  # ]:          0 :                 if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
   10496         [ #  # ]:          0 :                         if (!silent)
   10497                 :          0 :                                 RTE_LOG(INFO, USER1,
   10498                 :            :                                         "Crypto capabilities not supported\n");
   10499                 :          0 :                         return TEST_SKIPPED;
   10500                 :            :                 }
   10501         [ #  # ]:          0 :         } else if (td[0].auth_only) {
   10502                 :          0 :                 memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
   10503                 :            :                        sizeof(ut_params->auth_xform));
   10504                 :          0 :                 ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
   10505                 :            : 
   10506         [ #  # ]:          0 :                 if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
   10507         [ #  # ]:          0 :                         if (!silent)
   10508                 :          0 :                                 RTE_LOG(INFO, USER1,
   10509                 :            :                                         "Auth crypto capabilities not supported\n");
   10510                 :          0 :                         return TEST_SKIPPED;
   10511                 :            :                 }
   10512                 :            :         } else {
   10513                 :          0 :                 memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
   10514                 :            :                        sizeof(ut_params->cipher_xform));
   10515                 :          0 :                 memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
   10516                 :            :                        sizeof(ut_params->auth_xform));
   10517                 :          0 :                 ut_params->cipher_xform.cipher.key.data = td[0].key.data;
   10518                 :          0 :                 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   10519                 :          0 :                 ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
   10520                 :            : 
   10521                 :            :                 /* Verify crypto capabilities */
   10522                 :            : 
   10523         [ #  # ]:          0 :                 if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
   10524         [ #  # ]:          0 :                         if (!silent)
   10525                 :          0 :                                 RTE_LOG(INFO, USER1,
   10526                 :            :                                         "Cipher crypto capabilities not supported\n");
   10527                 :          0 :                         return TEST_SKIPPED;
   10528                 :            :                 }
   10529                 :            : 
   10530         [ #  # ]:          0 :                 if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
   10531         [ #  # ]:          0 :                         if (!silent)
   10532                 :          0 :                                 RTE_LOG(INFO, USER1,
   10533                 :            :                                         "Auth crypto capabilities not supported\n");
   10534                 :          0 :                         return TEST_SKIPPED;
   10535                 :            :                 }
   10536                 :            :         }
   10537                 :            : 
   10538         [ #  # ]:          0 :         if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
   10539                 :            :                 return TEST_SKIPPED;
   10540                 :            : 
   10541                 :          0 :         struct rte_security_session_conf sess_conf = {
   10542                 :          0 :                 .action_type = ut_params->type,
   10543                 :            :                 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
   10544                 :            :         };
   10545                 :            : 
   10546         [ #  # ]:          0 :         if (td[0].aead || td[0].aes_gmac) {
   10547                 :          0 :                 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
   10548                 :          0 :                 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
   10549                 :            :         }
   10550                 :            : 
   10551         [ #  # ]:          0 :         if (td[0].aead) {
   10552                 :          0 :                 sess_conf.ipsec = ipsec_xform;
   10553                 :          0 :                 sess_conf.crypto_xform = &ut_params->aead_xform;
   10554         [ #  # ]:          0 :         } else if (td[0].auth_only) {
   10555                 :          0 :                 sess_conf.ipsec = ipsec_xform;
   10556                 :          0 :                 sess_conf.crypto_xform = &ut_params->auth_xform;
   10557                 :            :         } else {
   10558                 :          0 :                 sess_conf.ipsec = ipsec_xform;
   10559         [ #  # ]:          0 :                 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
   10560                 :          0 :                         sess_conf.crypto_xform = &ut_params->cipher_xform;
   10561                 :          0 :                         ut_params->cipher_xform.next = &ut_params->auth_xform;
   10562                 :            :                 } else {
   10563                 :          0 :                         sess_conf.crypto_xform = &ut_params->auth_xform;
   10564                 :          0 :                         ut_params->auth_xform.next = &ut_params->cipher_xform;
   10565                 :            :                 }
   10566                 :            :         }
   10567                 :            : 
   10568   [ #  #  #  # ]:          0 :         if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
   10569                 :          0 :                 sess_conf.userdata = ut_params;
   10570                 :            : 
   10571                 :            :         /* Create security session */
   10572                 :          0 :         ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
   10573                 :            :                                         ts_params->session_mpool);
   10574                 :            : 
   10575         [ #  # ]:          0 :         if (ut_params->sec_session == NULL)
   10576                 :            :                 return TEST_SKIPPED;
   10577                 :            : 
   10578         [ #  # ]:          0 :         for (i = 0; i < nb_td; i++) {
   10579   [ #  #  #  # ]:          0 :                 if (flags->antireplay &&
   10580                 :            :                     (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
   10581                 :          0 :                         sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
   10582                 :          0 :                         ret = rte_security_session_update(ctx,
   10583                 :            :                                 ut_params->sec_session, &sess_conf);
   10584         [ #  # ]:          0 :                         if (ret) {
   10585                 :            :                                 printf("Could not update sequence number in "
   10586                 :            :                                        "session\n");
   10587                 :          0 :                                 return TEST_SKIPPED;
   10588                 :            :                         }
   10589                 :            :                 }
   10590                 :            : 
   10591                 :            :                 /* Copy test data before modification */
   10592                 :          0 :                 memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
   10593         [ #  # ]:          0 :                 if (test_ipsec_pkt_update(input_text, flags)) {
   10594                 :            :                         ret = TEST_FAILED;
   10595                 :          0 :                         goto mbuf_free;
   10596                 :            :                 }
   10597                 :            : 
   10598                 :            :                 /* Setup source mbuf payload */
   10599         [ #  # ]:          0 :                 if (flags->use_ext_mbuf) {
   10600                 :          0 :                         ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
   10601                 :          0 :                                         td[i].input_text.len, nb_segs, input_text);
   10602                 :            :                 } else {
   10603                 :          0 :                         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
   10604                 :          0 :                                         td[i].input_text.len, nb_segs, 0);
   10605                 :          0 :                         pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
   10606                 :            :                 }
   10607                 :            : 
   10608   [ #  #  #  # ]:          0 :                 if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
   10609                 :          0 :                         ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
   10610                 :            :                                                         ctx);
   10611                 :            :                 else
   10612                 :          0 :                         ret = test_ipsec_proto_crypto_op_enq(ts_params,
   10613                 :            :                                                              ut_params,
   10614                 :            :                                                              &ipsec_xform,
   10615                 :            :                                                              &td[i], flags,
   10616                 :            :                                                              i + 1);
   10617                 :            : 
   10618         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
   10619                 :          0 :                         goto mbuf_free;
   10620                 :            : 
   10621         [ #  # ]:          0 :                 if (res_d != NULL)
   10622                 :          0 :                         res_d_tmp = &res_d[i];
   10623                 :            : 
   10624                 :          0 :                 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
   10625                 :            :                                               res_d_tmp, silent, flags);
   10626         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
   10627                 :          0 :                         goto mbuf_free;
   10628                 :            : 
   10629                 :          0 :                 ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
   10630                 :            :                                               flags, dir);
   10631         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
   10632                 :          0 :                         goto mbuf_free;
   10633                 :            : 
   10634                 :          0 :                 rte_pktmbuf_free(ut_params->ibuf);
   10635                 :          0 :                 ut_params->ibuf = NULL;
   10636                 :            :         }
   10637                 :            : 
   10638                 :          0 : mbuf_free:
   10639         [ #  # ]:          0 :         if (flags->use_ext_mbuf)
   10640                 :          0 :                 ext_mbuf_memzone_free(nb_segs);
   10641                 :            : 
   10642                 :          0 :         rte_pktmbuf_free(ut_params->ibuf);
   10643                 :          0 :         ut_params->ibuf = NULL;
   10644                 :            : 
   10645         [ #  # ]:          0 :         if (ut_params->sec_session)
   10646                 :          0 :                 rte_security_session_destroy(ctx, ut_params->sec_session);
   10647                 :          0 :         ut_params->sec_session = NULL;
   10648                 :            : 
   10649                 :          0 :         return ret;
   10650                 :            : }
   10651                 :            : 
   10652                 :            : static int
   10653         [ #  # ]:          0 : test_ipsec_proto_known_vec(const void *test_data)
   10654                 :            : {
   10655                 :            :         struct ipsec_test_data td_outb;
   10656                 :            :         struct ipsec_test_flags flags;
   10657                 :            : 
   10658                 :            :         memset(&flags, 0, sizeof(flags));
   10659                 :            : 
   10660                 :            :         memcpy(&td_outb, test_data, sizeof(td_outb));
   10661                 :            : 
   10662         [ #  # ]:          0 :         if (td_outb.aes_gmac || td_outb.aead ||
   10663         [ #  # ]:          0 :             ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
   10664         [ #  # ]:          0 :              (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
   10665                 :            :                 /* Disable IV gen to be able to test with known vectors */
   10666                 :          0 :                 td_outb.ipsec_xform.options.iv_gen_disable = 1;
   10667                 :            :         }
   10668                 :            : 
   10669                 :          0 :         return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
   10670                 :            : }
   10671                 :            : 
   10672                 :            : static int
   10673         [ #  # ]:          0 : test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
   10674                 :            : {
   10675                 :            :         struct ipsec_test_data td_outb;
   10676                 :            :         struct ipsec_test_flags flags;
   10677                 :            : 
   10678                 :            :         memset(&flags, 0, sizeof(flags));
   10679         [ #  # ]:          0 :         flags.use_ext_mbuf = true;
   10680                 :            : 
   10681                 :            :         memcpy(&td_outb, test_data, sizeof(td_outb));
   10682                 :            : 
   10683         [ #  # ]:          0 :         if (td_outb.aes_gmac || td_outb.aead ||
   10684         [ #  # ]:          0 :             ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
   10685         [ #  # ]:          0 :              (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
   10686                 :            :                 /* Disable IV gen to be able to test with known vectors */
   10687                 :          0 :                 td_outb.ipsec_xform.options.iv_gen_disable = 1;
   10688                 :            :         }
   10689                 :            : 
   10690                 :          0 :         return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
   10691                 :            : }
   10692                 :            : 
   10693                 :            : static int
   10694         [ #  # ]:          0 : test_ipsec_proto_known_vec_inb(const void *test_data)
   10695                 :            : {
   10696                 :            :         const struct ipsec_test_data *td = test_data;
   10697                 :            :         struct ipsec_test_flags flags;
   10698                 :            :         struct ipsec_test_data td_inb;
   10699                 :            : 
   10700                 :            :         memset(&flags, 0, sizeof(flags));
   10701                 :            : 
   10702         [ #  # ]:          0 :         if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
   10703                 :          0 :                 test_ipsec_td_in_from_out(td, &td_inb);
   10704                 :            :         else
   10705                 :            :                 memcpy(&td_inb, td, sizeof(td_inb));
   10706                 :            : 
   10707                 :          0 :         return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
   10708                 :            : }
   10709                 :            : 
   10710                 :            : static int
   10711                 :          0 : test_ipsec_proto_known_vec_fragmented(const void *test_data)
   10712                 :            : {
   10713                 :            :         struct ipsec_test_data td_outb;
   10714                 :            :         struct ipsec_test_flags flags;
   10715                 :            : 
   10716                 :            :         memset(&flags, 0, sizeof(flags));
   10717                 :          0 :         flags.fragment = true;
   10718                 :            : 
   10719                 :            :         memcpy(&td_outb, test_data, sizeof(td_outb));
   10720                 :            : 
   10721                 :            :         /* Disable IV gen to be able to test with known vectors */
   10722                 :          0 :         td_outb.ipsec_xform.options.iv_gen_disable = 1;
   10723                 :            : 
   10724                 :          0 :         return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
   10725                 :            : }
   10726                 :            : 
   10727                 :            : static int
   10728         [ #  # ]:          0 : test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
   10729                 :            : {
   10730                 :            :         const struct ipsec_test_data *td = test_data;
   10731                 :            :         struct ipsec_test_flags flags;
   10732                 :            :         struct ipsec_test_data td_inb;
   10733                 :            : 
   10734                 :            :         memset(&flags, 0, sizeof(flags));
   10735                 :          0 :         flags.rx_inject = true;
   10736                 :            : 
   10737         [ #  # ]:          0 :         if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
   10738                 :          0 :                 test_ipsec_td_in_from_out(td, &td_inb);
   10739                 :            :         else
   10740                 :            :                 memcpy(&td_inb, td, sizeof(td_inb));
   10741                 :            : 
   10742                 :          0 :         return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
   10743                 :            : }
   10744                 :            : 
   10745                 :            : static int
   10746                 :          0 : test_ipsec_proto_all(const struct ipsec_test_flags *flags)
   10747                 :            : {
   10748                 :            :         struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
   10749                 :            :         struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
   10750                 :            :         unsigned int i, nb_pkts = 1, pass_cnt = 0;
   10751                 :            :         int ret;
   10752                 :            : 
   10753         [ #  # ]:          0 :         if (flags->iv_gen ||
   10754         [ #  # ]:          0 :             flags->sa_expiry_pkts_soft ||
   10755                 :            :             flags->sa_expiry_pkts_hard)
   10756                 :            :                 nb_pkts = TEST_SEC_PKTS_MAX;
   10757                 :            : 
   10758         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
   10759                 :          0 :                 test_ipsec_td_prepare(sec_alg_list[i].param1,
   10760                 :            :                                       sec_alg_list[i].param2,
   10761                 :            :                                       flags,
   10762                 :            :                                       td_outb,
   10763                 :            :                                       nb_pkts);
   10764                 :            : 
   10765         [ #  # ]:          0 :                 if (!td_outb->aead) {
   10766                 :            :                         enum rte_crypto_cipher_algorithm cipher_alg;
   10767                 :            :                         enum rte_crypto_auth_algorithm auth_alg;
   10768                 :            : 
   10769                 :          0 :                         cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
   10770                 :          0 :                         auth_alg = td_outb->xform.chain.auth.auth.algo;
   10771                 :            : 
   10772   [ #  #  #  # ]:          0 :                         if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
   10773                 :          0 :                                 continue;
   10774                 :            : 
   10775                 :            :                         /* ICV is not applicable for NULL auth */
   10776   [ #  #  #  # ]:          0 :                         if (flags->icv_corrupt &&
   10777                 :            :                             auth_alg == RTE_CRYPTO_AUTH_NULL)
   10778                 :          0 :                                 continue;
   10779                 :            : 
   10780                 :            :                         /* IV is not applicable for NULL cipher */
   10781   [ #  #  #  # ]:          0 :                         if (flags->iv_gen &&
   10782                 :            :                             cipher_alg == RTE_CRYPTO_CIPHER_NULL)
   10783                 :          0 :                                 continue;
   10784                 :            :                 }
   10785                 :            : 
   10786                 :          0 :                 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
   10787                 :            :                                                flags);
   10788         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   10789                 :          0 :                         continue;
   10790                 :            : 
   10791         [ #  # ]:          0 :                 if (ret == TEST_FAILED)
   10792                 :            :                         return TEST_FAILED;
   10793                 :            : 
   10794                 :          0 :                 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
   10795                 :            : 
   10796                 :          0 :                 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
   10797                 :            :                                                flags);
   10798         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   10799                 :          0 :                         continue;
   10800                 :            : 
   10801         [ #  # ]:          0 :                 if (ret == TEST_FAILED)
   10802                 :            :                         return TEST_FAILED;
   10803                 :            : 
   10804         [ #  # ]:          0 :                 if (flags->display_alg)
   10805                 :          0 :                         test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
   10806                 :            : 
   10807                 :          0 :                 pass_cnt++;
   10808                 :            :         }
   10809                 :            : 
   10810         [ #  # ]:          0 :         if (pass_cnt > 0)
   10811                 :            :                 return TEST_SUCCESS;
   10812                 :            :         else
   10813                 :          0 :                 return TEST_SKIPPED;
   10814                 :            : }
   10815                 :            : 
   10816                 :            : static int
   10817                 :          0 : test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
   10818                 :            : {
   10819                 :            :         struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
   10820                 :            :         struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
   10821                 :            :         unsigned int i, nb_pkts = 1, pass_cnt = 0;
   10822                 :            :         int ret;
   10823                 :            : 
   10824         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
   10825                 :          0 :                 test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
   10826                 :            :                                       sec_auth_only_alg_list[i].param2,
   10827                 :            :                                       flags,
   10828                 :            :                                       td_outb,
   10829                 :            :                                       nb_pkts);
   10830                 :            : 
   10831                 :          0 :                 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
   10832                 :            :                                                flags);
   10833         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   10834                 :          0 :                         continue;
   10835                 :            : 
   10836         [ #  # ]:          0 :                 if (ret == TEST_FAILED)
   10837                 :            :                         return TEST_FAILED;
   10838                 :            : 
   10839                 :          0 :                 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
   10840                 :            : 
   10841                 :          0 :                 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
   10842                 :            :                                                flags);
   10843         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   10844                 :          0 :                         continue;
   10845                 :            : 
   10846         [ #  # ]:          0 :                 if (ret == TEST_FAILED)
   10847                 :            :                         return TEST_FAILED;
   10848                 :            : 
   10849         [ #  # ]:          0 :                 if (flags->display_alg)
   10850                 :          0 :                         test_sec_alg_display(sec_auth_only_alg_list[i].param1,
   10851                 :            :                                              sec_auth_only_alg_list[i].param2);
   10852                 :            : 
   10853                 :          0 :                 pass_cnt++;
   10854                 :            :         }
   10855                 :            : 
   10856         [ #  # ]:          0 :         if (pass_cnt > 0)
   10857                 :            :                 return TEST_SUCCESS;
   10858                 :            :         else
   10859                 :          0 :                 return TEST_SKIPPED;
   10860                 :            : }
   10861                 :            : 
   10862                 :            : static int
   10863                 :          0 : test_ipsec_proto_display_list(void)
   10864                 :            : {
   10865                 :            :         struct ipsec_test_flags flags;
   10866                 :            : 
   10867                 :            :         memset(&flags, 0, sizeof(flags));
   10868                 :            : 
   10869                 :          0 :         flags.display_alg = true;
   10870                 :            : 
   10871                 :          0 :         return test_ipsec_proto_all(&flags);
   10872                 :            : }
   10873                 :            : 
   10874                 :            : static int
   10875                 :          0 : test_ipsec_proto_ah_tunnel_ipv4(void)
   10876                 :            : {
   10877                 :            :         struct ipsec_test_flags flags;
   10878                 :            : 
   10879                 :            :         memset(&flags, 0, sizeof(flags));
   10880                 :            : 
   10881                 :          0 :         flags.ah = true;
   10882                 :          0 :         flags.display_alg = true;
   10883                 :            : 
   10884                 :          0 :         return test_ipsec_ah_proto_all(&flags);
   10885                 :            : }
   10886                 :            : 
   10887                 :            : static int
   10888                 :          0 : test_ipsec_proto_ah_transport_ipv4(void)
   10889                 :            : {
   10890                 :            :         struct ipsec_test_flags flags;
   10891                 :            : 
   10892                 :            :         memset(&flags, 0, sizeof(flags));
   10893                 :            : 
   10894                 :          0 :         flags.ah = true;
   10895                 :          0 :         flags.transport = true;
   10896                 :            : 
   10897                 :          0 :         return test_ipsec_ah_proto_all(&flags);
   10898                 :            : }
   10899                 :            : 
   10900                 :            : static int
   10901                 :          0 : test_ipsec_proto_iv_gen(void)
   10902                 :            : {
   10903                 :            :         struct ipsec_test_flags flags;
   10904                 :            : 
   10905                 :            :         memset(&flags, 0, sizeof(flags));
   10906                 :            : 
   10907                 :          0 :         flags.iv_gen = true;
   10908                 :            : 
   10909                 :          0 :         return test_ipsec_proto_all(&flags);
   10910                 :            : }
   10911                 :            : 
   10912                 :            : static int
   10913                 :          0 : test_ipsec_proto_sa_exp_pkts_soft(void)
   10914                 :            : {
   10915                 :            :         struct ipsec_test_flags flags;
   10916                 :            : 
   10917                 :            :         memset(&flags, 0, sizeof(flags));
   10918                 :            : 
   10919                 :          0 :         flags.sa_expiry_pkts_soft = true;
   10920                 :            : 
   10921                 :          0 :         return test_ipsec_proto_all(&flags);
   10922                 :            : }
   10923                 :            : 
   10924                 :            : static int
   10925                 :          0 : test_ipsec_proto_sa_exp_pkts_hard(void)
   10926                 :            : {
   10927                 :            :         struct ipsec_test_flags flags;
   10928                 :            : 
   10929                 :            :         memset(&flags, 0, sizeof(flags));
   10930                 :            : 
   10931                 :          0 :         flags.sa_expiry_pkts_hard = true;
   10932                 :            : 
   10933                 :          0 :         return test_ipsec_proto_all(&flags);
   10934                 :            : }
   10935                 :            : 
   10936                 :            : static int
   10937                 :          0 : test_ipsec_proto_err_icv_corrupt(void)
   10938                 :            : {
   10939                 :            :         struct ipsec_test_flags flags;
   10940                 :            : 
   10941                 :            :         memset(&flags, 0, sizeof(flags));
   10942                 :            : 
   10943                 :          0 :         flags.icv_corrupt = true;
   10944                 :            : 
   10945                 :          0 :         return test_ipsec_proto_all(&flags);
   10946                 :            : }
   10947                 :            : 
   10948                 :            : static int
   10949                 :          0 : test_ipsec_proto_udp_encap_custom_ports(void)
   10950                 :            : {
   10951                 :            :         struct ipsec_test_flags flags;
   10952                 :            : 
   10953         [ #  # ]:          0 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   10954                 :            :                         RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
   10955                 :            :                 return TEST_SKIPPED;
   10956                 :            : 
   10957                 :            :         memset(&flags, 0, sizeof(flags));
   10958                 :            : 
   10959                 :          0 :         flags.udp_encap = true;
   10960                 :          0 :         flags.udp_encap_custom_ports = true;
   10961                 :            : 
   10962                 :          0 :         return test_ipsec_proto_all(&flags);
   10963                 :            : }
   10964                 :            : 
   10965                 :            : static int
   10966                 :          0 : test_ipsec_proto_udp_encap(void)
   10967                 :            : {
   10968                 :            :         struct ipsec_test_flags flags;
   10969                 :            : 
   10970                 :            :         memset(&flags, 0, sizeof(flags));
   10971                 :            : 
   10972                 :          0 :         flags.udp_encap = true;
   10973                 :            : 
   10974                 :          0 :         return test_ipsec_proto_all(&flags);
   10975                 :            : }
   10976                 :            : 
   10977                 :            : static int
   10978                 :          0 : test_ipsec_proto_tunnel_src_dst_addr_verify(void)
   10979                 :            : {
   10980                 :            :         struct ipsec_test_flags flags;
   10981                 :            : 
   10982                 :            :         memset(&flags, 0, sizeof(flags));
   10983                 :            : 
   10984                 :          0 :         flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
   10985                 :            : 
   10986                 :          0 :         return test_ipsec_proto_all(&flags);
   10987                 :            : }
   10988                 :            : 
   10989                 :            : static int
   10990                 :          0 : test_ipsec_proto_tunnel_dst_addr_verify(void)
   10991                 :            : {
   10992                 :            :         struct ipsec_test_flags flags;
   10993                 :            : 
   10994                 :            :         memset(&flags, 0, sizeof(flags));
   10995                 :            : 
   10996                 :          0 :         flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
   10997                 :            : 
   10998                 :          0 :         return test_ipsec_proto_all(&flags);
   10999                 :            : }
   11000                 :            : 
   11001                 :            : static int
   11002                 :          0 : test_ipsec_proto_udp_ports_verify(void)
   11003                 :            : {
   11004                 :            :         struct ipsec_test_flags flags;
   11005                 :            : 
   11006                 :            :         memset(&flags, 0, sizeof(flags));
   11007                 :            : 
   11008                 :          0 :         flags.udp_encap = true;
   11009                 :          0 :         flags.udp_ports_verify = true;
   11010                 :            : 
   11011                 :          0 :         return test_ipsec_proto_all(&flags);
   11012                 :            : }
   11013                 :            : 
   11014                 :            : static int
   11015                 :          0 : test_ipsec_proto_inner_ip_csum(void)
   11016                 :            : {
   11017                 :            :         struct ipsec_test_flags flags;
   11018                 :            : 
   11019                 :            :         memset(&flags, 0, sizeof(flags));
   11020                 :            : 
   11021                 :          0 :         flags.ip_csum = true;
   11022                 :            : 
   11023                 :          0 :         return test_ipsec_proto_all(&flags);
   11024                 :            : }
   11025                 :            : 
   11026                 :            : static int
   11027                 :          0 : test_ipsec_proto_inner_l4_csum(void)
   11028                 :            : {
   11029                 :            :         struct ipsec_test_flags flags;
   11030                 :            : 
   11031                 :            :         memset(&flags, 0, sizeof(flags));
   11032                 :            : 
   11033                 :          0 :         flags.l4_csum = true;
   11034                 :            : 
   11035                 :          0 :         return test_ipsec_proto_all(&flags);
   11036                 :            : }
   11037                 :            : 
   11038                 :            : static int
   11039                 :          0 : test_ipsec_proto_tunnel_v4_in_v4(void)
   11040                 :            : {
   11041                 :            :         struct ipsec_test_flags flags;
   11042                 :            : 
   11043                 :            :         memset(&flags, 0, sizeof(flags));
   11044                 :            : 
   11045                 :            :         flags.ipv6 = false;
   11046                 :            :         flags.tunnel_ipv6 = false;
   11047                 :            : 
   11048                 :          0 :         return test_ipsec_proto_all(&flags);
   11049                 :            : }
   11050                 :            : 
   11051                 :            : static int
   11052                 :          0 : test_ipsec_proto_tunnel_v6_in_v6(void)
   11053                 :            : {
   11054                 :            :         struct ipsec_test_flags flags;
   11055                 :            : 
   11056                 :            :         memset(&flags, 0, sizeof(flags));
   11057                 :            : 
   11058                 :          0 :         flags.ipv6 = true;
   11059                 :          0 :         flags.tunnel_ipv6 = true;
   11060                 :            : 
   11061                 :          0 :         return test_ipsec_proto_all(&flags);
   11062                 :            : }
   11063                 :            : 
   11064                 :            : static int
   11065                 :          0 : test_ipsec_proto_tunnel_v4_in_v6(void)
   11066                 :            : {
   11067                 :            :         struct ipsec_test_flags flags;
   11068                 :            : 
   11069                 :            :         memset(&flags, 0, sizeof(flags));
   11070                 :            : 
   11071                 :            :         flags.ipv6 = false;
   11072                 :          0 :         flags.tunnel_ipv6 = true;
   11073                 :            : 
   11074                 :          0 :         return test_ipsec_proto_all(&flags);
   11075                 :            : }
   11076                 :            : 
   11077                 :            : static int
   11078                 :          0 : test_ipsec_proto_tunnel_v6_in_v4(void)
   11079                 :            : {
   11080                 :            :         struct ipsec_test_flags flags;
   11081                 :            : 
   11082                 :            :         memset(&flags, 0, sizeof(flags));
   11083                 :            : 
   11084                 :          0 :         flags.ipv6 = true;
   11085                 :            :         flags.tunnel_ipv6 = false;
   11086                 :            : 
   11087                 :          0 :         return test_ipsec_proto_all(&flags);
   11088                 :            : }
   11089                 :            : 
   11090                 :            : static int
   11091                 :          0 : test_ipsec_proto_transport_v4(void)
   11092                 :            : {
   11093                 :            :         struct ipsec_test_flags flags;
   11094                 :            : 
   11095                 :            :         memset(&flags, 0, sizeof(flags));
   11096                 :            : 
   11097                 :            :         flags.ipv6 = false;
   11098                 :          0 :         flags.transport = true;
   11099                 :            : 
   11100                 :          0 :         return test_ipsec_proto_all(&flags);
   11101                 :            : }
   11102                 :            : 
   11103                 :            : static int
   11104                 :          0 : test_ipsec_proto_transport_l4_csum(void)
   11105                 :            : {
   11106                 :          0 :         struct ipsec_test_flags flags = {
   11107                 :            :                 .l4_csum = true,
   11108                 :            :                 .transport = true,
   11109                 :            :         };
   11110                 :            : 
   11111                 :          0 :         return test_ipsec_proto_all(&flags);
   11112                 :            : }
   11113                 :            : 
   11114                 :            : static int
   11115                 :          0 : test_ipsec_proto_stats(void)
   11116                 :            : {
   11117                 :            :         struct ipsec_test_flags flags;
   11118                 :            : 
   11119                 :            :         memset(&flags, 0, sizeof(flags));
   11120                 :            : 
   11121                 :          0 :         flags.stats_success = true;
   11122                 :            : 
   11123                 :          0 :         return test_ipsec_proto_all(&flags);
   11124                 :            : }
   11125                 :            : 
   11126                 :            : static int
   11127                 :          0 : test_ipsec_proto_pkt_fragment(void)
   11128                 :            : {
   11129                 :            :         struct ipsec_test_flags flags;
   11130                 :            : 
   11131                 :            :         memset(&flags, 0, sizeof(flags));
   11132                 :            : 
   11133                 :          0 :         flags.fragment = true;
   11134                 :            : 
   11135                 :          0 :         return test_ipsec_proto_all(&flags);
   11136                 :            : 
   11137                 :            : }
   11138                 :            : 
   11139                 :            : static int
   11140                 :          0 : test_ipsec_proto_copy_df_inner_0(void)
   11141                 :            : {
   11142                 :            :         struct ipsec_test_flags flags;
   11143                 :            : 
   11144                 :            :         memset(&flags, 0, sizeof(flags));
   11145                 :            : 
   11146                 :          0 :         flags.df = TEST_IPSEC_COPY_DF_INNER_0;
   11147                 :            : 
   11148                 :          0 :         return test_ipsec_proto_all(&flags);
   11149                 :            : }
   11150                 :            : 
   11151                 :            : static int
   11152                 :          0 : test_ipsec_proto_copy_df_inner_1(void)
   11153                 :            : {
   11154                 :            :         struct ipsec_test_flags flags;
   11155                 :            : 
   11156                 :            :         memset(&flags, 0, sizeof(flags));
   11157                 :            : 
   11158                 :          0 :         flags.df = TEST_IPSEC_COPY_DF_INNER_1;
   11159                 :            : 
   11160                 :          0 :         return test_ipsec_proto_all(&flags);
   11161                 :            : }
   11162                 :            : 
   11163                 :            : static int
   11164                 :          0 : test_ipsec_proto_set_df_0_inner_1(void)
   11165                 :            : {
   11166                 :            :         struct ipsec_test_flags flags;
   11167                 :            : 
   11168                 :            :         memset(&flags, 0, sizeof(flags));
   11169                 :            : 
   11170                 :          0 :         flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
   11171                 :            : 
   11172                 :          0 :         return test_ipsec_proto_all(&flags);
   11173                 :            : }
   11174                 :            : 
   11175                 :            : static int
   11176                 :          0 : test_ipsec_proto_set_df_1_inner_0(void)
   11177                 :            : {
   11178                 :            :         struct ipsec_test_flags flags;
   11179                 :            : 
   11180                 :            :         memset(&flags, 0, sizeof(flags));
   11181                 :            : 
   11182                 :          0 :         flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
   11183                 :            : 
   11184                 :          0 :         return test_ipsec_proto_all(&flags);
   11185                 :            : }
   11186                 :            : 
   11187                 :            : static int
   11188                 :          0 : test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
   11189                 :            : {
   11190                 :            :         struct ipsec_test_flags flags;
   11191                 :            : 
   11192                 :            :         memset(&flags, 0, sizeof(flags));
   11193                 :            : 
   11194                 :          0 :         flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
   11195                 :            : 
   11196                 :          0 :         return test_ipsec_proto_all(&flags);
   11197                 :            : }
   11198                 :            : 
   11199                 :            : static int
   11200                 :          0 : test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
   11201                 :            : {
   11202                 :            :         struct ipsec_test_flags flags;
   11203                 :            : 
   11204                 :            :         memset(&flags, 0, sizeof(flags));
   11205                 :            : 
   11206                 :          0 :         flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
   11207                 :            : 
   11208                 :          0 :         return test_ipsec_proto_all(&flags);
   11209                 :            : }
   11210                 :            : 
   11211                 :            : static int
   11212                 :          0 : test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
   11213                 :            : {
   11214                 :            :         struct ipsec_test_flags flags;
   11215                 :            : 
   11216         [ #  # ]:          0 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   11217                 :            :                         RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
   11218                 :            :                 return TEST_SKIPPED;
   11219                 :            : 
   11220                 :            :         memset(&flags, 0, sizeof(flags));
   11221                 :            : 
   11222                 :          0 :         flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
   11223                 :            : 
   11224                 :          0 :         return test_ipsec_proto_all(&flags);
   11225                 :            : }
   11226                 :            : 
   11227                 :            : static int
   11228                 :          0 : test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
   11229                 :            : {
   11230                 :            :         struct ipsec_test_flags flags;
   11231                 :            : 
   11232         [ #  # ]:          0 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   11233                 :            :                         RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
   11234                 :            :                 return TEST_SKIPPED;
   11235                 :            : 
   11236                 :            :         memset(&flags, 0, sizeof(flags));
   11237                 :            : 
   11238                 :          0 :         flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
   11239                 :            : 
   11240                 :          0 :         return test_ipsec_proto_all(&flags);
   11241                 :            : }
   11242                 :            : 
   11243                 :            : static int
   11244                 :          0 : test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
   11245                 :            : {
   11246                 :            :         struct ipsec_test_flags flags;
   11247                 :            : 
   11248                 :            :         memset(&flags, 0, sizeof(flags));
   11249                 :            : 
   11250                 :          0 :         flags.ipv6 = true;
   11251                 :          0 :         flags.tunnel_ipv6 = true;
   11252                 :          0 :         flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
   11253                 :            : 
   11254                 :          0 :         return test_ipsec_proto_all(&flags);
   11255                 :            : }
   11256                 :            : 
   11257                 :            : static int
   11258                 :          0 : test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
   11259                 :            : {
   11260                 :            :         struct ipsec_test_flags flags;
   11261                 :            : 
   11262                 :            :         memset(&flags, 0, sizeof(flags));
   11263                 :            : 
   11264                 :          0 :         flags.ipv6 = true;
   11265                 :          0 :         flags.tunnel_ipv6 = true;
   11266                 :          0 :         flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
   11267                 :            : 
   11268                 :          0 :         return test_ipsec_proto_all(&flags);
   11269                 :            : }
   11270                 :            : 
   11271                 :            : static int
   11272                 :          0 : test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
   11273                 :            : {
   11274                 :            :         struct ipsec_test_flags flags;
   11275                 :            : 
   11276         [ #  # ]:          0 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   11277                 :            :                         RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
   11278                 :            :                 return TEST_SKIPPED;
   11279                 :            : 
   11280                 :            :         memset(&flags, 0, sizeof(flags));
   11281                 :            : 
   11282                 :          0 :         flags.ipv6 = true;
   11283                 :          0 :         flags.tunnel_ipv6 = true;
   11284                 :          0 :         flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
   11285                 :            : 
   11286                 :          0 :         return test_ipsec_proto_all(&flags);
   11287                 :            : }
   11288                 :            : 
   11289                 :            : static int
   11290                 :          0 : test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
   11291                 :            : {
   11292                 :            :         struct ipsec_test_flags flags;
   11293                 :            : 
   11294         [ #  # ]:          0 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   11295                 :            :                         RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
   11296                 :            :                 return TEST_SKIPPED;
   11297                 :            : 
   11298                 :            :         memset(&flags, 0, sizeof(flags));
   11299                 :            : 
   11300                 :          0 :         flags.ipv6 = true;
   11301                 :          0 :         flags.tunnel_ipv6 = true;
   11302                 :          0 :         flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
   11303                 :            : 
   11304                 :          0 :         return test_ipsec_proto_all(&flags);
   11305                 :            : }
   11306                 :            : 
   11307                 :            : static int
   11308                 :          0 : test_ipsec_proto_sgl(void)
   11309                 :            : {
   11310                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   11311                 :            :         struct rte_cryptodev_info dev_info;
   11312                 :            : 
   11313                 :          0 :         struct ipsec_test_flags flags = {
   11314                 :            :                 .nb_segs_in_mbuf = 5
   11315                 :            :         };
   11316                 :            : 
   11317                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   11318         [ #  # ]:          0 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
   11319                 :            :                 printf("Device doesn't support in-place scatter-gather. "
   11320                 :            :                                 "Test Skipped.\n");
   11321                 :          0 :                 return TEST_SKIPPED;
   11322                 :            :         }
   11323                 :            : 
   11324                 :          0 :         return test_ipsec_proto_all(&flags);
   11325                 :            : }
   11326                 :            : 
   11327                 :            : static int
   11328                 :          0 : test_ipsec_proto_sgl_ext_mbuf(void)
   11329                 :            : {
   11330                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   11331                 :            :         struct rte_cryptodev_info dev_info;
   11332                 :            : 
   11333                 :          0 :         struct ipsec_test_flags flags = {
   11334                 :            :                 .nb_segs_in_mbuf = 5,
   11335                 :            :                 .use_ext_mbuf = 1
   11336                 :            :         };
   11337                 :            : 
   11338                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   11339         [ #  # ]:          0 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
   11340                 :            :                 printf("Device doesn't support in-place scatter-gather. "
   11341                 :            :                                 "Test Skipped.\n");
   11342                 :          0 :                 return TEST_SKIPPED;
   11343                 :            :         }
   11344                 :            : 
   11345                 :          0 :         return test_ipsec_proto_all(&flags);
   11346                 :            : }
   11347                 :            : 
   11348                 :            : static int
   11349                 :          0 : test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
   11350                 :            :                       bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
   11351                 :            :                       uint64_t winsz)
   11352                 :            : {
   11353                 :            :         struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
   11354                 :            :         struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
   11355                 :            :         struct ipsec_test_flags flags;
   11356                 :            :         uint32_t i = 0, ret = 0;
   11357                 :            : 
   11358         [ #  # ]:          0 :         if (nb_pkts == 0)
   11359                 :            :                 return TEST_FAILED;
   11360                 :            : 
   11361                 :            :         memset(&flags, 0, sizeof(flags));
   11362                 :          0 :         flags.antireplay = true;
   11363                 :            : 
   11364         [ #  # ]:          0 :         for (i = 0; i < nb_pkts; i++) {
   11365                 :          0 :                 memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
   11366                 :          0 :                 td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
   11367                 :          0 :                 td_outb[i].ipsec_xform.replay_win_sz = winsz;
   11368                 :          0 :                 td_outb[i].ipsec_xform.options.esn = esn_en;
   11369                 :            :         }
   11370                 :            : 
   11371         [ #  # ]:          0 :         for (i = 0; i < nb_pkts; i++)
   11372                 :          0 :                 td_outb[i].ipsec_xform.esn.value = esn[i];
   11373                 :            : 
   11374                 :          0 :         ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
   11375                 :            :                                        &flags);
   11376         [ #  # ]:          0 :         if (ret != TEST_SUCCESS)
   11377                 :            :                 return ret;
   11378                 :            : 
   11379                 :          0 :         test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
   11380                 :            : 
   11381         [ #  # ]:          0 :         for (i = 0; i < nb_pkts; i++) {
   11382                 :          0 :                 td_inb[i].ipsec_xform.options.esn = esn_en;
   11383                 :            :                 /* Set antireplay flag for packets to be dropped */
   11384                 :          0 :                 td_inb[i].ar_packet = replayed_pkt[i];
   11385                 :            :         }
   11386                 :            : 
   11387                 :          0 :         ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
   11388                 :            :                                        &flags);
   11389                 :            : 
   11390                 :          0 :         return ret;
   11391                 :            : }
   11392                 :            : 
   11393                 :            : static int
   11394                 :          0 : test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
   11395                 :            : {
   11396                 :            : 
   11397                 :            :         uint32_t nb_pkts = 5;
   11398                 :            :         bool replayed_pkt[5];
   11399                 :            :         uint64_t esn[5];
   11400                 :            : 
   11401                 :            :         /* 1. Advance the TOP of the window to WS * 2 */
   11402                 :          0 :         esn[0] = winsz * 2;
   11403                 :            :         /* 2. Test sequence number within the new window(WS + 1) */
   11404                 :          0 :         esn[1] = winsz + 1;
   11405                 :            :         /* 3. Test sequence number less than the window BOTTOM */
   11406                 :          0 :         esn[2] = winsz;
   11407                 :            :         /* 4. Test sequence number in the middle of the window */
   11408                 :          0 :         esn[3] = winsz + (winsz / 2);
   11409                 :            :         /* 5. Test replay of the packet in the middle of the window */
   11410                 :          0 :         esn[4] = winsz + (winsz / 2);
   11411                 :            : 
   11412                 :          0 :         replayed_pkt[0] = false;
   11413                 :          0 :         replayed_pkt[1] = false;
   11414                 :          0 :         replayed_pkt[2] = true;
   11415                 :          0 :         replayed_pkt[3] = false;
   11416                 :          0 :         replayed_pkt[4] = true;
   11417                 :            : 
   11418                 :          0 :         return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
   11419                 :            :                                      false, winsz);
   11420                 :            : }
   11421                 :            : 
   11422                 :            : static int
   11423                 :          0 : test_ipsec_proto_pkt_antireplay1024(const void *test_data)
   11424                 :            : {
   11425                 :          0 :         return test_ipsec_proto_pkt_antireplay(test_data, 1024);
   11426                 :            : }
   11427                 :            : 
   11428                 :            : static int
   11429                 :          0 : test_ipsec_proto_pkt_antireplay2048(const void *test_data)
   11430                 :            : {
   11431                 :          0 :         return test_ipsec_proto_pkt_antireplay(test_data, 2048);
   11432                 :            : }
   11433                 :            : 
   11434                 :            : static int
   11435                 :          0 : test_ipsec_proto_pkt_antireplay4096(const void *test_data)
   11436                 :            : {
   11437                 :          0 :         return test_ipsec_proto_pkt_antireplay(test_data, 4096);
   11438                 :            : }
   11439                 :            : 
   11440                 :            : static int
   11441                 :          0 : test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
   11442                 :            : {
   11443                 :            : 
   11444                 :            :         uint32_t nb_pkts = 7;
   11445                 :            :         bool replayed_pkt[7];
   11446                 :            :         uint64_t esn[7];
   11447                 :            : 
   11448                 :            :         /* Set the initial sequence number */
   11449                 :          0 :         esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
   11450                 :            :         /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
   11451                 :          0 :         esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
   11452                 :            :         /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
   11453                 :          0 :         esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
   11454                 :            :         /* 3. Test with sequence number within window (1<<32 - 1) */
   11455                 :          0 :         esn[3] = (uint64_t)((1ULL << 32) - 1);
   11456                 :            :         /* 4. Test with sequence number within window (1<<32 - 1) */
   11457                 :          0 :         esn[4] = (uint64_t)(1ULL << 32);
   11458                 :            :         /* 5. Test with duplicate sequence number within
   11459                 :            :          * new window (1<<32 - 1)
   11460                 :            :          */
   11461                 :          0 :         esn[5] = (uint64_t)((1ULL << 32) - 1);
   11462                 :            :         /* 6. Test with duplicate sequence number within new window (1<<32) */
   11463                 :          0 :         esn[6] = (uint64_t)(1ULL << 32);
   11464                 :            : 
   11465                 :          0 :         replayed_pkt[0] = false;
   11466                 :          0 :         replayed_pkt[1] = false;
   11467                 :          0 :         replayed_pkt[2] = false;
   11468                 :          0 :         replayed_pkt[3] = false;
   11469                 :          0 :         replayed_pkt[4] = false;
   11470                 :          0 :         replayed_pkt[5] = true;
   11471                 :          0 :         replayed_pkt[6] = true;
   11472                 :            : 
   11473                 :          0 :         return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
   11474                 :            :                                      true, winsz);
   11475                 :            : }
   11476                 :            : 
   11477                 :            : static int
   11478                 :          0 : test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
   11479                 :            : {
   11480                 :          0 :         return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
   11481                 :            : }
   11482                 :            : 
   11483                 :            : static int
   11484                 :          0 : test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
   11485                 :            : {
   11486                 :          0 :         return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
   11487                 :            : }
   11488                 :            : 
   11489                 :            : static int
   11490                 :          0 : test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
   11491                 :            : {
   11492                 :          0 :         return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
   11493                 :            : }
   11494                 :            : 
   11495                 :            : static int
   11496                 :          0 : test_PDCP_PROTO_all(void)
   11497                 :            : {
   11498                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   11499                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   11500                 :            :         struct rte_cryptodev_info dev_info;
   11501                 :            :         int status;
   11502                 :            : 
   11503                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   11504                 :          0 :         uint64_t feat_flags = dev_info.feature_flags;
   11505                 :            : 
   11506         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
   11507                 :            :                 return TEST_SKIPPED;
   11508                 :            : 
   11509                 :            :         /* Set action type */
   11510                 :          0 :         ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
   11511         [ #  # ]:          0 :                 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
   11512                 :            :                 gbl_action_type;
   11513                 :            : 
   11514         [ #  # ]:          0 :         if (security_proto_supported(ut_params->type,
   11515                 :            :                         RTE_SECURITY_PROTOCOL_PDCP) < 0)
   11516                 :            :                 return TEST_SKIPPED;
   11517                 :            : 
   11518                 :          0 :         status = test_PDCP_PROTO_cplane_encap_all();
   11519                 :          0 :         status += test_PDCP_PROTO_cplane_decap_all();
   11520                 :          0 :         status += test_PDCP_PROTO_uplane_encap_all();
   11521                 :          0 :         status += test_PDCP_PROTO_uplane_decap_all();
   11522                 :          0 :         status += test_PDCP_PROTO_SGL_in_place_32B();
   11523                 :          0 :         status += test_PDCP_PROTO_SGL_oop_32B_128B();
   11524                 :          0 :         status += test_PDCP_PROTO_SGL_oop_32B_40B();
   11525                 :          0 :         status += test_PDCP_PROTO_SGL_oop_128B_32B();
   11526                 :          0 :         status += test_PDCP_SDAP_PROTO_encap_all();
   11527                 :          0 :         status += test_PDCP_SDAP_PROTO_decap_all();
   11528                 :          0 :         status += test_PDCP_PROTO_short_mac();
   11529                 :            : 
   11530         [ #  # ]:          0 :         if (status)
   11531                 :            :                 return TEST_FAILED;
   11532                 :            :         else
   11533                 :          0 :                 return TEST_SUCCESS;
   11534                 :            : }
   11535                 :            : 
   11536                 :            : static int
   11537                 :          0 : test_ipsec_proto_ipv4_ttl_decrement(void)
   11538                 :            : {
   11539                 :          0 :         struct ipsec_test_flags flags = {
   11540                 :            :                 .dec_ttl_or_hop_limit = true
   11541                 :            :         };
   11542                 :            : 
   11543                 :          0 :         return test_ipsec_proto_all(&flags);
   11544                 :            : }
   11545                 :            : 
   11546                 :            : static int
   11547                 :          0 : test_ipsec_proto_ipv6_hop_limit_decrement(void)
   11548                 :            : {
   11549                 :          0 :         struct ipsec_test_flags flags = {
   11550                 :            :                 .ipv6 = true,
   11551                 :            :                 .dec_ttl_or_hop_limit = true
   11552                 :            :         };
   11553                 :            : 
   11554                 :          0 :         return test_ipsec_proto_all(&flags);
   11555                 :            : }
   11556                 :            : 
   11557                 :            : static int
   11558                 :          0 : test_docsis_proto_uplink(const void *data)
   11559                 :            : {
   11560                 :            :         const struct docsis_test_data *d_td = data;
   11561                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   11562                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   11563                 :            :         uint8_t *plaintext = NULL;
   11564                 :            :         uint8_t *ciphertext = NULL;
   11565                 :            :         uint8_t *iv_ptr;
   11566                 :            :         int32_t cipher_len, crc_len;
   11567                 :            :         uint32_t crc_data_len;
   11568                 :            :         int ret = TEST_SUCCESS;
   11569                 :            : 
   11570                 :          0 :         void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
   11571                 :            : 
   11572                 :            :         /* Verify the capabilities */
   11573                 :            :         struct rte_security_capability_idx sec_cap_idx;
   11574                 :            :         const struct rte_security_capability *sec_cap;
   11575                 :            :         const struct rte_cryptodev_capabilities *crypto_cap;
   11576                 :            :         const struct rte_cryptodev_symmetric_capability *sym_cap;
   11577                 :            :         int j = 0;
   11578                 :            : 
   11579                 :            :         /* Set action type */
   11580                 :          0 :         ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
   11581         [ #  # ]:          0 :                 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
   11582                 :            :                 gbl_action_type;
   11583                 :            : 
   11584         [ #  # ]:          0 :         if (security_proto_supported(ut_params->type,
   11585                 :            :                         RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
   11586                 :            :                 return TEST_SKIPPED;
   11587                 :            : 
   11588                 :          0 :         sec_cap_idx.action = ut_params->type;
   11589                 :          0 :         sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
   11590                 :          0 :         sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
   11591                 :            : 
   11592                 :          0 :         sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
   11593         [ #  # ]:          0 :         if (sec_cap == NULL)
   11594                 :            :                 return TEST_SKIPPED;
   11595                 :            : 
   11596         [ #  # ]:          0 :         while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
   11597                 :            :                         RTE_CRYPTO_OP_TYPE_UNDEFINED) {
   11598         [ #  # ]:          0 :                 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
   11599                 :            :                                 crypto_cap->sym.xform_type ==
   11600         [ #  # ]:          0 :                                         RTE_CRYPTO_SYM_XFORM_CIPHER &&
   11601                 :            :                                 crypto_cap->sym.cipher.algo ==
   11602                 :            :                                         RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
   11603                 :          0 :                         sym_cap = &crypto_cap->sym;
   11604         [ #  # ]:          0 :                         if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
   11605                 :          0 :                                                 d_td->key.len,
   11606                 :          0 :                                                 d_td->iv.len) == 0)
   11607                 :            :                                 break;
   11608                 :            :                 }
   11609                 :            :         }
   11610                 :            : 
   11611         [ #  # ]:          0 :         if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
   11612                 :            :                 return TEST_SKIPPED;
   11613                 :            : 
   11614                 :            :         /* Setup source mbuf payload */
   11615                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   11616                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   11617                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   11618                 :            : 
   11619                 :          0 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   11620                 :          0 :                         d_td->ciphertext.len);
   11621                 :            : 
   11622                 :          0 :         memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
   11623                 :            : 
   11624                 :            :         /* Setup cipher session parameters */
   11625                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   11626                 :          0 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
   11627                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
   11628                 :          0 :         ut_params->cipher_xform.cipher.key.data = d_td->key.data;
   11629                 :          0 :         ut_params->cipher_xform.cipher.key.length = d_td->key.len;
   11630                 :          0 :         ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
   11631                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   11632                 :          0 :         ut_params->cipher_xform.next = NULL;
   11633                 :            : 
   11634                 :            :         /* Setup DOCSIS session parameters */
   11635                 :          0 :         ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
   11636                 :            : 
   11637                 :          0 :         struct rte_security_session_conf sess_conf = {
   11638                 :          0 :                 .action_type = ut_params->type,
   11639                 :            :                 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
   11640                 :            :                 .docsis = ut_params->docsis_xform,
   11641                 :            :                 .crypto_xform = &ut_params->cipher_xform,
   11642                 :            :         };
   11643                 :            : 
   11644                 :            :         /* Create security session */
   11645                 :          0 :         ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
   11646                 :            :                                         ts_params->session_mpool);
   11647                 :            : 
   11648         [ #  # ]:          0 :         if (!ut_params->sec_session) {
   11649                 :            :                 printf("Test function %s line %u: failed to allocate session\n",
   11650                 :            :                         __func__, __LINE__);
   11651                 :            :                 ret = TEST_FAILED;
   11652                 :          0 :                 goto on_err;
   11653                 :            :         }
   11654                 :            : 
   11655                 :            :         /* Generate crypto op data structure */
   11656                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   11657                 :            :                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   11658         [ #  # ]:          0 :         if (!ut_params->op) {
   11659                 :            :                 printf("Test function %s line %u: failed to allocate symmetric "
   11660                 :            :                         "crypto operation\n", __func__, __LINE__);
   11661                 :            :                 ret = TEST_FAILED;
   11662                 :          0 :                 goto on_err;
   11663                 :            :         }
   11664                 :            : 
   11665                 :            :         /* Setup CRC operation parameters */
   11666                 :          0 :         crc_len = d_td->ciphertext.no_crc == false ?
   11667                 :          0 :                         (d_td->ciphertext.len -
   11668                 :          0 :                                 d_td->ciphertext.crc_offset -
   11669         [ #  # ]:          0 :                                 RTE_ETHER_CRC_LEN) :
   11670                 :            :                         0;
   11671                 :          0 :         crc_len = crc_len > 0 ? crc_len : 0;
   11672         [ #  # ]:          0 :         crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
   11673                 :          0 :         ut_params->op->sym->auth.data.length = crc_len;
   11674                 :          0 :         ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
   11675                 :            : 
   11676                 :            :         /* Setup cipher operation parameters */
   11677                 :          0 :         cipher_len = d_td->ciphertext.no_cipher == false ?
   11678                 :          0 :                         (d_td->ciphertext.len -
   11679         [ #  # ]:          0 :                                 d_td->ciphertext.cipher_offset) :
   11680                 :            :                         0;
   11681                 :          0 :         cipher_len = cipher_len > 0 ? cipher_len : 0;
   11682                 :          0 :         ut_params->op->sym->cipher.data.length = cipher_len;
   11683                 :          0 :         ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
   11684                 :            : 
   11685                 :            :         /* Setup cipher IV */
   11686                 :          0 :         iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
   11687         [ #  # ]:          0 :         rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
   11688                 :            : 
   11689                 :            :         /* Attach session to operation */
   11690         [ #  # ]:          0 :         rte_security_attach_session(ut_params->op, ut_params->sec_session);
   11691                 :            : 
   11692                 :            :         /* Set crypto operation mbufs */
   11693                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
   11694                 :          0 :         ut_params->op->sym->m_dst = NULL;
   11695                 :            : 
   11696                 :            :         /* Process crypto operation */
   11697         [ #  # ]:          0 :         if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
   11698                 :            :                         NULL) {
   11699                 :            :                 printf("Test function %s line %u: failed to process security "
   11700                 :            :                         "crypto op\n", __func__, __LINE__);
   11701                 :            :                 ret = TEST_FAILED;
   11702                 :          0 :                 goto on_err;
   11703                 :            :         }
   11704                 :            : 
   11705         [ #  # ]:          0 :         if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
   11706                 :            :                 printf("Test function %s line %u: failed to process crypto op\n",
   11707                 :            :                         __func__, __LINE__);
   11708                 :            :                 ret = TEST_FAILED;
   11709                 :          0 :                 goto on_err;
   11710                 :            :         }
   11711                 :            : 
   11712                 :            :         /* Validate plaintext */
   11713                 :            :         plaintext = ciphertext;
   11714                 :            : 
   11715                 :          0 :         if (memcmp(plaintext, d_td->plaintext.data,
   11716         [ #  # ]:          0 :                         d_td->plaintext.len - crc_data_len)) {
   11717                 :            :                 printf("Test function %s line %u: plaintext not as expected\n",
   11718                 :            :                         __func__, __LINE__);
   11719                 :          0 :                 rte_hexdump(stdout, "expected", d_td->plaintext.data,
   11720                 :          0 :                                 d_td->plaintext.len);
   11721                 :          0 :                 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
   11722                 :            :                 ret = TEST_FAILED;
   11723                 :          0 :                 goto on_err;
   11724                 :            :         }
   11725                 :            : 
   11726                 :          0 : on_err:
   11727                 :          0 :         rte_crypto_op_free(ut_params->op);
   11728                 :          0 :         ut_params->op = NULL;
   11729                 :            : 
   11730         [ #  # ]:          0 :         if (ut_params->sec_session)
   11731                 :          0 :                 rte_security_session_destroy(ctx, ut_params->sec_session);
   11732                 :          0 :         ut_params->sec_session = NULL;
   11733                 :            : 
   11734                 :          0 :         rte_pktmbuf_free(ut_params->ibuf);
   11735                 :          0 :         ut_params->ibuf = NULL;
   11736                 :            : 
   11737                 :          0 :         return ret;
   11738                 :            : }
   11739                 :            : 
   11740                 :            : static int
   11741                 :          0 : test_docsis_proto_downlink(const void *data)
   11742                 :            : {
   11743                 :            :         const struct docsis_test_data *d_td = data;
   11744                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   11745                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   11746                 :            :         uint8_t *plaintext = NULL;
   11747                 :            :         uint8_t *ciphertext = NULL;
   11748                 :            :         uint8_t *iv_ptr;
   11749                 :            :         int32_t cipher_len, crc_len;
   11750                 :            :         int ret = TEST_SUCCESS;
   11751                 :            : 
   11752                 :          0 :         void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
   11753                 :            : 
   11754                 :            :         /* Verify the capabilities */
   11755                 :            :         struct rte_security_capability_idx sec_cap_idx;
   11756                 :            :         const struct rte_security_capability *sec_cap;
   11757                 :            :         const struct rte_cryptodev_capabilities *crypto_cap;
   11758                 :            :         const struct rte_cryptodev_symmetric_capability *sym_cap;
   11759                 :            :         int j = 0;
   11760                 :            : 
   11761                 :            :         /* Set action type */
   11762                 :          0 :         ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
   11763         [ #  # ]:          0 :                 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
   11764                 :            :                 gbl_action_type;
   11765                 :            : 
   11766         [ #  # ]:          0 :         if (security_proto_supported(ut_params->type,
   11767                 :            :                         RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
   11768                 :            :                 return TEST_SKIPPED;
   11769                 :            : 
   11770                 :          0 :         sec_cap_idx.action = ut_params->type;
   11771                 :          0 :         sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
   11772                 :          0 :         sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
   11773                 :            : 
   11774                 :          0 :         sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
   11775         [ #  # ]:          0 :         if (sec_cap == NULL)
   11776                 :            :                 return TEST_SKIPPED;
   11777                 :            : 
   11778         [ #  # ]:          0 :         while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
   11779                 :            :                         RTE_CRYPTO_OP_TYPE_UNDEFINED) {
   11780         [ #  # ]:          0 :                 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
   11781                 :            :                                 crypto_cap->sym.xform_type ==
   11782         [ #  # ]:          0 :                                         RTE_CRYPTO_SYM_XFORM_CIPHER &&
   11783                 :            :                                 crypto_cap->sym.cipher.algo ==
   11784                 :            :                                         RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
   11785                 :          0 :                         sym_cap = &crypto_cap->sym;
   11786         [ #  # ]:          0 :                         if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
   11787                 :          0 :                                                 d_td->key.len,
   11788                 :          0 :                                                 d_td->iv.len) == 0)
   11789                 :            :                                 break;
   11790                 :            :                 }
   11791                 :            :         }
   11792                 :            : 
   11793         [ #  # ]:          0 :         if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
   11794                 :            :                 return TEST_SKIPPED;
   11795                 :            : 
   11796                 :            :         /* Setup source mbuf payload */
   11797                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   11798                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   11799                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   11800                 :            : 
   11801                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   11802                 :          0 :                         d_td->plaintext.len);
   11803                 :            : 
   11804                 :          0 :         memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
   11805                 :            : 
   11806                 :            :         /* Setup cipher session parameters */
   11807                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   11808                 :          0 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
   11809                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
   11810                 :          0 :         ut_params->cipher_xform.cipher.key.data = d_td->key.data;
   11811                 :          0 :         ut_params->cipher_xform.cipher.key.length = d_td->key.len;
   11812                 :          0 :         ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
   11813                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   11814                 :          0 :         ut_params->cipher_xform.next = NULL;
   11815                 :            : 
   11816                 :            :         /* Setup DOCSIS session parameters */
   11817                 :          0 :         ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
   11818                 :            : 
   11819                 :          0 :         struct rte_security_session_conf sess_conf = {
   11820                 :          0 :                 .action_type = ut_params->type,
   11821                 :            :                 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
   11822                 :            :                 .docsis = ut_params->docsis_xform,
   11823                 :            :                 .crypto_xform = &ut_params->cipher_xform,
   11824                 :            :         };
   11825                 :            : 
   11826                 :            :         /* Create security session */
   11827                 :          0 :         ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
   11828                 :            :                                         ts_params->session_mpool);
   11829                 :            : 
   11830         [ #  # ]:          0 :         if (!ut_params->sec_session) {
   11831                 :            :                 printf("Test function %s line %u: failed to allocate session\n",
   11832                 :            :                         __func__, __LINE__);
   11833                 :            :                 ret = TEST_FAILED;
   11834                 :          0 :                 goto on_err;
   11835                 :            :         }
   11836                 :            : 
   11837                 :            :         /* Generate crypto op data structure */
   11838                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   11839                 :            :                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   11840         [ #  # ]:          0 :         if (!ut_params->op) {
   11841                 :            :                 printf("Test function %s line %u: failed to allocate symmetric "
   11842                 :            :                         "crypto operation\n", __func__, __LINE__);
   11843                 :            :                 ret = TEST_FAILED;
   11844                 :          0 :                 goto on_err;
   11845                 :            :         }
   11846                 :            : 
   11847                 :            :         /* Setup CRC operation parameters */
   11848                 :          0 :         crc_len = d_td->plaintext.no_crc == false ?
   11849                 :          0 :                         (d_td->plaintext.len -
   11850                 :          0 :                                 d_td->plaintext.crc_offset -
   11851         [ #  # ]:          0 :                                 RTE_ETHER_CRC_LEN) :
   11852                 :            :                         0;
   11853                 :          0 :         crc_len = crc_len > 0 ? crc_len : 0;
   11854                 :          0 :         ut_params->op->sym->auth.data.length = crc_len;
   11855                 :          0 :         ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
   11856                 :            : 
   11857                 :            :         /* Setup cipher operation parameters */
   11858                 :          0 :         cipher_len = d_td->plaintext.no_cipher == false ?
   11859                 :          0 :                         (d_td->plaintext.len -
   11860         [ #  # ]:          0 :                                 d_td->plaintext.cipher_offset) :
   11861                 :            :                         0;
   11862                 :          0 :         cipher_len = cipher_len > 0 ? cipher_len : 0;
   11863                 :          0 :         ut_params->op->sym->cipher.data.length = cipher_len;
   11864                 :          0 :         ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
   11865                 :            : 
   11866                 :            :         /* Setup cipher IV */
   11867                 :          0 :         iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
   11868         [ #  # ]:          0 :         rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
   11869                 :            : 
   11870                 :            :         /* Attach session to operation */
   11871         [ #  # ]:          0 :         rte_security_attach_session(ut_params->op, ut_params->sec_session);
   11872                 :            : 
   11873                 :            :         /* Set crypto operation mbufs */
   11874                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
   11875                 :          0 :         ut_params->op->sym->m_dst = NULL;
   11876                 :            : 
   11877                 :            :         /* Process crypto operation */
   11878         [ #  # ]:          0 :         if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
   11879                 :            :                         NULL) {
   11880                 :            :                 printf("Test function %s line %u: failed to process crypto op\n",
   11881                 :            :                         __func__, __LINE__);
   11882                 :            :                 ret = TEST_FAILED;
   11883                 :          0 :                 goto on_err;
   11884                 :            :         }
   11885                 :            : 
   11886         [ #  # ]:          0 :         if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
   11887                 :            :                 printf("Test function %s line %u: crypto op processing failed\n",
   11888                 :            :                         __func__, __LINE__);
   11889                 :            :                 ret = TEST_FAILED;
   11890                 :          0 :                 goto on_err;
   11891                 :            :         }
   11892                 :            : 
   11893                 :            :         /* Validate ciphertext */
   11894                 :            :         ciphertext = plaintext;
   11895                 :            : 
   11896         [ #  # ]:          0 :         if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
   11897                 :            :                 printf("Test function %s line %u: plaintext not as expected\n",
   11898                 :            :                         __func__, __LINE__);
   11899                 :          0 :                 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
   11900                 :          0 :                                 d_td->ciphertext.len);
   11901                 :          0 :                 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
   11902                 :            :                 ret = TEST_FAILED;
   11903                 :          0 :                 goto on_err;
   11904                 :            :         }
   11905                 :            : 
   11906                 :          0 : on_err:
   11907                 :          0 :         rte_crypto_op_free(ut_params->op);
   11908                 :          0 :         ut_params->op = NULL;
   11909                 :            : 
   11910         [ #  # ]:          0 :         if (ut_params->sec_session)
   11911                 :          0 :                 rte_security_session_destroy(ctx, ut_params->sec_session);
   11912                 :          0 :         ut_params->sec_session = NULL;
   11913                 :            : 
   11914                 :          0 :         rte_pktmbuf_free(ut_params->ibuf);
   11915                 :          0 :         ut_params->ibuf = NULL;
   11916                 :            : 
   11917                 :          0 :         return ret;
   11918                 :            : }
   11919                 :            : 
   11920                 :            : static void
   11921                 :          0 : test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
   11922                 :            :                                  struct rte_security_tls_record_xform *tls_record_xform)
   11923                 :            : {
   11924                 :            :         unsigned int imp_nonce_len;
   11925                 :            :         uint8_t *imp_nonce;
   11926                 :            : 
   11927   [ #  #  #  # ]:          0 :         switch (tls_record_xform->ver) {
   11928                 :          0 :         case RTE_SECURITY_VERSION_TLS_1_2:
   11929                 :            :                 imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
   11930                 :          0 :                 imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
   11931                 :          0 :                 break;
   11932                 :          0 :         case RTE_SECURITY_VERSION_DTLS_1_2:
   11933                 :            :                 imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
   11934                 :          0 :                 imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
   11935                 :          0 :                 break;
   11936                 :          0 :         case RTE_SECURITY_VERSION_TLS_1_3:
   11937                 :            :                 imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
   11938                 :          0 :                 imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
   11939                 :          0 :                 break;
   11940                 :            :         default:
   11941                 :            :                 return;
   11942                 :            :         }
   11943                 :            : 
   11944                 :          0 :         imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
   11945                 :          0 :         memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
   11946                 :            : }
   11947                 :            : 
   11948                 :            : static int
   11949                 :          0 : test_tls_record_proto_process(const struct tls_record_test_data td[],
   11950                 :            :                               struct tls_record_test_data res_d[], int nb_td, bool silent,
   11951                 :            :                               const struct tls_record_test_flags *flags)
   11952                 :            : {
   11953                 :          0 :         int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
   11954                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   11955                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   11956                 :            :         struct rte_security_tls_record_xform tls_record_xform;
   11957                 :            :         struct rte_security_capability_idx sec_cap_idx;
   11958                 :            :         const struct rte_security_capability *sec_cap;
   11959                 :            :         struct tls_record_test_data *res_d_tmp = NULL;
   11960                 :            :         enum rte_security_tls_sess_type sess_type;
   11961                 :          0 :         uint8_t dev_id = ts_params->valid_devs[0];
   11962                 :            :         struct rte_security_ctx *ctx;
   11963                 :            :         int i, ret = TEST_SUCCESS;
   11964                 :            : 
   11965                 :          0 :         ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
   11966                 :          0 :         gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
   11967                 :            : 
   11968                 :            :         /* Use first test data to create session */
   11969                 :            : 
   11970                 :            :         /* Copy TLS record xform */
   11971                 :          0 :         memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
   11972                 :            : 
   11973                 :          0 :         sess_type = tls_record_xform.type;
   11974                 :            : 
   11975                 :          0 :         ctx = rte_cryptodev_get_sec_ctx(dev_id);
   11976                 :            : 
   11977                 :          0 :         sec_cap_idx.action = ut_params->type;
   11978                 :          0 :         sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
   11979                 :          0 :         sec_cap_idx.tls_record.type = tls_record_xform.type;
   11980                 :          0 :         sec_cap_idx.tls_record.ver = tls_record_xform.ver;
   11981                 :            : 
   11982                 :          0 :         sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
   11983         [ #  # ]:          0 :         if (sec_cap == NULL)
   11984                 :            :                 return TEST_SKIPPED;
   11985                 :            : 
   11986                 :            :         /* Copy cipher session parameters */
   11987         [ #  # ]:          0 :         if (td[0].aead) {
   11988                 :          0 :                 memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
   11989                 :          0 :                 ut_params->aead_xform.aead.key.data = td[0].key.data;
   11990                 :          0 :                 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
   11991                 :            : 
   11992                 :            :                 /* Verify crypto capabilities */
   11993         [ #  # ]:          0 :                 if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
   11994         [ #  # ]:          0 :                         if (!silent)
   11995                 :          0 :                                 RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
   11996                 :          0 :                         return TEST_SKIPPED;
   11997                 :            :                 }
   11998                 :            :         } else {
   11999                 :          0 :                 memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
   12000                 :            :                        sizeof(ut_params->cipher_xform));
   12001                 :          0 :                 memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
   12002                 :            :                        sizeof(ut_params->auth_xform));
   12003                 :          0 :                 ut_params->cipher_xform.cipher.key.data = td[0].key.data;
   12004                 :          0 :                 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   12005                 :          0 :                 ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
   12006                 :            : 
   12007                 :            :                 /* Verify crypto capabilities */
   12008                 :            : 
   12009         [ #  # ]:          0 :                 if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
   12010         [ #  # ]:          0 :                         if (!silent)
   12011                 :          0 :                                 RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
   12012                 :          0 :                         return TEST_SKIPPED;
   12013                 :            :                 }
   12014                 :            : 
   12015         [ #  # ]:          0 :                 if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
   12016         [ #  # ]:          0 :                         if (!silent)
   12017                 :          0 :                                 RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
   12018                 :          0 :                         return TEST_SKIPPED;
   12019                 :            :                 }
   12020                 :            :         }
   12021                 :            : 
   12022         [ #  # ]:          0 :         if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
   12023                 :            :                 return TEST_SKIPPED;
   12024                 :            : 
   12025                 :          0 :         struct rte_security_session_conf sess_conf = {
   12026                 :          0 :                 .action_type = ut_params->type,
   12027                 :            :                 .protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
   12028                 :            :         };
   12029                 :            : 
   12030                 :            :         if ((tls_record_xform.ver == RTE_SECURITY_VERSION_DTLS_1_2) &&
   12031                 :            :             (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ))
   12032                 :            :                 sess_conf.tls_record.dtls_1_2.ar_win_sz = flags->ar_win_size;
   12033                 :            : 
   12034         [ #  # ]:          0 :         if (td[0].aead)
   12035                 :          0 :                 test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
   12036                 :            : 
   12037         [ #  # ]:          0 :         if (flags->opt_padding)
   12038                 :          0 :                 tls_record_xform.options.extra_padding_enable = 1;
   12039                 :            : 
   12040                 :          0 :         sess_conf.tls_record = tls_record_xform;
   12041                 :            : 
   12042         [ #  # ]:          0 :         if (td[0].aead) {
   12043                 :          0 :                 sess_conf.crypto_xform = &ut_params->aead_xform;
   12044                 :            :         } else {
   12045         [ #  # ]:          0 :                 if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
   12046                 :          0 :                         sess_conf.crypto_xform = &ut_params->cipher_xform;
   12047                 :          0 :                         ut_params->cipher_xform.next = &ut_params->auth_xform;
   12048                 :            :                 } else {
   12049                 :          0 :                         sess_conf.crypto_xform = &ut_params->auth_xform;
   12050                 :          0 :                         ut_params->auth_xform.next = &ut_params->cipher_xform;
   12051                 :            :                 }
   12052                 :            :         }
   12053                 :            : 
   12054         [ #  # ]:          0 :         if (ut_params->sec_session == NULL) {
   12055                 :            :                 /* Create security session */
   12056                 :          0 :                 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
   12057                 :            :                                 ts_params->session_mpool);
   12058                 :            :         }
   12059                 :            : 
   12060         [ #  # ]:          0 :         if (ut_params->sec_session == NULL)
   12061                 :            :                 return TEST_SKIPPED;
   12062                 :            : 
   12063         [ #  # ]:          0 :         for (i = 0; i < nb_td; i++) {
   12064   [ #  #  #  # ]:          0 :                 if (flags->ar_win_size &&
   12065                 :            :                         (sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)) {
   12066                 :          0 :                         sess_conf.tls_record.dtls_1_2.seq_no =
   12067                 :          0 :                                 td[i].tls_record_xform.dtls_1_2.seq_no;
   12068                 :          0 :                         ret = rte_security_session_update(ctx, ut_params->sec_session, &sess_conf);
   12069         [ #  # ]:          0 :                         if (ret) {
   12070                 :            :                                 printf("Could not update sequence number in session\n");
   12071                 :          0 :                                 return TEST_SKIPPED;
   12072                 :            :                         }
   12073                 :            :                 }
   12074                 :            : 
   12075                 :            :                 /* Setup source mbuf payload */
   12076                 :          0 :                 ut_params->ibuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
   12077                 :          0 :                                 ts_params->large_mbuf_pool, td[i].input_text.len, nb_segs, 0);
   12078                 :          0 :                 pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
   12079         [ #  # ]:          0 :                 if (flags->out_of_place)
   12080                 :          0 :                         ut_params->obuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
   12081                 :          0 :                                         ts_params->large_mbuf_pool, td[i].output_text.len, nb_segs,
   12082                 :            :                                         0);
   12083                 :            :                 else
   12084                 :          0 :                         ut_params->obuf = NULL;
   12085                 :            : 
   12086                 :            :                 /* Generate crypto op data structure */
   12087                 :          0 :                 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   12088                 :            :                                                     RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   12089         [ #  # ]:          0 :                 if (ut_params->op == NULL) {
   12090                 :            :                         printf("Could not allocate crypto op");
   12091                 :            :                         ret = TEST_FAILED;
   12092                 :          0 :                         goto crypto_op_free;
   12093                 :            :                 }
   12094                 :            : 
   12095                 :            :                 /* Attach session to operation */
   12096         [ #  # ]:          0 :                 rte_security_attach_session(ut_params->op, ut_params->sec_session);
   12097                 :            : 
   12098                 :            :                 /* Set crypto operation mbufs */
   12099                 :          0 :                 ut_params->op->sym->m_src = ut_params->ibuf;
   12100                 :          0 :                 ut_params->op->sym->m_dst = ut_params->obuf;
   12101                 :          0 :                 ut_params->op->param1.tls_record.content_type = td[i].app_type;
   12102                 :            : 
   12103         [ #  # ]:          0 :                 if (flags->opt_padding)
   12104                 :          0 :                         ut_params->op->aux_flags = flags->opt_padding;
   12105                 :            : 
   12106                 :            :                 /* Copy IV in crypto operation when IV generation is disabled */
   12107         [ #  # ]:          0 :                 if ((sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE) &&
   12108         [ #  # ]:          0 :                     (tls_record_xform.ver != RTE_SECURITY_VERSION_TLS_1_3) &&
   12109         [ #  # ]:          0 :                     (tls_record_xform.options.iv_gen_disable == 1)) {
   12110                 :            :                         uint8_t *iv;
   12111                 :            :                         int len;
   12112                 :            : 
   12113                 :          0 :                         iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
   12114         [ #  # ]:          0 :                         if (td[i].aead)
   12115                 :          0 :                                 len = td[i].xform.aead.aead.iv.length - 4;
   12116                 :            :                         else
   12117                 :          0 :                                 len = td[i].xform.chain.cipher.cipher.iv.length;
   12118                 :          0 :                         memcpy(iv, td[i].iv.data, len);
   12119                 :            :                 }
   12120                 :            : 
   12121                 :            :                 /* Process crypto operation */
   12122                 :          0 :                 process_crypto_request(dev_id, ut_params->op);
   12123                 :            : 
   12124                 :          0 :                 ret = test_tls_record_status_check(ut_params->op, &td[i]);
   12125         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
   12126                 :          0 :                         goto crypto_op_free;
   12127                 :            : 
   12128         [ #  # ]:          0 :                 if (res_d != NULL)
   12129                 :          0 :                         res_d_tmp = &res_d[i];
   12130                 :            : 
   12131         [ #  # ]:          0 :                 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
   12132         [ #  # ]:          0 :                         struct rte_mbuf *buf = flags->out_of_place ? ut_params->obuf :
   12133                 :            :                                                 ut_params->ibuf;
   12134                 :            : 
   12135                 :          0 :                         ret = test_tls_record_post_process(buf, &td[i], res_d_tmp,
   12136                 :            :                                                            silent, flags);
   12137         [ #  # ]:          0 :                         if (ret != TEST_SUCCESS)
   12138                 :          0 :                                 goto crypto_op_free;
   12139                 :            :                 }
   12140                 :            : 
   12141                 :          0 :                 rte_crypto_op_free(ut_params->op);
   12142                 :          0 :                 ut_params->op = NULL;
   12143                 :            : 
   12144         [ #  # ]:          0 :                 if (flags->out_of_place) {
   12145                 :          0 :                         rte_pktmbuf_free(ut_params->obuf);
   12146                 :          0 :                         ut_params->obuf = NULL;
   12147                 :            :                 }
   12148                 :            : 
   12149                 :          0 :                 rte_pktmbuf_free(ut_params->ibuf);
   12150                 :          0 :                 ut_params->ibuf = NULL;
   12151                 :            :         }
   12152                 :            : 
   12153                 :          0 : crypto_op_free:
   12154                 :          0 :         rte_crypto_op_free(ut_params->op);
   12155                 :          0 :         ut_params->op = NULL;
   12156                 :            : 
   12157         [ #  # ]:          0 :         if (flags->out_of_place) {
   12158                 :          0 :                 rte_pktmbuf_free(ut_params->obuf);
   12159                 :          0 :                 ut_params->obuf = NULL;
   12160                 :            :         }
   12161                 :            : 
   12162                 :          0 :         rte_pktmbuf_free(ut_params->ibuf);
   12163                 :          0 :         ut_params->ibuf = NULL;
   12164                 :            : 
   12165   [ #  #  #  # ]:          0 :         if (ut_params->sec_session != NULL && !flags->skip_sess_destroy) {
   12166                 :          0 :                 rte_security_session_destroy(ctx, ut_params->sec_session);
   12167                 :          0 :                 ut_params->sec_session = NULL;
   12168                 :            :         }
   12169                 :            : 
   12170                 :            :         RTE_SET_USED(flags);
   12171                 :            : 
   12172                 :            :         return ret;
   12173                 :            : }
   12174                 :            : 
   12175                 :            : static int
   12176                 :          0 : test_tls_record_proto_known_vec(const void *test_data)
   12177                 :            : {
   12178                 :            :         struct tls_record_test_data td_write;
   12179                 :            :         struct tls_record_test_flags flags;
   12180                 :            : 
   12181                 :            :         memset(&flags, 0, sizeof(flags));
   12182                 :            : 
   12183                 :            :         memcpy(&td_write, test_data, sizeof(td_write));
   12184                 :            : 
   12185                 :            :         /* Disable IV gen to be able to test with known vectors */
   12186                 :          0 :         td_write.tls_record_xform.options.iv_gen_disable = 1;
   12187                 :            : 
   12188                 :          0 :         return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
   12189                 :            : }
   12190                 :            : 
   12191                 :            : static int
   12192         [ #  # ]:          0 : test_tls_record_proto_known_vec_read(const void *test_data)
   12193                 :            : {
   12194                 :            :         const struct tls_record_test_data *td = test_data;
   12195                 :            :         struct tls_record_test_flags flags;
   12196                 :            :         struct tls_record_test_data td_inb;
   12197                 :            : 
   12198                 :            :         memset(&flags, 0, sizeof(flags));
   12199                 :            : 
   12200         [ #  # ]:          0 :         if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
   12201                 :          0 :                 test_tls_record_td_read_from_write(td, &td_inb);
   12202                 :            :         else
   12203                 :            :                 memcpy(&td_inb, td, sizeof(td_inb));
   12204                 :            : 
   12205                 :          0 :         return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
   12206                 :            : }
   12207                 :            : 
   12208                 :            : static int
   12209                 :          0 : test_tls_record_proto_all(const struct tls_record_test_flags *flags)
   12210                 :            : {
   12211                 :            :         unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
   12212                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   12213                 :            :         struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
   12214                 :            :         struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
   12215                 :            :         void *sec_session_outb = NULL;
   12216                 :            :         void *sec_session_inb = NULL;
   12217                 :            :         int ret;
   12218                 :            : 
   12219      [ #  #  # ]:          0 :         switch (flags->tls_version) {
   12220                 :            :         case RTE_SECURITY_VERSION_TLS_1_2:
   12221                 :            :                 max_payload_len = TLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
   12222                 :            :                 break;
   12223                 :          0 :         case RTE_SECURITY_VERSION_TLS_1_3:
   12224                 :            :                 max_payload_len = TLS_1_3_RECORD_PLAINTEXT_MAX_LEN;
   12225                 :          0 :                 break;
   12226                 :            :         case RTE_SECURITY_VERSION_DTLS_1_2:
   12227                 :            :                 max_payload_len = DTLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
   12228                 :            :                 break;
   12229                 :          0 :         default:
   12230                 :            :                 max_payload_len = 0;
   12231                 :            :         }
   12232                 :            : 
   12233         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
   12234                 :            :                 payload_len = TLS_RECORD_PLAINTEXT_MIN_LEN;
   12235         [ #  # ]:          0 :                 if (flags->nb_segs_in_mbuf)
   12236                 :          0 :                         payload_len = RTE_MAX(payload_len, flags->nb_segs_in_mbuf);
   12237                 :            : 
   12238         [ #  # ]:          0 :                 if (flags->zero_len)
   12239                 :            :                         payload_len = 0;
   12240                 :          0 : again:
   12241                 :          0 :                 ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
   12242                 :            :                                                  flags, td_outb, nb_pkts, payload_len);
   12243         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   12244                 :          0 :                         continue;
   12245                 :            : 
   12246         [ #  # ]:          0 :                 if (flags->skip_sess_destroy)
   12247                 :          0 :                         ut_params->sec_session = sec_session_outb;
   12248                 :            : 
   12249                 :          0 :                 ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
   12250         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   12251                 :          0 :                         continue;
   12252                 :            : 
   12253   [ #  #  #  # ]:          0 :                 if (flags->skip_sess_destroy && sec_session_outb == NULL)
   12254                 :          0 :                         sec_session_outb = ut_params->sec_session;
   12255                 :            : 
   12256   [ #  #  #  # ]:          0 :                 if (flags->zero_len && flags->content_type != TLS_RECORD_TEST_CONTENT_TYPE_APP) {
   12257         [ #  # ]:          0 :                         if (ret == TEST_SUCCESS)
   12258                 :            :                                 return TEST_FAILED;
   12259                 :          0 :                         goto skip_decrypt;
   12260         [ #  # ]:          0 :                 } else if (ret == TEST_FAILED) {
   12261                 :            :                         return TEST_FAILED;
   12262                 :            :                 }
   12263                 :            : 
   12264                 :          0 :                 test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
   12265                 :            : 
   12266         [ #  # ]:          0 :                 if (flags->skip_sess_destroy)
   12267                 :          0 :                         ut_params->sec_session = sec_session_inb;
   12268                 :            : 
   12269                 :          0 :                 ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
   12270         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   12271                 :          0 :                         continue;
   12272                 :            : 
   12273   [ #  #  #  # ]:          0 :                 if (flags->skip_sess_destroy && sec_session_inb == NULL)
   12274                 :          0 :                         sec_session_inb = ut_params->sec_session;
   12275                 :            : 
   12276   [ #  #  #  # ]:          0 :                 if (flags->pkt_corruption || flags->padding_corruption) {
   12277         [ #  # ]:          0 :                         if (ret == TEST_SUCCESS)
   12278                 :            :                                 return TEST_FAILED;
   12279                 :            :                 } else {
   12280         [ #  # ]:          0 :                         if (ret == TEST_FAILED)
   12281                 :            :                                 return TEST_FAILED;
   12282                 :            :                 }
   12283                 :            : 
   12284                 :          0 : skip_decrypt:
   12285   [ #  #  #  # ]:          0 :                 if (flags->data_walkthrough && (++payload_len <= max_payload_len))
   12286                 :          0 :                         goto again;
   12287                 :            : 
   12288         [ #  # ]:          0 :                 if (flags->display_alg)
   12289                 :          0 :                         test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
   12290                 :            : 
   12291         [ #  # ]:          0 :                 if (flags->skip_sess_destroy) {
   12292                 :          0 :                         uint8_t dev_id = testsuite_params.valid_devs[0];
   12293                 :            :                         struct rte_security_ctx *ctx;
   12294                 :            : 
   12295                 :          0 :                         ctx = rte_cryptodev_get_sec_ctx(dev_id);
   12296         [ #  # ]:          0 :                         if (sec_session_inb != NULL) {
   12297                 :          0 :                                 rte_security_session_destroy(ctx, sec_session_inb);
   12298                 :            :                                 sec_session_inb = NULL;
   12299                 :            :                         }
   12300         [ #  # ]:          0 :                         if (sec_session_outb != NULL) {
   12301                 :          0 :                                 rte_security_session_destroy(ctx, sec_session_outb);
   12302                 :            :                                 sec_session_outb = NULL;
   12303                 :            :                         }
   12304                 :          0 :                         ut_params->sec_session = NULL;
   12305                 :            :                 }
   12306                 :            : 
   12307                 :          0 :                 pass_cnt++;
   12308                 :            :         }
   12309                 :            : 
   12310         [ #  # ]:          0 :         if (flags->data_walkthrough)
   12311                 :            :                 printf("\t Min payload size: %d, Max payload size: %d\n",
   12312                 :            :                                 TLS_RECORD_PLAINTEXT_MIN_LEN, max_payload_len);
   12313                 :            : 
   12314         [ #  # ]:          0 :         if (pass_cnt > 0)
   12315                 :            :                 return TEST_SUCCESS;
   12316                 :            :         else
   12317                 :          0 :                 return TEST_SKIPPED;
   12318                 :            : }
   12319                 :            : 
   12320                 :            : static int
   12321                 :          0 : test_tls_1_2_record_proto_data_walkthrough(void)
   12322                 :            : {
   12323                 :            :         struct tls_record_test_flags flags;
   12324                 :            : 
   12325                 :            :         memset(&flags, 0, sizeof(flags));
   12326                 :            : 
   12327                 :          0 :         flags.data_walkthrough = true;
   12328                 :          0 :         flags.skip_sess_destroy = true;
   12329                 :            :         flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
   12330                 :            : 
   12331                 :          0 :         return test_tls_record_proto_all(&flags);
   12332                 :            : }
   12333                 :            : 
   12334                 :            : static int
   12335                 :          0 : test_tls_1_2_record_proto_display_list(void)
   12336                 :            : {
   12337                 :            :         struct tls_record_test_flags flags;
   12338                 :            : 
   12339                 :            :         memset(&flags, 0, sizeof(flags));
   12340                 :            : 
   12341                 :          0 :         flags.display_alg = true;
   12342                 :            :         flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
   12343                 :            : 
   12344                 :          0 :         return test_tls_record_proto_all(&flags);
   12345                 :            : }
   12346                 :            : 
   12347                 :            : static int
   12348                 :          0 : test_tls_record_proto_sgl(enum rte_security_tls_version tls_version)
   12349                 :            : {
   12350                 :          0 :         struct tls_record_test_flags flags = {
   12351                 :            :                 .nb_segs_in_mbuf = 5,
   12352                 :            :                 .tls_version = tls_version
   12353                 :            :         };
   12354                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12355                 :            :         struct rte_cryptodev_info dev_info;
   12356                 :            : 
   12357                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12358         [ #  # ]:          0 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
   12359                 :            :                 printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
   12360                 :          0 :                 return TEST_SKIPPED;
   12361                 :            :         }
   12362                 :            : 
   12363                 :          0 :         return test_tls_record_proto_all(&flags);
   12364                 :            : }
   12365                 :            : 
   12366                 :            : static int
   12367                 :          0 : test_tls_1_2_record_proto_sgl(void)
   12368                 :            : {
   12369                 :          0 :         return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_2);
   12370                 :            : }
   12371                 :            : 
   12372                 :            : static int
   12373                 :          0 : test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_version)
   12374                 :            : {
   12375                 :          0 :         struct tls_record_test_flags flags = {
   12376                 :            :                 .nb_segs_in_mbuf = 5,
   12377                 :            :                 .tls_version = tls_version,
   12378                 :            :                 .skip_sess_destroy = true,
   12379                 :            :                 .data_walkthrough = true
   12380                 :            :         };
   12381                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12382                 :            :         struct rte_cryptodev_info dev_info;
   12383                 :            : 
   12384                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12385         [ #  # ]:          0 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
   12386                 :            :                 printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
   12387                 :          0 :                 return TEST_SKIPPED;
   12388                 :            :         }
   12389                 :            : 
   12390                 :          0 :         return test_tls_record_proto_all(&flags);
   12391                 :            : }
   12392                 :            : 
   12393                 :            : static int
   12394                 :          0 : test_tls_record_proto_sgl_oop(enum rte_security_tls_version tls_version)
   12395                 :            : {
   12396                 :          0 :         struct tls_record_test_flags flags = {
   12397                 :            :                 .nb_segs_in_mbuf = 5,
   12398                 :            :                 .out_of_place = true,
   12399                 :            :                 .tls_version = tls_version
   12400                 :            :         };
   12401                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12402                 :            :         struct rte_cryptodev_info dev_info;
   12403                 :            : 
   12404                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12405         [ #  # ]:          0 :         if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
   12406                 :            :                 printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
   12407                 :          0 :                 return TEST_SKIPPED;
   12408                 :            :         }
   12409                 :            : 
   12410                 :          0 :         return test_tls_record_proto_all(&flags);
   12411                 :            : }
   12412                 :            : 
   12413                 :            : static int
   12414                 :          0 : test_tls_1_2_record_proto_sgl_oop(void)
   12415                 :            : {
   12416                 :          0 :         return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_2);
   12417                 :            : }
   12418                 :            : 
   12419                 :            : static int
   12420                 :          0 : test_tls_1_2_record_proto_sgl_data_walkthrough(void)
   12421                 :            : {
   12422                 :          0 :         return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_2);
   12423                 :            : }
   12424                 :            : 
   12425                 :            : static int
   12426                 :          0 : test_tls_record_proto_corrupt_pkt(void)
   12427                 :            : {
   12428                 :          0 :         struct tls_record_test_flags flags = {
   12429                 :            :                 .pkt_corruption = 1
   12430                 :            :         };
   12431                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12432                 :            :         struct rte_cryptodev_info dev_info;
   12433                 :            : 
   12434                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12435                 :            : 
   12436                 :          0 :         return test_tls_record_proto_all(&flags);
   12437                 :            : }
   12438                 :            : 
   12439                 :            : static int
   12440                 :          0 : test_tls_record_proto_custom_content_type(void)
   12441                 :            : {
   12442                 :          0 :         struct tls_record_test_flags flags = {
   12443                 :            :                 .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM
   12444                 :            :         };
   12445                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12446                 :            :         struct rte_cryptodev_info dev_info;
   12447                 :            : 
   12448                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12449                 :            : 
   12450                 :          0 :         return test_tls_record_proto_all(&flags);
   12451                 :            : }
   12452                 :            : 
   12453                 :            : static int
   12454                 :          0 : test_tls_record_proto_zero_len(void)
   12455                 :            : {
   12456                 :          0 :         struct tls_record_test_flags flags = {
   12457                 :            :                 .zero_len = 1
   12458                 :            :         };
   12459                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12460                 :            :         struct rte_cryptodev_info dev_info;
   12461                 :            : 
   12462                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12463                 :            : 
   12464                 :          0 :         return test_tls_record_proto_all(&flags);
   12465                 :            : }
   12466                 :            : 
   12467                 :            : static int
   12468                 :          0 : test_tls_record_proto_zero_len_non_app(void)
   12469                 :            : {
   12470                 :          0 :         struct tls_record_test_flags flags = {
   12471                 :            :                 .zero_len = 1,
   12472                 :            :                 .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
   12473                 :            :         };
   12474                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12475                 :            :         struct rte_cryptodev_info dev_info;
   12476                 :            : 
   12477                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12478                 :            : 
   12479                 :          0 :         return test_tls_record_proto_all(&flags);
   12480                 :            : }
   12481                 :            : 
   12482                 :            : static int
   12483                 :          0 : test_tls_record_proto_opt_padding(uint8_t padding, uint8_t num_segs,
   12484                 :            :                                   enum rte_security_tls_version tls_version)
   12485                 :            : {
   12486                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12487                 :            :         struct rte_cryptodev_info dev_info;
   12488                 :          0 :         struct tls_record_test_flags flags = {
   12489                 :            :                 .nb_segs_in_mbuf = num_segs,
   12490                 :            :                 .tls_version = tls_version,
   12491                 :            :                 .opt_padding = padding
   12492                 :            :         };
   12493                 :            : 
   12494                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12495                 :            : 
   12496                 :          0 :         return test_tls_record_proto_all(&flags);
   12497                 :            : }
   12498                 :            : 
   12499                 :            : static int
   12500                 :          0 : test_tls_record_proto_dm_opt_padding(void)
   12501                 :            : {
   12502                 :          0 :         return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_TLS_1_2);
   12503                 :            : }
   12504                 :            : 
   12505                 :            : static int
   12506                 :          0 : test_tls_record_proto_dm_opt_padding_1(void)
   12507                 :            : {
   12508                 :          0 :         return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_TLS_1_2);
   12509                 :            : }
   12510                 :            : 
   12511                 :            : static int
   12512                 :          0 : test_tls_record_proto_sg_opt_padding(void)
   12513                 :            : {
   12514                 :          0 :         return test_tls_record_proto_opt_padding(1, 2, RTE_SECURITY_VERSION_TLS_1_2);
   12515                 :            : }
   12516                 :            : 
   12517                 :            : static int
   12518                 :          0 : test_tls_record_proto_sg_opt_padding_1(void)
   12519                 :            : {
   12520                 :          0 :         return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_TLS_1_2);
   12521                 :            : }
   12522                 :            : 
   12523                 :            : static int
   12524                 :          0 : test_tls_record_proto_sg_opt_padding_2(void)
   12525                 :            : {
   12526                 :          0 :         return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_TLS_1_2);
   12527                 :            : }
   12528                 :            : 
   12529                 :            : static int
   12530                 :          0 : test_tls_record_proto_sg_opt_padding_max(void)
   12531                 :            : {
   12532                 :          0 :         return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_TLS_1_2);
   12533                 :            : }
   12534                 :            : 
   12535                 :            : static int
   12536                 :          0 : test_tls_record_proto_sg_opt_padding_corrupt(void)
   12537                 :            : {
   12538                 :          0 :         struct tls_record_test_flags flags = {
   12539                 :            :                 .opt_padding = 8,
   12540                 :            :                 .padding_corruption = true,
   12541                 :            :                 .nb_segs_in_mbuf = 4,
   12542                 :            :         };
   12543                 :            : 
   12544                 :          0 :         return test_tls_record_proto_all(&flags);
   12545                 :            : }
   12546                 :            : 
   12547                 :            : static int
   12548                 :          0 : test_dtls_1_2_record_proto_data_walkthrough(void)
   12549                 :            : {
   12550                 :            :         struct tls_record_test_flags flags;
   12551                 :            : 
   12552                 :            :         memset(&flags, 0, sizeof(flags));
   12553                 :            : 
   12554                 :          0 :         flags.data_walkthrough = true;
   12555                 :          0 :         flags.skip_sess_destroy = true;
   12556                 :          0 :         flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
   12557                 :            : 
   12558                 :          0 :         return test_tls_record_proto_all(&flags);
   12559                 :            : }
   12560                 :            : 
   12561                 :            : static int
   12562                 :          0 : test_dtls_1_2_record_proto_display_list(void)
   12563                 :            : {
   12564                 :            :         struct tls_record_test_flags flags;
   12565                 :            : 
   12566                 :            :         memset(&flags, 0, sizeof(flags));
   12567                 :            : 
   12568                 :          0 :         flags.display_alg = true;
   12569                 :          0 :         flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
   12570                 :            : 
   12571                 :          0 :         return test_tls_record_proto_all(&flags);
   12572                 :            : }
   12573                 :            : 
   12574                 :            : static int
   12575                 :          0 : test_dtls_pkt_replay(const uint64_t seq_no[],
   12576                 :            :                       bool replayed_pkt[], uint32_t nb_pkts,
   12577                 :            :                       struct tls_record_test_flags *flags)
   12578                 :            : {
   12579                 :            :         struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
   12580                 :            :         struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
   12581                 :            :         unsigned int i, idx, pass_cnt = 0;
   12582                 :            :         int ret;
   12583                 :            : 
   12584         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
   12585                 :          0 :                 ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
   12586                 :            :                                                  flags, td_outb, nb_pkts, 0);
   12587         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   12588                 :          0 :                         continue;
   12589                 :            : 
   12590         [ #  # ]:          0 :                 for (idx = 0; idx < nb_pkts; idx++)
   12591                 :          0 :                         td_outb[idx].tls_record_xform.dtls_1_2.seq_no = seq_no[idx];
   12592                 :            : 
   12593                 :          0 :                 ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
   12594         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   12595                 :          0 :                         continue;
   12596                 :            : 
   12597         [ #  # ]:          0 :                 if (ret == TEST_FAILED)
   12598                 :            :                         return TEST_FAILED;
   12599                 :            : 
   12600                 :          0 :                 test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
   12601                 :            : 
   12602         [ #  # ]:          0 :                 for (idx = 0; idx < nb_pkts; idx++) {
   12603                 :          0 :                         td_inb[idx].tls_record_xform.dtls_1_2.ar_win_sz = flags->ar_win_size;
   12604                 :            :                         /* Set antireplay flag for packets to be dropped */
   12605                 :          0 :                         td_inb[idx].ar_packet = replayed_pkt[idx];
   12606                 :            :                 }
   12607                 :            : 
   12608                 :          0 :                 ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
   12609         [ #  # ]:          0 :                 if (ret == TEST_SKIPPED)
   12610                 :          0 :                         continue;
   12611                 :            : 
   12612         [ #  # ]:          0 :                 if (ret == TEST_FAILED)
   12613                 :            :                         return TEST_FAILED;
   12614                 :            : 
   12615         [ #  # ]:          0 :                 if (flags->display_alg)
   12616                 :          0 :                         test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
   12617                 :            : 
   12618                 :          0 :                 pass_cnt++;
   12619                 :            :         }
   12620                 :            : 
   12621         [ #  # ]:          0 :         if (pass_cnt > 0)
   12622                 :            :                 return TEST_SUCCESS;
   12623                 :            :         else
   12624                 :          0 :                 return TEST_SKIPPED;
   12625                 :            : }
   12626                 :            : 
   12627                 :            : static int
   12628                 :          0 : test_dtls_1_2_record_proto_antireplay(uint64_t winsz)
   12629                 :            : {
   12630                 :            :         struct tls_record_test_flags flags;
   12631                 :            :         uint32_t nb_pkts = 5;
   12632                 :            :         bool replayed_pkt[5];
   12633                 :            :         uint64_t seq_no[5];
   12634                 :            : 
   12635                 :            :         memset(&flags, 0, sizeof(flags));
   12636                 :            : 
   12637                 :          0 :         flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
   12638                 :          0 :         flags.ar_win_size = winsz;
   12639                 :            : 
   12640                 :            :         /* 1. Advance the TOP of the window to WS * 2 */
   12641                 :          0 :         seq_no[0] = winsz * 2;
   12642                 :            :         /* 2. Test sequence number within the new window(WS + 1) */
   12643                 :          0 :         seq_no[1] = winsz + 1;
   12644                 :            :         /* 3. Test sequence number less than the window BOTTOM */
   12645                 :          0 :         seq_no[2] = winsz;
   12646                 :            :         /* 4. Test sequence number in the middle of the window */
   12647                 :          0 :         seq_no[3] = winsz + (winsz / 2);
   12648                 :            :         /* 5. Test replay of the packet in the middle of the window */
   12649                 :          0 :         seq_no[4] = winsz + (winsz / 2);
   12650                 :            : 
   12651                 :          0 :         replayed_pkt[0] = false;
   12652                 :          0 :         replayed_pkt[1] = false;
   12653                 :          0 :         replayed_pkt[2] = true;
   12654                 :          0 :         replayed_pkt[3] = false;
   12655                 :          0 :         replayed_pkt[4] = true;
   12656                 :            : 
   12657                 :          0 :         return test_dtls_pkt_replay(seq_no, replayed_pkt, nb_pkts, &flags);
   12658                 :            : }
   12659                 :            : 
   12660                 :            : static int
   12661                 :          0 : test_dtls_1_2_record_proto_antireplay64(void)
   12662                 :            : {
   12663                 :          0 :         return test_dtls_1_2_record_proto_antireplay(64);
   12664                 :            : }
   12665                 :            : 
   12666                 :            : static int
   12667                 :          0 : test_dtls_1_2_record_proto_antireplay128(void)
   12668                 :            : {
   12669                 :          0 :         return test_dtls_1_2_record_proto_antireplay(128);
   12670                 :            : }
   12671                 :            : 
   12672                 :            : static int
   12673                 :          0 : test_dtls_1_2_record_proto_antireplay256(void)
   12674                 :            : {
   12675                 :          0 :         return test_dtls_1_2_record_proto_antireplay(256);
   12676                 :            : }
   12677                 :            : 
   12678                 :            : static int
   12679                 :          0 : test_dtls_1_2_record_proto_antireplay512(void)
   12680                 :            : {
   12681                 :          0 :         return test_dtls_1_2_record_proto_antireplay(512);
   12682                 :            : }
   12683                 :            : 
   12684                 :            : static int
   12685                 :          0 : test_dtls_1_2_record_proto_antireplay1024(void)
   12686                 :            : {
   12687                 :          0 :         return test_dtls_1_2_record_proto_antireplay(1024);
   12688                 :            : }
   12689                 :            : 
   12690                 :            : static int
   12691                 :          0 : test_dtls_1_2_record_proto_antireplay2048(void)
   12692                 :            : {
   12693                 :          0 :         return test_dtls_1_2_record_proto_antireplay(2048);
   12694                 :            : }
   12695                 :            : 
   12696                 :            : static int
   12697                 :          0 : test_dtls_1_2_record_proto_antireplay4096(void)
   12698                 :            : {
   12699                 :          0 :         return test_dtls_1_2_record_proto_antireplay(4096);
   12700                 :            : }
   12701                 :            : 
   12702                 :            : static int
   12703                 :          0 : test_dtls_1_2_record_proto_sgl(void)
   12704                 :            : {
   12705                 :          0 :         return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_DTLS_1_2);
   12706                 :            : }
   12707                 :            : 
   12708                 :            : static int
   12709                 :          0 : test_dtls_1_2_record_proto_sgl_data_walkthrough(void)
   12710                 :            : {
   12711                 :          0 :         return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_DTLS_1_2);
   12712                 :            : }
   12713                 :            : 
   12714                 :            : static int
   12715                 :          0 : test_dtls_1_2_record_proto_sgl_oop(void)
   12716                 :            : {
   12717                 :          0 :         return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_DTLS_1_2);
   12718                 :            : }
   12719                 :            : 
   12720                 :            : static int
   12721                 :          0 : test_dtls_1_2_record_proto_corrupt_pkt(void)
   12722                 :            : {
   12723                 :          0 :         struct tls_record_test_flags flags = {
   12724                 :            :                 .pkt_corruption = 1,
   12725                 :            :                 .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
   12726                 :            :         };
   12727                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12728                 :            :         struct rte_cryptodev_info dev_info;
   12729                 :            : 
   12730                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12731                 :            : 
   12732                 :          0 :         return test_tls_record_proto_all(&flags);
   12733                 :            : }
   12734                 :            : 
   12735                 :            : static int
   12736                 :          0 : test_dtls_1_2_record_proto_custom_content_type(void)
   12737                 :            : {
   12738                 :          0 :         struct tls_record_test_flags flags = {
   12739                 :            :                 .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
   12740                 :            :                 .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
   12741                 :            :         };
   12742                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12743                 :            :         struct rte_cryptodev_info dev_info;
   12744                 :            : 
   12745                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12746                 :            : 
   12747                 :          0 :         return test_tls_record_proto_all(&flags);
   12748                 :            : }
   12749                 :            : 
   12750                 :            : static int
   12751                 :          0 : test_dtls_1_2_record_proto_zero_len(void)
   12752                 :            : {
   12753                 :          0 :         struct tls_record_test_flags flags = {
   12754                 :            :                 .zero_len = 1,
   12755                 :            :                 .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
   12756                 :            :         };
   12757                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12758                 :            :         struct rte_cryptodev_info dev_info;
   12759                 :            : 
   12760                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12761                 :            : 
   12762                 :          0 :         return test_tls_record_proto_all(&flags);
   12763                 :            : }
   12764                 :            : 
   12765                 :            : static int
   12766                 :          0 : test_dtls_1_2_record_proto_zero_len_non_app(void)
   12767                 :            : {
   12768                 :          0 :         struct tls_record_test_flags flags = {
   12769                 :            :                 .zero_len = 1,
   12770                 :            :                 .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
   12771                 :            :                 .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
   12772                 :            :         };
   12773                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12774                 :            :         struct rte_cryptodev_info dev_info;
   12775                 :            : 
   12776                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12777                 :            : 
   12778                 :          0 :         return test_tls_record_proto_all(&flags);
   12779                 :            : }
   12780                 :            : 
   12781                 :            : static int
   12782                 :          0 : test_dtls_1_2_record_proto_dm_opt_padding(void)
   12783                 :            : {
   12784                 :          0 :         return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_DTLS_1_2);
   12785                 :            : }
   12786                 :            : 
   12787                 :            : static int
   12788                 :          0 : test_dtls_1_2_record_proto_dm_opt_padding_1(void)
   12789                 :            : {
   12790                 :          0 :         return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_DTLS_1_2);
   12791                 :            : }
   12792                 :            : 
   12793                 :            : static int
   12794                 :          0 : test_dtls_1_2_record_proto_sg_opt_padding(void)
   12795                 :            : {
   12796                 :          0 :         return test_tls_record_proto_opt_padding(1, 5, RTE_SECURITY_VERSION_DTLS_1_2);
   12797                 :            : }
   12798                 :            : 
   12799                 :            : static int
   12800                 :          0 : test_dtls_1_2_record_proto_sg_opt_padding_1(void)
   12801                 :            : {
   12802                 :          0 :         return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_DTLS_1_2);
   12803                 :            : }
   12804                 :            : 
   12805                 :            : static int
   12806                 :          0 : test_dtls_1_2_record_proto_sg_opt_padding_2(void)
   12807                 :            : {
   12808                 :          0 :         return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_DTLS_1_2);
   12809                 :            : }
   12810                 :            : 
   12811                 :            : static int
   12812                 :          0 : test_dtls_1_2_record_proto_sg_opt_padding_max(void)
   12813                 :            : {
   12814                 :          0 :         return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_DTLS_1_2);
   12815                 :            : }
   12816                 :            : 
   12817                 :            : static int
   12818                 :          0 : test_tls_1_3_record_proto_display_list(void)
   12819                 :            : {
   12820                 :            :         struct tls_record_test_flags flags;
   12821                 :            : 
   12822                 :            :         memset(&flags, 0, sizeof(flags));
   12823                 :            : 
   12824                 :          0 :         flags.display_alg = true;
   12825                 :          0 :         flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
   12826                 :            : 
   12827                 :          0 :         return test_tls_record_proto_all(&flags);
   12828                 :            : }
   12829                 :            : 
   12830                 :            : static int
   12831                 :          0 : test_dtls_1_2_record_proto_sg_opt_padding_corrupt(void)
   12832                 :            : {
   12833                 :          0 :         struct tls_record_test_flags flags = {
   12834                 :            :                 .opt_padding = 8,
   12835                 :            :                 .padding_corruption = true,
   12836                 :            :                 .nb_segs_in_mbuf = 4,
   12837                 :            :                 .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
   12838                 :            :         };
   12839                 :            : 
   12840                 :          0 :         return test_tls_record_proto_all(&flags);
   12841                 :            : }
   12842                 :            : 
   12843                 :            : static int
   12844                 :          0 : test_tls_1_3_record_proto_corrupt_pkt(void)
   12845                 :            : {
   12846                 :          0 :         struct tls_record_test_flags flags = {
   12847                 :            :                 .pkt_corruption = 1,
   12848                 :            :                 .tls_version = RTE_SECURITY_VERSION_TLS_1_3
   12849                 :            :         };
   12850                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12851                 :            :         struct rte_cryptodev_info dev_info;
   12852                 :            : 
   12853                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12854                 :            : 
   12855                 :          0 :         return test_tls_record_proto_all(&flags);
   12856                 :            : }
   12857                 :            : 
   12858                 :            : static int
   12859                 :          0 : test_tls_1_3_record_proto_custom_content_type(void)
   12860                 :            : {
   12861                 :          0 :         struct tls_record_test_flags flags = {
   12862                 :            :                 .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
   12863                 :            :                 .tls_version = RTE_SECURITY_VERSION_TLS_1_3
   12864                 :            :         };
   12865                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12866                 :            :         struct rte_cryptodev_info dev_info;
   12867                 :            : 
   12868                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12869                 :            : 
   12870                 :          0 :         return test_tls_record_proto_all(&flags);
   12871                 :            : }
   12872                 :            : 
   12873                 :            : static int
   12874                 :          0 : test_tls_1_3_record_proto_zero_len(void)
   12875                 :            : {
   12876                 :          0 :         struct tls_record_test_flags flags = {
   12877                 :            :                 .zero_len = 1,
   12878                 :            :                 .tls_version = RTE_SECURITY_VERSION_TLS_1_3
   12879                 :            :         };
   12880                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12881                 :            :         struct rte_cryptodev_info dev_info;
   12882                 :            : 
   12883                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12884                 :            : 
   12885                 :          0 :         return test_tls_record_proto_all(&flags);
   12886                 :            : }
   12887                 :            : 
   12888                 :            : static int
   12889                 :          0 : test_tls_1_3_record_proto_zero_len_non_app(void)
   12890                 :            : {
   12891                 :          0 :         struct tls_record_test_flags flags = {
   12892                 :            :                 .zero_len = 1,
   12893                 :            :                 .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
   12894                 :            :                 .tls_version = RTE_SECURITY_VERSION_TLS_1_3
   12895                 :            :         };
   12896                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12897                 :            :         struct rte_cryptodev_info dev_info;
   12898                 :            : 
   12899                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12900                 :            : 
   12901                 :          0 :         return test_tls_record_proto_all(&flags);
   12902                 :            : }
   12903                 :            : 
   12904                 :            : static int
   12905                 :          0 : test_tls_1_3_record_proto_dm_opt_padding(void)
   12906                 :            : {
   12907                 :          0 :         return test_tls_record_proto_opt_padding(6, 0, RTE_SECURITY_VERSION_TLS_1_3);
   12908                 :            : }
   12909                 :            : 
   12910                 :            : static int
   12911                 :          0 : test_tls_1_3_record_proto_sg_opt_padding(void)
   12912                 :            : {
   12913                 :          0 :         return test_tls_record_proto_opt_padding(25, 5, RTE_SECURITY_VERSION_TLS_1_3);
   12914                 :            : }
   12915                 :            : 
   12916                 :            : static int
   12917                 :          0 : test_tls_1_3_record_proto_sg_opt_padding_1(void)
   12918                 :            : {
   12919                 :          0 :         return test_tls_record_proto_opt_padding(25, 4, RTE_SECURITY_VERSION_TLS_1_3);
   12920                 :            : }
   12921                 :            : 
   12922                 :            : static int
   12923                 :          0 : test_tls_1_3_record_proto_data_walkthrough(void)
   12924                 :            : {
   12925                 :            :         struct tls_record_test_flags flags;
   12926                 :            : 
   12927                 :            :         memset(&flags, 0, sizeof(flags));
   12928                 :            : 
   12929                 :          0 :         flags.data_walkthrough = true;
   12930                 :          0 :         flags.skip_sess_destroy = true;
   12931                 :          0 :         flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
   12932                 :            : 
   12933                 :          0 :         return test_tls_record_proto_all(&flags);
   12934                 :            : }
   12935                 :            : 
   12936                 :            : static int
   12937                 :          0 : test_tls_1_3_record_proto_sgl(void)
   12938                 :            : {
   12939                 :          0 :         return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_3);
   12940                 :            : }
   12941                 :            : 
   12942                 :            : static int
   12943                 :          0 : test_tls_1_3_record_proto_sgl_data_walkthrough(void)
   12944                 :            : {
   12945                 :          0 :         return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_3);
   12946                 :            : }
   12947                 :            : 
   12948                 :            : static int
   12949                 :          0 : test_tls_1_3_record_proto_sgl_oop(void)
   12950                 :            : {
   12951                 :          0 :         return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_3);
   12952                 :            : }
   12953                 :            : 
   12954                 :            : #endif
   12955                 :            : 
   12956                 :            : static int
   12957                 :          1 : test_cryptodev_error_recover_helper_check(void)
   12958                 :            : {
   12959                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12960                 :            :         struct rte_cryptodev_info dev_info;
   12961                 :            :         uint64_t feat_flags;
   12962                 :            :         int ret;
   12963                 :            : 
   12964                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   12965                 :          1 :         feat_flags = dev_info.feature_flags;
   12966                 :            : 
   12967                 :            :         /* Skip the test if queue pair reset is not supported */
   12968                 :          1 :         ret = rte_cryptodev_queue_pair_reset(ts_params->valid_devs[0], 0, NULL, 0);
   12969         [ -  + ]:          1 :         if (ret == -ENOTSUP)
   12970                 :            :                 return TEST_SKIPPED;
   12971                 :            : 
   12972         [ #  # ]:          0 :         ret = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
   12973         [ #  # ]:          0 :         if (ret == -ENOTSUP)
   12974                 :          0 :                 return TEST_SKIPPED;
   12975                 :            : 
   12976         [ #  # ]:          0 :         if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
   12977         [ #  # ]:          0 :             ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   12978         [ #  # ]:          0 :              !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   12979                 :          0 :                 RTE_LOG(INFO, USER1, "Feature flag req for AES Cipheronly, testsuite not met\n");
   12980                 :          0 :                 return TEST_SKIPPED;
   12981                 :            :         }
   12982                 :            : 
   12983                 :            :         return 0;
   12984                 :            : }
   12985                 :            : 
   12986                 :            : static int
   12987                 :          0 : test_cryptodev_error_recover_helper(uint8_t dev_id, const void *test_data, bool generate_err)
   12988                 :          0 : {
   12989                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   12990                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   12991                 :            :         const struct blockcipher_test_data *tdata = test_data;
   12992                 :          0 :         uint8_t cipher_key[tdata->cipher_key.len];
   12993                 :            :         struct rte_crypto_sym_op *sym_op = NULL;
   12994                 :            :         struct rte_crypto_op *op = NULL;
   12995                 :            :         char *dst;
   12996                 :            : 
   12997                 :          0 :         memcpy(cipher_key, tdata->cipher_key.data, tdata->cipher_key.len);
   12998                 :          0 :         ut_params->cipher_xform.next = NULL;
   12999                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   13000                 :          0 :         ut_params->cipher_xform.cipher.algo = tdata->crypto_algo;
   13001                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
   13002                 :          0 :         ut_params->cipher_xform.cipher.key.data = cipher_key;
   13003                 :          0 :         ut_params->cipher_xform.cipher.key.length = tdata->cipher_key.len;
   13004                 :          0 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   13005                 :          0 :         ut_params->cipher_xform.cipher.iv.length = tdata->iv.len;
   13006                 :            : 
   13007                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id, &ut_params->cipher_xform,
   13008                 :            :                                                            ts_params->session_mpool);
   13009         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   13010                 :            : 
   13011                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   13012         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
   13013                 :            : 
   13014                 :          0 :         memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), tdata->iv.data,
   13015         [ #  # ]:          0 :                tdata->iv.len);
   13016                 :            :         sym_op = ut_params->op->sym;
   13017                 :          0 :         sym_op->cipher.data.offset = tdata->cipher_offset;
   13018                 :          0 :         sym_op->cipher.data.length = tdata->ciphertext.len - tdata->cipher_offset;
   13019                 :            : 
   13020         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   13021                 :            : 
   13022         [ #  # ]:          0 :         if (generate_err) {
   13023                 :          0 :                 ut_params->ibuf = create_mbuf_from_heap(tdata->ciphertext.len, 0);
   13024         [ #  # ]:          0 :                 if (ut_params->ibuf == NULL)
   13025                 :            :                         return TEST_FAILED;
   13026                 :          0 :                 crypto_err = CRYPTODEV_ERR_TRIGGERED;
   13027                 :            :         } else {
   13028                 :          0 :                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   13029                 :            :         }
   13030                 :            : 
   13031                 :            :         /* clear mbuf payload */
   13032                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   13033                 :          0 :                rte_pktmbuf_tailroom(ut_params->ibuf));
   13034                 :            : 
   13035                 :          0 :         dst = rte_pktmbuf_mtod_offset(ut_params->ibuf, char *, 0);
   13036                 :          0 :         memcpy(dst, tdata->plaintext.data, tdata->plaintext.len);
   13037                 :            : 
   13038                 :          0 :         sym_op->m_src = ut_params->ibuf;
   13039                 :          0 :         sym_op->m_dst = NULL;
   13040                 :            : 
   13041                 :          0 :         op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
   13042                 :            : 
   13043         [ #  # ]:          0 :         if (generate_err) {
   13044                 :          0 :                 free(ut_params->ibuf);
   13045                 :          0 :                 ut_params->ibuf = NULL;
   13046         [ #  # ]:          0 :                 if (op == NULL) {
   13047                 :          0 :                         rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
   13048                 :          0 :                         ut_params->sess = NULL;
   13049                 :          0 :                         return TEST_SUCCESS;
   13050                 :            :                 } else {
   13051                 :            :                         return TEST_FAILED;
   13052                 :            :                 }
   13053                 :            :         }
   13054                 :            : 
   13055         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   13056                 :            :                           "crypto op processing failed");
   13057                 :            : 
   13058         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(dst, tdata->ciphertext.data + tdata->cipher_offset,
   13059                 :            :                                       tdata->ciphertext.len - tdata->cipher_offset,
   13060                 :            :                                       "Data not as expected");
   13061                 :            : 
   13062                 :          0 :         rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
   13063                 :          0 :         ut_params->sess = NULL;
   13064                 :            : 
   13065                 :          0 :         return TEST_SUCCESS;
   13066                 :            : }
   13067                 :            : 
   13068                 :            : /*
   13069                 :            :  * This unit test verifies the recovery of the cryptodev from any fatal error.
   13070                 :            :  * It verifies a single test data multiple times in a iteration. It uses a flag and flips its value
   13071                 :            :  * for every call to helper function.
   13072                 :            :  *
   13073                 :            :  * When the flag is set to 0, the helper function verifies the test data without generating any
   13074                 :            :  * errors, i.e: verifies the default behaviour of the cryptodev.
   13075                 :            :  *
   13076                 :            :  * When the flag is set to 1, the helper function allocates a pointer from heap or non-DMAble
   13077                 :            :  * memory and passes the pointer to cryptodev PMD inorder to generate a fatal error. Once the error
   13078                 :            :  * is generated, it waits till the cryptodev is recoverd from the error.
   13079                 :            :  *
   13080                 :            :  * Iterates the above steps multiple times, to verify the error recovery of cryptodev and behaviour
   13081                 :            :  * of cryptodev after the recovery.
   13082                 :            :  */
   13083                 :            : static int
   13084                 :          1 : test_cryptodev_verify_error_recover(const void *test_data)
   13085                 :            : {
   13086                 :            :         int ret = TEST_FAILED;
   13087                 :            :         int i, num_itr = 5;
   13088                 :            : 
   13089                 :          1 :         ret = test_cryptodev_error_recover_helper_check();
   13090         [ -  + ]:          1 :         if (ret)
   13091                 :            :                 return ret;
   13092                 :            : 
   13093         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_callback_register(p_testsuite_params->valid_devs[0],
   13094                 :            :                                                             RTE_CRYPTODEV_EVENT_ERROR,
   13095                 :            :                                                             test_cryptodev_error_cb, NULL),
   13096                 :            :                             "Failed to register Cryptodev callback");
   13097                 :            : 
   13098         [ #  # ]:          0 :         for (i = 0; i < num_itr; i++) {
   13099                 :            :                 int ticks = 0;
   13100                 :            : 
   13101                 :          0 :                 ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
   13102                 :            :                                                           test_data, false);
   13103         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
   13104                 :            : 
   13105                 :            :                 /* Generate Error */
   13106                 :          0 :                 ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
   13107                 :            :                                                           test_data, true);
   13108         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
   13109                 :            : 
   13110                 :            :                 /* Wait till cryptodev recovered from error */
   13111         [ #  # ]:          0 :                 while (crypto_err == CRYPTODEV_ERR_TRIGGERED) {
   13112                 :            :                         rte_delay_ms(10);
   13113         [ #  # ]:          0 :                         if (ticks++ > HW_ERR_RECOVER_TIMEOUT)
   13114                 :            :                                 return TEST_FAILED;
   13115                 :            :                 }
   13116                 :            :         }
   13117         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(crypto_err, CRYPTODEV_ERR_CLEARED, "cryptodev error recovery failed");
   13118                 :            : 
   13119                 :            :         return ret;
   13120                 :            : }
   13121                 :            : 
   13122                 :            : static int
   13123                 :          1 : test_AES_GCM_authenticated_encryption_test_case_1(void)
   13124                 :            : {
   13125                 :          1 :         return test_authenticated_encryption(&gcm_test_case_1);
   13126                 :            : }
   13127                 :            : 
   13128                 :            : static int
   13129                 :          1 : test_AES_GCM_authenticated_encryption_test_case_2(void)
   13130                 :            : {
   13131                 :          1 :         return test_authenticated_encryption(&gcm_test_case_2);
   13132                 :            : }
   13133                 :            : 
   13134                 :            : static int
   13135                 :          1 : test_AES_GCM_authenticated_encryption_test_case_3(void)
   13136                 :            : {
   13137                 :          1 :         return test_authenticated_encryption(&gcm_test_case_3);
   13138                 :            : }
   13139                 :            : 
   13140                 :            : static int
   13141                 :          1 : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
   13142                 :            : {
   13143                 :          1 :         return test_authenticated_encryption_helper(&gcm_test_case_3, true);
   13144                 :            : }
   13145                 :            : 
   13146                 :            : static int
   13147                 :          1 : test_AES_GCM_authenticated_encryption_test_case_4(void)
   13148                 :            : {
   13149                 :          1 :         return test_authenticated_encryption(&gcm_test_case_4);
   13150                 :            : }
   13151                 :            : 
   13152                 :            : static int
   13153                 :          1 : test_AES_GCM_authenticated_encryption_test_case_5(void)
   13154                 :            : {
   13155                 :          1 :         return test_authenticated_encryption(&gcm_test_case_5);
   13156                 :            : }
   13157                 :            : 
   13158                 :            : static int
   13159                 :          1 : test_AES_GCM_authenticated_encryption_test_case_6(void)
   13160                 :            : {
   13161                 :          1 :         return test_authenticated_encryption(&gcm_test_case_6);
   13162                 :            : }
   13163                 :            : 
   13164                 :            : static int
   13165                 :          1 : test_AES_GCM_authenticated_encryption_test_case_7(void)
   13166                 :            : {
   13167                 :          1 :         return test_authenticated_encryption(&gcm_test_case_7);
   13168                 :            : }
   13169                 :            : 
   13170                 :            : static int
   13171                 :          1 : test_AES_GCM_authenticated_encryption_test_case_8(void)
   13172                 :            : {
   13173                 :          1 :         return test_authenticated_encryption(&gcm_test_case_8);
   13174                 :            : }
   13175                 :            : 
   13176                 :            : static int
   13177                 :          1 : test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
   13178                 :            : {
   13179                 :          1 :         return test_authenticated_encryption(&gcm_J0_test_case_1);
   13180                 :            : }
   13181                 :            : 
   13182                 :            : static int
   13183                 :          1 : test_AES_GCM_auth_encryption_test_case_192_1(void)
   13184                 :            : {
   13185                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_1);
   13186                 :            : }
   13187                 :            : 
   13188                 :            : static int
   13189                 :          1 : test_AES_GCM_auth_encryption_test_case_192_2(void)
   13190                 :            : {
   13191                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_2);
   13192                 :            : }
   13193                 :            : 
   13194                 :            : static int
   13195                 :          1 : test_AES_GCM_auth_encryption_test_case_192_3(void)
   13196                 :            : {
   13197                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_3);
   13198                 :            : }
   13199                 :            : 
   13200                 :            : static int
   13201                 :          1 : test_AES_GCM_auth_encryption_test_case_192_4(void)
   13202                 :            : {
   13203                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_4);
   13204                 :            : }
   13205                 :            : 
   13206                 :            : static int
   13207                 :          1 : test_AES_GCM_auth_encryption_test_case_192_5(void)
   13208                 :            : {
   13209                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_5);
   13210                 :            : }
   13211                 :            : 
   13212                 :            : static int
   13213                 :          1 : test_AES_GCM_auth_encryption_test_case_192_6(void)
   13214                 :            : {
   13215                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_6);
   13216                 :            : }
   13217                 :            : 
   13218                 :            : static int
   13219                 :          1 : test_AES_GCM_auth_encryption_test_case_192_7(void)
   13220                 :            : {
   13221                 :          1 :         return test_authenticated_encryption(&gcm_test_case_192_7);
   13222                 :            : }
   13223                 :            : 
   13224                 :            : static int
   13225                 :          1 : test_AES_GCM_auth_encryption_test_case_256_1(void)
   13226                 :            : {
   13227                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_1);
   13228                 :            : }
   13229                 :            : 
   13230                 :            : static int
   13231                 :          1 : test_AES_GCM_auth_encryption_test_case_256_2(void)
   13232                 :            : {
   13233                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_2);
   13234                 :            : }
   13235                 :            : 
   13236                 :            : static int
   13237                 :          1 : test_AES_GCM_auth_encryption_test_case_256_3(void)
   13238                 :            : {
   13239                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_3);
   13240                 :            : }
   13241                 :            : 
   13242                 :            : static int
   13243                 :          1 : test_AES_GCM_auth_encryption_test_case_256_4(void)
   13244                 :            : {
   13245                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_4);
   13246                 :            : }
   13247                 :            : 
   13248                 :            : static int
   13249                 :          1 : test_AES_GCM_auth_encryption_test_case_256_5(void)
   13250                 :            : {
   13251                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_5);
   13252                 :            : }
   13253                 :            : 
   13254                 :            : static int
   13255                 :          1 : test_AES_GCM_auth_encryption_test_case_256_6(void)
   13256                 :            : {
   13257                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_6);
   13258                 :            : }
   13259                 :            : 
   13260                 :            : static int
   13261                 :          1 : test_AES_GCM_auth_encryption_test_case_256_7(void)
   13262                 :            : {
   13263                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_7);
   13264                 :            : }
   13265                 :            : 
   13266                 :            : static int
   13267                 :          1 : test_AES_GCM_auth_encryption_test_case_aad_1(void)
   13268                 :            : {
   13269                 :          1 :         return test_authenticated_encryption(&gcm_test_case_aad_1);
   13270                 :            : }
   13271                 :            : 
   13272                 :            : static int
   13273                 :          1 : test_AES_GCM_auth_encryption_test_case_aad_2(void)
   13274                 :            : {
   13275                 :          1 :         return test_authenticated_encryption(&gcm_test_case_aad_2);
   13276                 :            : }
   13277                 :            : 
   13278                 :            : static int
   13279                 :          1 : test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
   13280                 :            : {
   13281                 :            :         struct aead_test_data tdata;
   13282                 :            :         int res;
   13283                 :            : 
   13284                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13285                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13286                 :          1 :         tdata.iv.data[0] += 1;
   13287                 :            :         res = test_authenticated_encryption(&tdata);
   13288         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13289                 :            :                 return res;
   13290         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
   13291                 :            :         return TEST_SUCCESS;
   13292                 :            : }
   13293                 :            : 
   13294                 :            : static int
   13295                 :          1 : test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
   13296                 :            : {
   13297                 :            :         struct aead_test_data tdata;
   13298                 :            :         int res;
   13299                 :            : 
   13300                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13301                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13302                 :          1 :         tdata.plaintext.data[0] += 1;
   13303                 :            :         res = test_authenticated_encryption(&tdata);
   13304         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13305                 :            :                 return res;
   13306         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
   13307                 :            :         return TEST_SUCCESS;
   13308                 :            : }
   13309                 :            : 
   13310                 :            : static int
   13311                 :          1 : test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
   13312                 :            : {
   13313                 :            :         struct aead_test_data tdata;
   13314                 :            :         int res;
   13315                 :            : 
   13316                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13317                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13318                 :          1 :         tdata.ciphertext.data[0] += 1;
   13319                 :            :         res = test_authenticated_encryption(&tdata);
   13320         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13321                 :            :                 return res;
   13322         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
   13323                 :            :         return TEST_SUCCESS;
   13324                 :            : }
   13325                 :            : 
   13326                 :            : static int
   13327                 :          1 : test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
   13328                 :            : {
   13329                 :            :         struct aead_test_data tdata;
   13330                 :            :         int res;
   13331                 :            : 
   13332                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13333                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13334                 :          1 :         tdata.aad.len += 1;
   13335                 :            :         res = test_authenticated_encryption(&tdata);
   13336         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13337                 :            :                 return res;
   13338         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
   13339                 :            :         return TEST_SUCCESS;
   13340                 :            : }
   13341                 :            : 
   13342                 :            : static int
   13343                 :          1 : test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
   13344                 :          1 : {
   13345                 :            :         struct aead_test_data tdata;
   13346                 :            :         uint8_t aad[gcm_test_case_7.aad.len];
   13347                 :            :         int res;
   13348                 :            : 
   13349                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13350                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13351                 :            :         memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
   13352                 :          1 :         aad[0] += 1;
   13353                 :          1 :         tdata.aad.data = aad;
   13354                 :            :         res = test_authenticated_encryption(&tdata);
   13355         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13356                 :            :                 return res;
   13357         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
   13358                 :            :         return TEST_SUCCESS;
   13359                 :            : }
   13360                 :            : 
   13361                 :            : static int
   13362                 :          1 : test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
   13363                 :            : {
   13364                 :            :         struct aead_test_data tdata;
   13365                 :            :         int res;
   13366                 :            : 
   13367                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13368                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13369                 :          1 :         tdata.auth_tag.data[0] += 1;
   13370                 :            :         res = test_authenticated_encryption(&tdata);
   13371         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13372                 :            :                 return res;
   13373         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
   13374                 :            :         return TEST_SUCCESS;
   13375                 :            : }
   13376                 :            : 
   13377                 :            : static int
   13378                 :         42 : test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
   13379                 :            : {
   13380                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   13381                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   13382                 :            : 
   13383                 :            :         int retval;
   13384                 :            :         uint8_t *plaintext;
   13385                 :            :         uint32_t i;
   13386                 :            :         struct rte_cryptodev_info dev_info;
   13387                 :            : 
   13388                 :         42 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   13389                 :         42 :         uint64_t feat_flags = dev_info.feature_flags;
   13390                 :            : 
   13391         [ -  + ]:         42 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   13392         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   13393                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   13394                 :          0 :                 return TEST_SKIPPED;
   13395                 :            :         }
   13396                 :            : 
   13397                 :            :         /* Verify the capabilities */
   13398                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   13399                 :            :         const struct rte_cryptodev_symmetric_capability *capability;
   13400                 :         42 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
   13401                 :         42 :         cap_idx.algo.aead = tdata->algo;
   13402                 :         42 :         capability = rte_cryptodev_sym_capability_get(
   13403                 :         42 :                         ts_params->valid_devs[0], &cap_idx);
   13404         [ +  - ]:         42 :         if (capability == NULL)
   13405                 :            :                 return TEST_SKIPPED;
   13406         [ +  + ]:         42 :         if (rte_cryptodev_sym_capability_check_aead(
   13407                 :         42 :                         capability, tdata->key.len, tdata->auth_tag.len,
   13408                 :         42 :                         tdata->aad.len, tdata->iv.len))
   13409                 :            :                 return TEST_SKIPPED;
   13410                 :            : 
   13411                 :            :         /* Create AEAD session */
   13412                 :         41 :         retval = create_aead_session(ts_params->valid_devs[0],
   13413                 :         41 :                         tdata->algo,
   13414                 :            :                         RTE_CRYPTO_AEAD_OP_DECRYPT,
   13415                 :         41 :                         tdata->key.data, tdata->key.len,
   13416                 :         41 :                         tdata->aad.len, tdata->auth_tag.len,
   13417                 :         41 :                         tdata->iv.len);
   13418         [ +  - ]:         41 :         if (retval != TEST_SUCCESS)
   13419                 :            :                 return retval;
   13420                 :            : 
   13421                 :            :         /* alloc mbuf and set payload */
   13422         [ +  + ]:         41 :         if (tdata->aad.len > MBUF_SIZE) {
   13423         [ -  + ]:          2 :                 if (use_ext_mbuf) {
   13424                 :          0 :                         ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
   13425                 :            :                                                           AEAD_TEXT_MAX_LENGTH,
   13426                 :            :                                                           1 /* nb_segs */,
   13427                 :            :                                                           NULL);
   13428                 :            :                 } else {
   13429                 :          2 :                         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
   13430                 :            :                 }
   13431                 :            :                 /* Populate full size of add data */
   13432         [ +  + ]:       4088 :                 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
   13433                 :       4086 :                         memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
   13434                 :            :         } else {
   13435         [ +  + ]:         39 :                 if (use_ext_mbuf) {
   13436                 :          1 :                         ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
   13437                 :            :                                                           AEAD_TEXT_MAX_LENGTH,
   13438                 :            :                                                           1 /* nb_segs */,
   13439                 :            :                                                           NULL);
   13440                 :            :                 } else {
   13441                 :         38 :                         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   13442                 :            :                 }
   13443                 :            :         }
   13444                 :         41 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   13445                 :         41 :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   13446                 :            : 
   13447                 :            :         /* Create AEAD operation */
   13448                 :         41 :         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
   13449         [ +  - ]:         41 :         if (retval < 0)
   13450                 :            :                 return retval;
   13451                 :            : 
   13452         [ +  - ]:         41 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   13453                 :            : 
   13454                 :         41 :         ut_params->op->sym->m_src = ut_params->ibuf;
   13455                 :            : 
   13456                 :            :         /* Process crypto operation */
   13457         [ -  + ]:         41 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   13458                 :          0 :                 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
   13459         [ -  + ]:         41 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   13460                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
   13461                 :            :                                                0);
   13462         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   13463                 :            :                         return retval;
   13464                 :            :         } else
   13465         [ +  + ]:         41 :                 TEST_ASSERT_NOT_NULL(
   13466                 :            :                         process_crypto_request(ts_params->valid_devs[0],
   13467                 :            :                         ut_params->op), "failed to process sym crypto op");
   13468                 :            : 
   13469         [ -  + ]:         36 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   13470                 :            :                         "crypto op processing failed");
   13471                 :            : 
   13472         [ -  + ]:         36 :         if (ut_params->op->sym->m_dst)
   13473                 :          0 :                 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
   13474                 :            :                                 uint8_t *);
   13475                 :            :         else
   13476                 :         36 :                 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
   13477                 :            :                                 uint8_t *,
   13478                 :            :                                 ut_params->op->sym->cipher.data.offset);
   13479                 :            : 
   13480                 :         36 :         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
   13481                 :            : 
   13482                 :            :         /* Validate obuf */
   13483         [ +  + ]:         37 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   13484                 :            :                         plaintext,
   13485                 :            :                         tdata->plaintext.data,
   13486                 :            :                         tdata->plaintext.len,
   13487                 :            :                         "Plaintext data not as expected");
   13488                 :            : 
   13489         [ -  + ]:         35 :         TEST_ASSERT_EQUAL(ut_params->op->status,
   13490                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   13491                 :            :                         "Authentication failed");
   13492                 :            : 
   13493                 :            :         return 0;
   13494                 :            : }
   13495                 :            : 
   13496                 :            : static int
   13497                 :            : test_authenticated_decryption(const struct aead_test_data *tdata)
   13498                 :            : {
   13499                 :         41 :         return test_authenticated_decryption_helper(tdata, false);
   13500                 :            : }
   13501                 :            : 
   13502                 :            : static int
   13503                 :          1 : test_AES_GCM_authenticated_decryption_test_case_1(void)
   13504                 :            : {
   13505                 :          1 :         return test_authenticated_decryption(&gcm_test_case_1);
   13506                 :            : }
   13507                 :            : 
   13508                 :            : static int
   13509                 :          1 : test_AES_GCM_authenticated_decryption_test_case_2(void)
   13510                 :            : {
   13511                 :          1 :         return test_authenticated_decryption(&gcm_test_case_2);
   13512                 :            : }
   13513                 :            : 
   13514                 :            : static int
   13515                 :          1 : test_AES_GCM_authenticated_decryption_test_case_3(void)
   13516                 :            : {
   13517                 :          1 :         return test_authenticated_decryption(&gcm_test_case_3);
   13518                 :            : }
   13519                 :            : 
   13520                 :            : static int
   13521                 :          1 : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
   13522                 :            : {
   13523                 :          1 :         return test_authenticated_decryption_helper(&gcm_test_case_3, true);
   13524                 :            : }
   13525                 :            : 
   13526                 :            : static int
   13527                 :          1 : test_AES_GCM_authenticated_decryption_test_case_4(void)
   13528                 :            : {
   13529                 :          1 :         return test_authenticated_decryption(&gcm_test_case_4);
   13530                 :            : }
   13531                 :            : 
   13532                 :            : static int
   13533                 :          1 : test_AES_GCM_authenticated_decryption_test_case_5(void)
   13534                 :            : {
   13535                 :          1 :         return test_authenticated_decryption(&gcm_test_case_5);
   13536                 :            : }
   13537                 :            : 
   13538                 :            : static int
   13539                 :          1 : test_AES_GCM_authenticated_decryption_test_case_6(void)
   13540                 :            : {
   13541                 :          1 :         return test_authenticated_decryption(&gcm_test_case_6);
   13542                 :            : }
   13543                 :            : 
   13544                 :            : static int
   13545                 :          1 : test_AES_GCM_authenticated_decryption_test_case_7(void)
   13546                 :            : {
   13547                 :          1 :         return test_authenticated_decryption(&gcm_test_case_7);
   13548                 :            : }
   13549                 :            : 
   13550                 :            : static int
   13551                 :          1 : test_AES_GCM_authenticated_decryption_test_case_8(void)
   13552                 :            : {
   13553                 :          1 :         return test_authenticated_decryption(&gcm_test_case_8);
   13554                 :            : }
   13555                 :            : 
   13556                 :            : static int
   13557                 :          1 : test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
   13558                 :            : {
   13559                 :          1 :         return test_authenticated_decryption(&gcm_J0_test_case_1);
   13560                 :            : }
   13561                 :            : 
   13562                 :            : static int
   13563                 :          1 : test_AES_GCM_auth_decryption_test_case_192_1(void)
   13564                 :            : {
   13565                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_1);
   13566                 :            : }
   13567                 :            : 
   13568                 :            : static int
   13569                 :          1 : test_AES_GCM_auth_decryption_test_case_192_2(void)
   13570                 :            : {
   13571                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_2);
   13572                 :            : }
   13573                 :            : 
   13574                 :            : static int
   13575                 :          1 : test_AES_GCM_auth_decryption_test_case_192_3(void)
   13576                 :            : {
   13577                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_3);
   13578                 :            : }
   13579                 :            : 
   13580                 :            : static int
   13581                 :          1 : test_AES_GCM_auth_decryption_test_case_192_4(void)
   13582                 :            : {
   13583                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_4);
   13584                 :            : }
   13585                 :            : 
   13586                 :            : static int
   13587                 :          1 : test_AES_GCM_auth_decryption_test_case_192_5(void)
   13588                 :            : {
   13589                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_5);
   13590                 :            : }
   13591                 :            : 
   13592                 :            : static int
   13593                 :          1 : test_AES_GCM_auth_decryption_test_case_192_6(void)
   13594                 :            : {
   13595                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_6);
   13596                 :            : }
   13597                 :            : 
   13598                 :            : static int
   13599                 :          1 : test_AES_GCM_auth_decryption_test_case_192_7(void)
   13600                 :            : {
   13601                 :          1 :         return test_authenticated_decryption(&gcm_test_case_192_7);
   13602                 :            : }
   13603                 :            : 
   13604                 :            : static int
   13605                 :          1 : test_AES_GCM_auth_decryption_test_case_256_1(void)
   13606                 :            : {
   13607                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_1);
   13608                 :            : }
   13609                 :            : 
   13610                 :            : static int
   13611                 :          1 : test_AES_GCM_auth_decryption_test_case_256_2(void)
   13612                 :            : {
   13613                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_2);
   13614                 :            : }
   13615                 :            : 
   13616                 :            : static int
   13617                 :          1 : test_AES_GCM_auth_decryption_test_case_256_3(void)
   13618                 :            : {
   13619                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_3);
   13620                 :            : }
   13621                 :            : 
   13622                 :            : static int
   13623                 :          1 : test_AES_GCM_auth_decryption_test_case_256_4(void)
   13624                 :            : {
   13625                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_4);
   13626                 :            : }
   13627                 :            : 
   13628                 :            : static int
   13629                 :          1 : test_AES_GCM_auth_decryption_test_case_256_5(void)
   13630                 :            : {
   13631                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_5);
   13632                 :            : }
   13633                 :            : 
   13634                 :            : static int
   13635                 :          1 : test_AES_GCM_auth_decryption_test_case_256_6(void)
   13636                 :            : {
   13637                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_6);
   13638                 :            : }
   13639                 :            : 
   13640                 :            : static int
   13641                 :          1 : test_AES_GCM_auth_decryption_test_case_256_7(void)
   13642                 :            : {
   13643                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_7);
   13644                 :            : }
   13645                 :            : 
   13646                 :            : static int
   13647                 :          1 : test_AES_GCM_auth_decryption_test_case_256_8(void)
   13648                 :            : {
   13649                 :          1 :         return test_authenticated_decryption(&gcm_test_case_256_8);
   13650                 :            : }
   13651                 :            : 
   13652                 :            : static int
   13653                 :          1 : test_AES_GCM_auth_encryption_test_case_256_8(void)
   13654                 :            : {
   13655                 :          1 :         return test_authenticated_encryption(&gcm_test_case_256_8);
   13656                 :            : }
   13657                 :            : 
   13658                 :            : static int
   13659                 :          1 : test_AES_GCM_auth_decryption_test_case_aad_1(void)
   13660                 :            : {
   13661                 :          1 :         return test_authenticated_decryption(&gcm_test_case_aad_1);
   13662                 :            : }
   13663                 :            : 
   13664                 :            : static int
   13665                 :          1 : test_AES_GCM_auth_decryption_test_case_aad_2(void)
   13666                 :            : {
   13667                 :          1 :         return test_authenticated_decryption(&gcm_test_case_aad_2);
   13668                 :            : }
   13669                 :            : 
   13670                 :            : static int
   13671                 :          1 : test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
   13672                 :            : {
   13673                 :            :         struct aead_test_data tdata;
   13674                 :            :         int res;
   13675                 :            : 
   13676                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13677                 :          1 :         tdata.iv.data[0] += 1;
   13678                 :            :         res = test_authenticated_decryption(&tdata);
   13679         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13680                 :            :                 return res;
   13681         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
   13682                 :            :         return TEST_SUCCESS;
   13683                 :            : }
   13684                 :            : 
   13685                 :            : static int
   13686                 :          1 : test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
   13687                 :            : {
   13688                 :            :         struct aead_test_data tdata;
   13689                 :            :         int res;
   13690                 :            : 
   13691                 :          1 :         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
   13692                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13693                 :          1 :         tdata.plaintext.data[0] += 1;
   13694                 :            :         res = test_authenticated_decryption(&tdata);
   13695         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13696                 :            :                 return res;
   13697         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
   13698                 :            :         return TEST_SUCCESS;
   13699                 :            : }
   13700                 :            : 
   13701                 :            : static int
   13702                 :          1 : test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
   13703                 :            : {
   13704                 :            :         struct aead_test_data tdata;
   13705                 :            :         int res;
   13706                 :            : 
   13707                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13708                 :          1 :         tdata.ciphertext.data[0] += 1;
   13709                 :            :         res = test_authenticated_decryption(&tdata);
   13710         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13711                 :            :                 return res;
   13712         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
   13713                 :            :         return TEST_SUCCESS;
   13714                 :            : }
   13715                 :            : 
   13716                 :            : static int
   13717                 :          1 : test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
   13718                 :            : {
   13719                 :            :         struct aead_test_data tdata;
   13720                 :            :         int res;
   13721                 :            : 
   13722                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13723                 :          1 :         tdata.aad.len += 1;
   13724                 :            :         res = test_authenticated_decryption(&tdata);
   13725         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13726                 :            :                 return res;
   13727         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
   13728                 :            :         return TEST_SUCCESS;
   13729                 :            : }
   13730                 :            : 
   13731                 :            : static int
   13732                 :          1 : test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
   13733                 :          1 : {
   13734                 :            :         struct aead_test_data tdata;
   13735                 :            :         uint8_t aad[gcm_test_case_7.aad.len];
   13736                 :            :         int res;
   13737                 :            : 
   13738                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13739                 :            :         memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
   13740                 :          1 :         aad[0] += 1;
   13741                 :          1 :         tdata.aad.data = aad;
   13742                 :            :         res = test_authenticated_decryption(&tdata);
   13743         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13744                 :            :                 return res;
   13745         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
   13746                 :            :         return TEST_SUCCESS;
   13747                 :            : }
   13748                 :            : 
   13749                 :            : static int
   13750                 :          1 : test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
   13751                 :            : {
   13752                 :            :         struct aead_test_data tdata;
   13753                 :            :         int res;
   13754                 :            : 
   13755                 :            :         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
   13756                 :          1 :         tdata.auth_tag.data[0] += 1;
   13757                 :            :         res = test_authenticated_decryption(&tdata);
   13758         [ +  - ]:          1 :         if (res == TEST_SKIPPED)
   13759                 :            :                 return res;
   13760         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
   13761                 :            :         return TEST_SUCCESS;
   13762                 :            : }
   13763                 :            : 
   13764                 :            : static int
   13765                 :          1 : test_authenticated_encryption_oop(const struct aead_test_data *tdata)
   13766                 :            : {
   13767                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   13768                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   13769                 :            : 
   13770                 :            :         int retval;
   13771                 :            :         uint8_t *ciphertext, *auth_tag;
   13772                 :            :         uint16_t plaintext_pad_len;
   13773                 :            :         struct rte_cryptodev_info dev_info;
   13774                 :            : 
   13775                 :            :         /* Verify the capabilities */
   13776                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   13777                 :            :         const struct rte_cryptodev_symmetric_capability *capability;
   13778                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
   13779                 :          1 :         cap_idx.algo.aead = tdata->algo;
   13780                 :          1 :         capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
   13781         [ +  - ]:          1 :         if (capability == NULL)
   13782                 :            :                 return TEST_SKIPPED;
   13783         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_check_aead(
   13784                 :          1 :                 capability, tdata->key.len, tdata->auth_tag.len,
   13785                 :          1 :                 tdata->aad.len, tdata->iv.len))
   13786                 :            :                 return TEST_SKIPPED;
   13787                 :            : 
   13788                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   13789                 :          1 :         uint64_t feat_flags = dev_info.feature_flags;
   13790                 :            : 
   13791         [ -  + ]:          1 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   13792         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
   13793                 :            :                 return TEST_SKIPPED;
   13794                 :            : 
   13795                 :            :         /* not supported with CPU crypto */
   13796         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   13797                 :            :                 return TEST_SKIPPED;
   13798                 :            : 
   13799                 :            :         /* Create AEAD session */
   13800                 :          1 :         retval = create_aead_session(ts_params->valid_devs[0],
   13801                 :          1 :                         tdata->algo,
   13802                 :            :                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
   13803                 :          1 :                         tdata->key.data, tdata->key.len,
   13804                 :          1 :                         tdata->aad.len, tdata->auth_tag.len,
   13805                 :          1 :                         tdata->iv.len);
   13806         [ +  - ]:          1 :         if (retval < 0)
   13807                 :            :                 return retval;
   13808                 :            : 
   13809                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   13810                 :          1 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   13811                 :            : 
   13812                 :            :         /* clear mbuf payload */
   13813                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   13814                 :          1 :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   13815                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
   13816                 :          1 :                         rte_pktmbuf_tailroom(ut_params->obuf));
   13817                 :            : 
   13818                 :            :         /* Create AEAD operation */
   13819                 :          1 :         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
   13820         [ +  - ]:          1 :         if (retval < 0)
   13821                 :            :                 return retval;
   13822                 :            : 
   13823         [ +  - ]:          1 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   13824                 :            : 
   13825                 :          1 :         ut_params->op->sym->m_src = ut_params->ibuf;
   13826                 :          1 :         ut_params->op->sym->m_dst = ut_params->obuf;
   13827                 :            : 
   13828                 :            :         /* Process crypto operation */
   13829         [ -  + ]:          1 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   13830                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
   13831                 :            :                                                0);
   13832         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   13833                 :            :                         return retval;
   13834                 :            :         } else
   13835         [ -  + ]:          1 :                 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
   13836                 :            :                         ut_params->op), "failed to process sym crypto op");
   13837                 :            : 
   13838         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   13839                 :            :                         "crypto op processing failed");
   13840                 :            : 
   13841                 :          1 :         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
   13842                 :            : 
   13843                 :          1 :         ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
   13844                 :            :                         ut_params->op->sym->cipher.data.offset);
   13845                 :          1 :         auth_tag = ciphertext + plaintext_pad_len;
   13846                 :            : 
   13847                 :          1 :         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
   13848                 :          1 :         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
   13849                 :            : 
   13850                 :            :         /* Validate obuf */
   13851         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   13852                 :            :                         ciphertext,
   13853                 :            :                         tdata->ciphertext.data,
   13854                 :            :                         tdata->ciphertext.len,
   13855                 :            :                         "Ciphertext data not as expected");
   13856                 :            : 
   13857         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   13858                 :            :                         auth_tag,
   13859                 :            :                         tdata->auth_tag.data,
   13860                 :            :                         tdata->auth_tag.len,
   13861                 :            :                         "Generated auth tag not as expected");
   13862                 :            : 
   13863                 :            :         return 0;
   13864                 :            : 
   13865                 :            : }
   13866                 :            : 
   13867                 :            : static int
   13868                 :          1 : test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
   13869                 :            : {
   13870                 :          1 :         return test_authenticated_encryption_oop(&gcm_test_case_5);
   13871                 :            : }
   13872                 :            : 
   13873                 :            : static int
   13874                 :          1 : test_authenticated_decryption_oop(const struct aead_test_data *tdata)
   13875                 :            : {
   13876                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   13877                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   13878                 :            : 
   13879                 :            :         int retval;
   13880                 :            :         uint8_t *plaintext;
   13881                 :            :         struct rte_cryptodev_info dev_info;
   13882                 :            : 
   13883                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   13884                 :            :         uint64_t feat_flags = dev_info.feature_flags;
   13885                 :            : 
   13886                 :            :         /* Verify the capabilities */
   13887                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   13888                 :            :         const struct rte_cryptodev_symmetric_capability *capability;
   13889                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
   13890                 :          1 :         cap_idx.algo.aead = tdata->algo;
   13891                 :          1 :         capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
   13892                 :            : 
   13893         [ +  - ]:          1 :         if (capability == NULL)
   13894                 :            :                 return TEST_SKIPPED;
   13895                 :            : 
   13896         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
   13897                 :          1 :                         tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
   13898                 :            :                 return TEST_SKIPPED;
   13899                 :            : 
   13900                 :            :         /* not supported with CPU crypto and raw data-path APIs*/
   13901         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
   13902         [ +  - ]:          1 :                         global_api_test_type == CRYPTODEV_RAW_API_TEST)
   13903                 :            :                 return TEST_SKIPPED;
   13904                 :            : 
   13905                 :            :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   13906                 :            :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   13907                 :            :                 printf("Device does not support RAW data-path APIs.\n");
   13908                 :            :                 return TEST_SKIPPED;
   13909                 :            :         }
   13910                 :            : 
   13911                 :            :         /* Create AEAD session */
   13912                 :          1 :         retval = create_aead_session(ts_params->valid_devs[0],
   13913                 :          1 :                         tdata->algo,
   13914                 :            :                         RTE_CRYPTO_AEAD_OP_DECRYPT,
   13915                 :          1 :                         tdata->key.data, tdata->key.len,
   13916                 :          1 :                         tdata->aad.len, tdata->auth_tag.len,
   13917                 :          1 :                         tdata->iv.len);
   13918         [ +  - ]:          1 :         if (retval < 0)
   13919                 :            :                 return retval;
   13920                 :            : 
   13921                 :            :         /* alloc mbuf and set payload */
   13922                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   13923                 :          1 :         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   13924                 :            : 
   13925                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   13926                 :          1 :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   13927                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
   13928                 :          1 :                         rte_pktmbuf_tailroom(ut_params->obuf));
   13929                 :            : 
   13930                 :            :         /* Create AEAD operation */
   13931                 :          1 :         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
   13932         [ +  - ]:          1 :         if (retval < 0)
   13933                 :            :                 return retval;
   13934                 :            : 
   13935         [ +  - ]:          1 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   13936                 :            : 
   13937                 :          1 :         ut_params->op->sym->m_src = ut_params->ibuf;
   13938                 :          1 :         ut_params->op->sym->m_dst = ut_params->obuf;
   13939                 :            : 
   13940                 :            :         /* Process crypto operation */
   13941         [ -  + ]:          1 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   13942                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
   13943                 :            :                                                0);
   13944         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   13945                 :            :                         return retval;
   13946                 :            :         } else
   13947         [ -  + ]:          1 :                 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
   13948                 :            :                         ut_params->op), "failed to process sym crypto op");
   13949                 :            : 
   13950         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   13951                 :            :                         "crypto op processing failed");
   13952                 :            : 
   13953                 :          1 :         plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
   13954                 :            :                         ut_params->op->sym->cipher.data.offset);
   13955                 :            : 
   13956                 :          1 :         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
   13957                 :            : 
   13958                 :            :         /* Validate obuf */
   13959         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   13960                 :            :                         plaintext,
   13961                 :            :                         tdata->plaintext.data,
   13962                 :            :                         tdata->plaintext.len,
   13963                 :            :                         "Plaintext data not as expected");
   13964                 :            : 
   13965         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status,
   13966                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   13967                 :            :                         "Authentication failed");
   13968                 :            :         return 0;
   13969                 :            : }
   13970                 :            : 
   13971                 :            : static int
   13972                 :          1 : test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
   13973                 :            : {
   13974                 :          1 :         return test_authenticated_decryption_oop(&gcm_test_case_5);
   13975                 :            : }
   13976                 :            : 
   13977                 :            : static int
   13978                 :          1 : test_authenticated_encryption_sessionless(
   13979                 :            :                 const struct aead_test_data *tdata)
   13980                 :          1 : {
   13981                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   13982                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   13983                 :            : 
   13984                 :            :         int retval;
   13985                 :            :         uint8_t *ciphertext, *auth_tag;
   13986                 :            :         uint16_t plaintext_pad_len;
   13987                 :          1 :         uint8_t key[tdata->key.len + 1];
   13988                 :            :         struct rte_cryptodev_info dev_info;
   13989                 :            : 
   13990                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   13991                 :          1 :         uint64_t feat_flags = dev_info.feature_flags;
   13992                 :            : 
   13993         [ -  + ]:          1 :         if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
   13994                 :            :                 printf("Device doesn't support Sessionless ops.\n");
   13995                 :          0 :                 return TEST_SKIPPED;
   13996                 :            :         }
   13997                 :            : 
   13998                 :            :         /* not supported with CPU crypto */
   13999         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   14000                 :            :                 return TEST_SKIPPED;
   14001                 :            : 
   14002                 :            :         /* Verify the capabilities */
   14003                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14004                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
   14005                 :          1 :         cap_idx.algo.aead = tdata->algo;
   14006         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14007                 :            :                         &cap_idx) == NULL)
   14008                 :            :                 return TEST_SKIPPED;
   14009                 :            : 
   14010                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   14011                 :            : 
   14012                 :            :         /* clear mbuf payload */
   14013                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   14014                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   14015                 :            : 
   14016                 :            :         /* Create AEAD operation */
   14017                 :          1 :         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
   14018         [ +  - ]:          1 :         if (retval < 0)
   14019                 :            :                 return retval;
   14020                 :            : 
   14021                 :            :         /* Create GCM xform */
   14022                 :          1 :         memcpy(key, tdata->key.data, tdata->key.len);
   14023                 :          1 :         retval = create_aead_xform(ut_params->op,
   14024                 :          1 :                         tdata->algo,
   14025                 :            :                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
   14026                 :            :                         key, tdata->key.len,
   14027                 :          1 :                         tdata->aad.len, tdata->auth_tag.len,
   14028                 :          1 :                         tdata->iv.len);
   14029         [ +  - ]:          1 :         if (retval < 0)
   14030                 :            :                 return retval;
   14031                 :            : 
   14032                 :          1 :         ut_params->op->sym->m_src = ut_params->ibuf;
   14033                 :            : 
   14034         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->sess_type,
   14035                 :            :                         RTE_CRYPTO_OP_SESSIONLESS,
   14036                 :            :                         "crypto op session type not sessionless");
   14037                 :            : 
   14038                 :            :         /* Process crypto operation */
   14039         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
   14040                 :            :                         ut_params->op), "failed to process sym crypto op");
   14041                 :            : 
   14042         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
   14043                 :            : 
   14044         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   14045                 :            :                         "crypto op status not success");
   14046                 :            : 
   14047                 :          1 :         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
   14048                 :            : 
   14049                 :          1 :         ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
   14050                 :            :                         ut_params->op->sym->cipher.data.offset);
   14051                 :          1 :         auth_tag = ciphertext + plaintext_pad_len;
   14052                 :            : 
   14053                 :          1 :         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
   14054                 :          1 :         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
   14055                 :            : 
   14056                 :            :         /* Validate obuf */
   14057         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   14058                 :            :                         ciphertext,
   14059                 :            :                         tdata->ciphertext.data,
   14060                 :            :                         tdata->ciphertext.len,
   14061                 :            :                         "Ciphertext data not as expected");
   14062                 :            : 
   14063         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   14064                 :            :                         auth_tag,
   14065                 :            :                         tdata->auth_tag.data,
   14066                 :            :                         tdata->auth_tag.len,
   14067                 :            :                         "Generated auth tag not as expected");
   14068                 :            : 
   14069                 :            :         return 0;
   14070                 :            : 
   14071                 :            : }
   14072                 :            : 
   14073                 :            : static int
   14074                 :          1 : test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
   14075                 :            : {
   14076                 :          1 :         return test_authenticated_encryption_sessionless(
   14077                 :            :                         &gcm_test_case_5);
   14078                 :            : }
   14079                 :            : 
   14080                 :            : static int
   14081                 :          1 : test_authenticated_decryption_sessionless(
   14082                 :            :                 const struct aead_test_data *tdata)
   14083                 :          1 : {
   14084                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14085                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   14086                 :            : 
   14087                 :            :         int retval;
   14088                 :            :         uint8_t *plaintext;
   14089                 :          1 :         uint8_t key[tdata->key.len + 1];
   14090                 :            :         struct rte_cryptodev_info dev_info;
   14091                 :            : 
   14092                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   14093                 :          1 :         uint64_t feat_flags = dev_info.feature_flags;
   14094                 :            : 
   14095         [ -  + ]:          1 :         if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
   14096                 :            :                 printf("Device doesn't support Sessionless ops.\n");
   14097                 :          0 :                 return TEST_SKIPPED;
   14098                 :            :         }
   14099                 :            : 
   14100         [ -  + ]:          1 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   14101         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   14102                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   14103                 :          0 :                 return TEST_SKIPPED;
   14104                 :            :         }
   14105                 :            : 
   14106                 :            :         /* not supported with CPU crypto */
   14107         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   14108                 :            :                 return TEST_SKIPPED;
   14109                 :            : 
   14110                 :            :         /* Verify the capabilities */
   14111                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14112                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
   14113                 :          1 :         cap_idx.algo.aead = tdata->algo;
   14114         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14115                 :            :                         &cap_idx) == NULL)
   14116                 :            :                 return TEST_SKIPPED;
   14117                 :            : 
   14118                 :            :         /* alloc mbuf and set payload */
   14119                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   14120                 :            : 
   14121                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   14122                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   14123                 :            : 
   14124                 :            :         /* Create AEAD operation */
   14125                 :          1 :         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
   14126         [ +  - ]:          1 :         if (retval < 0)
   14127                 :            :                 return retval;
   14128                 :            : 
   14129                 :            :         /* Create AEAD xform */
   14130                 :          1 :         memcpy(key, tdata->key.data, tdata->key.len);
   14131                 :          1 :         retval = create_aead_xform(ut_params->op,
   14132                 :          1 :                         tdata->algo,
   14133                 :            :                         RTE_CRYPTO_AEAD_OP_DECRYPT,
   14134                 :            :                         key, tdata->key.len,
   14135                 :          1 :                         tdata->aad.len, tdata->auth_tag.len,
   14136                 :          1 :                         tdata->iv.len);
   14137         [ +  - ]:          1 :         if (retval < 0)
   14138                 :            :                 return retval;
   14139                 :            : 
   14140                 :          1 :         ut_params->op->sym->m_src = ut_params->ibuf;
   14141                 :            : 
   14142         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->sess_type,
   14143                 :            :                         RTE_CRYPTO_OP_SESSIONLESS,
   14144                 :            :                         "crypto op session type not sessionless");
   14145                 :            : 
   14146                 :            :         /* Process crypto operation */
   14147         [ -  + ]:          1 :         if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   14148                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
   14149                 :            :                                                0);
   14150         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   14151                 :            :                         return retval;
   14152                 :            :         } else
   14153         [ -  + ]:          1 :                 TEST_ASSERT_NOT_NULL(process_crypto_request(
   14154                 :            :                         ts_params->valid_devs[0], ut_params->op),
   14155                 :            :                                 "failed to process sym crypto op");
   14156                 :            : 
   14157         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
   14158                 :            : 
   14159         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   14160                 :            :                         "crypto op status not success");
   14161                 :            : 
   14162                 :          1 :         plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
   14163                 :            :                         ut_params->op->sym->cipher.data.offset);
   14164                 :            : 
   14165                 :          1 :         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
   14166                 :            : 
   14167                 :            :         /* Validate obuf */
   14168         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   14169                 :            :                         plaintext,
   14170                 :            :                         tdata->plaintext.data,
   14171                 :            :                         tdata->plaintext.len,
   14172                 :            :                         "Plaintext data not as expected");
   14173                 :            : 
   14174         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status,
   14175                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   14176                 :            :                         "Authentication failed");
   14177                 :            :         return 0;
   14178                 :            : }
   14179                 :            : 
   14180                 :            : static int
   14181                 :          1 : test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
   14182                 :            : {
   14183                 :          1 :         return test_authenticated_decryption_sessionless(
   14184                 :            :                         &gcm_test_case_5);
   14185                 :            : }
   14186                 :            : 
   14187                 :            : static int
   14188                 :          1 : test_AES_CCM_authenticated_encryption_test_case_128_1(void)
   14189                 :            : {
   14190                 :          1 :         return test_authenticated_encryption(&ccm_test_case_128_1);
   14191                 :            : }
   14192                 :            : 
   14193                 :            : static int
   14194                 :          1 : test_AES_CCM_authenticated_encryption_test_case_128_2(void)
   14195                 :            : {
   14196                 :          1 :         return test_authenticated_encryption(&ccm_test_case_128_2);
   14197                 :            : }
   14198                 :            : 
   14199                 :            : static int
   14200                 :          1 : test_AES_CCM_authenticated_encryption_test_case_128_3(void)
   14201                 :            : {
   14202                 :          1 :         return test_authenticated_encryption(&ccm_test_case_128_3);
   14203                 :            : }
   14204                 :            : 
   14205                 :            : static int
   14206                 :          1 : test_AES_CCM_authenticated_decryption_test_case_128_1(void)
   14207                 :            : {
   14208                 :          1 :         return test_authenticated_decryption(&ccm_test_case_128_1);
   14209                 :            : }
   14210                 :            : 
   14211                 :            : static int
   14212                 :          1 : test_AES_CCM_authenticated_decryption_test_case_128_2(void)
   14213                 :            : {
   14214                 :          1 :         return test_authenticated_decryption(&ccm_test_case_128_2);
   14215                 :            : }
   14216                 :            : 
   14217                 :            : static int
   14218                 :          1 : test_AES_CCM_authenticated_decryption_test_case_128_3(void)
   14219                 :            : {
   14220                 :          1 :         return test_authenticated_decryption(&ccm_test_case_128_3);
   14221                 :            : }
   14222                 :            : 
   14223                 :            : static int
   14224                 :          1 : test_AES_CCM_authenticated_encryption_test_case_192_1(void)
   14225                 :            : {
   14226                 :          1 :         return test_authenticated_encryption(&ccm_test_case_192_1);
   14227                 :            : }
   14228                 :            : 
   14229                 :            : static int
   14230                 :          1 : test_AES_CCM_authenticated_encryption_test_case_192_2(void)
   14231                 :            : {
   14232                 :          1 :         return test_authenticated_encryption(&ccm_test_case_192_2);
   14233                 :            : }
   14234                 :            : 
   14235                 :            : static int
   14236                 :          1 : test_AES_CCM_authenticated_encryption_test_case_192_3(void)
   14237                 :            : {
   14238                 :          1 :         return test_authenticated_encryption(&ccm_test_case_192_3);
   14239                 :            : }
   14240                 :            : 
   14241                 :            : static int
   14242                 :          1 : test_AES_CCM_authenticated_decryption_test_case_192_1(void)
   14243                 :            : {
   14244                 :          1 :         return test_authenticated_decryption(&ccm_test_case_192_1);
   14245                 :            : }
   14246                 :            : 
   14247                 :            : static int
   14248                 :          1 : test_AES_CCM_authenticated_decryption_test_case_192_2(void)
   14249                 :            : {
   14250                 :          1 :         return test_authenticated_decryption(&ccm_test_case_192_2);
   14251                 :            : }
   14252                 :            : 
   14253                 :            : static int
   14254                 :          1 : test_AES_CCM_authenticated_decryption_test_case_192_3(void)
   14255                 :            : {
   14256                 :          1 :         return test_authenticated_decryption(&ccm_test_case_192_3);
   14257                 :            : }
   14258                 :            : 
   14259                 :            : static int
   14260                 :          1 : test_AES_CCM_authenticated_encryption_test_case_256_1(void)
   14261                 :            : {
   14262                 :          1 :         return test_authenticated_encryption(&ccm_test_case_256_1);
   14263                 :            : }
   14264                 :            : 
   14265                 :            : static int
   14266                 :          1 : test_AES_CCM_authenticated_encryption_test_case_256_2(void)
   14267                 :            : {
   14268                 :          1 :         return test_authenticated_encryption(&ccm_test_case_256_2);
   14269                 :            : }
   14270                 :            : 
   14271                 :            : static int
   14272                 :          1 : test_AES_CCM_authenticated_encryption_test_case_256_3(void)
   14273                 :            : {
   14274                 :          1 :         return test_authenticated_encryption(&ccm_test_case_256_3);
   14275                 :            : }
   14276                 :            : 
   14277                 :            : static int
   14278                 :          1 : test_AES_CCM_authenticated_decryption_test_case_256_1(void)
   14279                 :            : {
   14280                 :          1 :         return test_authenticated_decryption(&ccm_test_case_256_1);
   14281                 :            : }
   14282                 :            : 
   14283                 :            : static int
   14284                 :          1 : test_AES_CCM_authenticated_decryption_test_case_256_2(void)
   14285                 :            : {
   14286                 :          1 :         return test_authenticated_decryption(&ccm_test_case_256_2);
   14287                 :            : }
   14288                 :            : 
   14289                 :            : static int
   14290                 :          1 : test_AES_CCM_authenticated_decryption_test_case_256_3(void)
   14291                 :            : {
   14292                 :          1 :         return test_authenticated_decryption(&ccm_test_case_256_3);
   14293                 :            : }
   14294                 :            : 
   14295                 :            : static int
   14296                 :          1 : test_stats(void)
   14297                 :            : {
   14298                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14299                 :            :         struct rte_cryptodev_stats stats;
   14300                 :            : 
   14301         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   14302                 :            :                 return TEST_SKIPPED;
   14303                 :            : 
   14304                 :            :         /* Verify the capabilities */
   14305                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14306                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14307                 :          1 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
   14308         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14309                 :            :                         &cap_idx) == NULL)
   14310                 :            :                 return TEST_SKIPPED;
   14311                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   14312                 :          1 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
   14313         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14314                 :            :                         &cap_idx) == NULL)
   14315                 :            :                 return TEST_SKIPPED;
   14316                 :            : 
   14317         [ +  - ]:          1 :         if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
   14318                 :            :                         == -ENOTSUP)
   14319                 :            :                 return TEST_SKIPPED;
   14320                 :            : 
   14321                 :          1 :         rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
   14322         [ -  + ]:          1 :         TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
   14323                 :            :                         &stats) == -ENODEV),
   14324                 :            :                 "rte_cryptodev_stats_get invalid dev failed");
   14325         [ -  + ]:          1 :         TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
   14326                 :            :                 "rte_cryptodev_stats_get invalid Param failed");
   14327                 :            : 
   14328                 :            :         /* Test expected values */
   14329                 :          1 :         test_AES_CBC_HMAC_SHA1_encrypt_digest();
   14330         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
   14331                 :            :                         &stats),
   14332                 :            :                 "rte_cryptodev_stats_get failed");
   14333         [ -  + ]:          1 :         TEST_ASSERT((stats.enqueued_count == 1),
   14334                 :            :                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
   14335         [ -  + ]:          1 :         TEST_ASSERT((stats.dequeued_count == 1),
   14336                 :            :                 "rte_cryptodev_stats_get returned unexpected dequeued stat");
   14337         [ -  + ]:          1 :         TEST_ASSERT((stats.enqueue_err_count == 0),
   14338                 :            :                 "rte_cryptodev_stats_get returned unexpected enqueued error count stat");
   14339         [ -  + ]:          1 :         TEST_ASSERT((stats.dequeue_err_count == 0),
   14340                 :            :                 "rte_cryptodev_stats_get returned unexpected dequeued error count stat");
   14341                 :            : 
   14342                 :            :         /* invalid device but should ignore and not reset device stats*/
   14343                 :          1 :         rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
   14344         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
   14345                 :            :                         &stats),
   14346                 :            :                 "rte_cryptodev_stats_get failed");
   14347         [ -  + ]:          1 :         TEST_ASSERT((stats.enqueued_count == 1),
   14348                 :            :                 "rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
   14349                 :            : 
   14350                 :            :         /* check that a valid reset clears stats */
   14351                 :          1 :         rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
   14352         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
   14353                 :            :                         &stats),
   14354                 :            :                                           "rte_cryptodev_stats_get failed");
   14355         [ -  + ]:          1 :         TEST_ASSERT((stats.enqueued_count == 0),
   14356                 :            :                 "rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
   14357         [ -  + ]:          1 :         TEST_ASSERT((stats.dequeued_count == 0),
   14358                 :            :                 "rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
   14359                 :            : 
   14360                 :            :         return TEST_SUCCESS;
   14361                 :            : }
   14362                 :            : 
   14363                 :            : static int
   14364                 :          1 : test_device_reconfigure(void)
   14365                 :            : {
   14366                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14367                 :          1 :         uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
   14368                 :          1 :         struct rte_cryptodev_qp_conf qp_conf = {
   14369                 :            :                 .nb_descriptors = MAX_NUM_OPS_INFLIGHT,
   14370                 :          1 :                 .mp_session = ts_params->session_mpool
   14371                 :            :         };
   14372                 :            :         uint16_t qp_id, dev_id, num_devs = 0;
   14373                 :            : 
   14374         [ -  + ]:          1 :         TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
   14375                 :            :                         "Need at least %d devices for test", 1);
   14376                 :            : 
   14377                 :          1 :         dev_id = ts_params->valid_devs[0];
   14378                 :            : 
   14379                 :            :         /* Stop the device in case it's started so it can be configured */
   14380                 :          1 :         rte_cryptodev_stop(dev_id);
   14381                 :            : 
   14382         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
   14383                 :            :                         "Failed test for rte_cryptodev_configure: "
   14384                 :            :                         "dev_num %u", dev_id);
   14385                 :            : 
   14386                 :            :         /* Reconfigure with same configure params */
   14387         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
   14388                 :            :                         "Failed test for rte_cryptodev_configure: "
   14389                 :            :                         "dev_num %u", dev_id);
   14390                 :            : 
   14391                 :            :         /* Reconfigure with just one queue pair */
   14392                 :          1 :         ts_params->conf.nb_queue_pairs = 1;
   14393                 :            : 
   14394         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
   14395                 :            :                         &ts_params->conf),
   14396                 :            :                         "Failed to configure cryptodev: dev_id %u, qp_id %u",
   14397                 :            :                         ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
   14398                 :            : 
   14399         [ +  + ]:          2 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
   14400         [ -  + ]:          1 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
   14401                 :            :                                 ts_params->valid_devs[0], qp_id, &qp_conf,
   14402                 :            :                                 rte_cryptodev_socket_id(
   14403                 :            :                                                 ts_params->valid_devs[0])),
   14404                 :            :                                 "Failed test for "
   14405                 :            :                                 "rte_cryptodev_queue_pair_setup: num_inflights "
   14406                 :            :                                 "%u on qp %u on cryptodev %u",
   14407                 :            :                                 qp_conf.nb_descriptors, qp_id,
   14408                 :            :                                 ts_params->valid_devs[0]);
   14409                 :            :         }
   14410                 :            : 
   14411                 :            :         /* Reconfigure with max number of queue pairs */
   14412                 :          1 :         ts_params->conf.nb_queue_pairs = orig_nb_qps;
   14413                 :            : 
   14414         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
   14415                 :            :                         &ts_params->conf),
   14416                 :            :                         "Failed to configure cryptodev: dev_id %u, qp_id %u",
   14417                 :            :                         ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
   14418                 :            : 
   14419                 :          1 :         qp_conf.mp_session = ts_params->session_mpool;
   14420                 :            : 
   14421         [ +  + ]:          9 :         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
   14422         [ -  + ]:          8 :                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
   14423                 :            :                                 ts_params->valid_devs[0], qp_id, &qp_conf,
   14424                 :            :                                 rte_cryptodev_socket_id(
   14425                 :            :                                                 ts_params->valid_devs[0])),
   14426                 :            :                                 "Failed test for "
   14427                 :            :                                 "rte_cryptodev_queue_pair_setup: num_inflights "
   14428                 :            :                                 "%u on qp %u on cryptodev %u",
   14429                 :            :                                 qp_conf.nb_descriptors, qp_id,
   14430                 :            :                                 ts_params->valid_devs[0]);
   14431                 :            :         }
   14432                 :            : 
   14433                 :            :         /* Start the device */
   14434         [ -  + ]:          1 :         TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
   14435                 :            :                         "Failed to start cryptodev %u",
   14436                 :            :                         ts_params->valid_devs[0]);
   14437                 :            : 
   14438                 :            :         /* Test expected values */
   14439                 :          1 :         return test_AES_CBC_HMAC_SHA1_encrypt_digest();
   14440                 :            : }
   14441                 :            : 
   14442                 :          4 : static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
   14443                 :            :                                    struct crypto_unittest_params *ut_params,
   14444                 :            :                                    enum rte_crypto_auth_operation op,
   14445                 :            :                                    const struct HMAC_MD5_vector *test_case)
   14446                 :            : {
   14447                 :            :         uint8_t key[64];
   14448                 :            : 
   14449                 :          4 :         memcpy(key, test_case->key.data, test_case->key.len);
   14450                 :            : 
   14451                 :          4 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14452                 :          4 :         ut_params->auth_xform.next = NULL;
   14453                 :          4 :         ut_params->auth_xform.auth.op = op;
   14454                 :            : 
   14455                 :          4 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
   14456                 :            : 
   14457                 :          4 :         ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
   14458                 :          4 :         ut_params->auth_xform.auth.key.length = test_case->key.len;
   14459                 :          4 :         ut_params->auth_xform.auth.key.data = key;
   14460                 :            : 
   14461                 :          8 :         ut_params->sess = rte_cryptodev_sym_session_create(
   14462                 :          4 :                 ts_params->valid_devs[0], &ut_params->auth_xform,
   14463                 :            :                         ts_params->session_mpool);
   14464   [ -  +  -  - ]:          4 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   14465                 :            :                 return TEST_SKIPPED;
   14466         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   14467                 :            : 
   14468                 :          4 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   14469                 :            : 
   14470                 :          4 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   14471                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   14472                 :            : 
   14473                 :          4 :         return 0;
   14474                 :            : }
   14475                 :            : 
   14476                 :          4 : static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
   14477                 :            :                               const struct HMAC_MD5_vector *test_case,
   14478                 :            :                               uint8_t **plaintext)
   14479                 :            : {
   14480                 :            :         uint16_t plaintext_pad_len;
   14481                 :            : 
   14482                 :          4 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
   14483                 :            : 
   14484                 :          4 :         plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
   14485                 :            :                                 16);
   14486                 :            : 
   14487                 :          4 :         *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   14488                 :            :                         plaintext_pad_len);
   14489                 :          4 :         memcpy(*plaintext, test_case->plaintext.data,
   14490                 :          4 :                         test_case->plaintext.len);
   14491                 :            : 
   14492                 :          4 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
   14493                 :            :                         ut_params->ibuf, MD5_DIGEST_LEN);
   14494         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
   14495                 :            :                         "no room to append digest");
   14496         [ +  + ]:          4 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
   14497                 :            :                         ut_params->ibuf, plaintext_pad_len);
   14498                 :            : 
   14499         [ +  + ]:          4 :         if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
   14500                 :          2 :                 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
   14501         [ -  + ]:          2 :                            test_case->auth_tag.len);
   14502                 :            :         }
   14503                 :            : 
   14504                 :          4 :         sym_op->auth.data.offset = 0;
   14505                 :          4 :         sym_op->auth.data.length = test_case->plaintext.len;
   14506                 :            : 
   14507         [ +  - ]:          4 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   14508                 :          4 :         ut_params->op->sym->m_src = ut_params->ibuf;
   14509                 :            : 
   14510                 :          4 :         return 0;
   14511                 :            : }
   14512                 :            : 
   14513                 :            : static int
   14514                 :          2 : test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
   14515                 :            : {
   14516                 :            :         uint16_t plaintext_pad_len;
   14517                 :            :         uint8_t *plaintext, *auth_tag;
   14518                 :            :         int ret;
   14519                 :            : 
   14520                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14521                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   14522                 :            :         struct rte_cryptodev_info dev_info;
   14523                 :            : 
   14524                 :          2 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   14525                 :          2 :         uint64_t feat_flags = dev_info.feature_flags;
   14526                 :            : 
   14527         [ -  + ]:          2 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   14528         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   14529                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   14530                 :          0 :                 return TEST_SKIPPED;
   14531                 :            :         }
   14532                 :            : 
   14533                 :            :         /* Verify the capabilities */
   14534                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14535                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14536                 :          2 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
   14537         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14538                 :            :                         &cap_idx) == NULL)
   14539                 :            :                 return TEST_SKIPPED;
   14540                 :            : 
   14541         [ +  - ]:          2 :         if (MD5_HMAC_create_session(ts_params, ut_params,
   14542                 :            :                         RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
   14543                 :            :                 return TEST_FAILED;
   14544                 :            : 
   14545                 :            :         /* Generate Crypto op data structure */
   14546                 :          2 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   14547                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   14548         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   14549                 :            :                         "Failed to allocate symmetric crypto operation struct");
   14550                 :            : 
   14551                 :          2 :         plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
   14552                 :            :                                 16);
   14553                 :            : 
   14554         [ +  - ]:          2 :         if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
   14555                 :            :                 return TEST_FAILED;
   14556                 :            : 
   14557         [ -  + ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   14558                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   14559                 :            :                         ut_params->op);
   14560         [ -  + ]:          2 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   14561                 :          0 :                 ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
   14562         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
   14563                 :            :                         return ret;
   14564                 :            :         } else
   14565         [ -  + ]:          2 :                 TEST_ASSERT_NOT_NULL(
   14566                 :            :                         process_crypto_request(ts_params->valid_devs[0],
   14567                 :            :                                 ut_params->op),
   14568                 :            :                                 "failed to process sym crypto op");
   14569                 :            : 
   14570         [ -  + ]:          2 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   14571                 :            :                         "crypto op processing failed");
   14572                 :            : 
   14573         [ -  + ]:          2 :         if (ut_params->op->sym->m_dst) {
   14574                 :          0 :                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
   14575                 :            :                                 uint8_t *, plaintext_pad_len);
   14576                 :            :         } else {
   14577                 :          2 :                 auth_tag = plaintext + plaintext_pad_len;
   14578                 :            :         }
   14579                 :            : 
   14580         [ -  + ]:          2 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   14581                 :            :                         auth_tag,
   14582                 :            :                         test_case->auth_tag.data,
   14583                 :            :                         test_case->auth_tag.len,
   14584                 :            :                         "HMAC_MD5 generated tag not as expected");
   14585                 :            : 
   14586                 :            :         return TEST_SUCCESS;
   14587                 :            : }
   14588                 :            : 
   14589                 :            : static int
   14590                 :          2 : test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
   14591                 :            : {
   14592                 :            :         uint8_t *plaintext;
   14593                 :            :         int ret;
   14594                 :            : 
   14595                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14596                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   14597                 :            :         struct rte_cryptodev_info dev_info;
   14598                 :            : 
   14599                 :          2 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   14600                 :          2 :         uint64_t feat_flags = dev_info.feature_flags;
   14601                 :            : 
   14602         [ -  + ]:          2 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   14603         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   14604                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   14605                 :          0 :                 return TEST_SKIPPED;
   14606                 :            :         }
   14607                 :            : 
   14608                 :            :         /* Verify the capabilities */
   14609                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14610                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14611                 :          2 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
   14612         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14613                 :            :                         &cap_idx) == NULL)
   14614                 :            :                 return TEST_SKIPPED;
   14615                 :            : 
   14616         [ +  - ]:          2 :         if (MD5_HMAC_create_session(ts_params, ut_params,
   14617                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
   14618                 :            :                 return TEST_FAILED;
   14619                 :            :         }
   14620                 :            : 
   14621                 :            :         /* Generate Crypto op data structure */
   14622                 :          2 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   14623                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   14624         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   14625                 :            :                         "Failed to allocate symmetric crypto operation struct");
   14626                 :            : 
   14627         [ +  - ]:          2 :         if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
   14628                 :            :                 return TEST_FAILED;
   14629                 :            : 
   14630         [ -  + ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   14631                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   14632                 :            :                         ut_params->op);
   14633         [ -  + ]:          2 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   14634                 :          0 :                 ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
   14635         [ #  # ]:          0 :                 if (ret != TEST_SUCCESS)
   14636                 :            :                         return ret;
   14637                 :            :         } else
   14638         [ -  + ]:          2 :                 TEST_ASSERT_NOT_NULL(
   14639                 :            :                         process_crypto_request(ts_params->valid_devs[0],
   14640                 :            :                                 ut_params->op),
   14641                 :            :                                 "failed to process sym crypto op");
   14642                 :            : 
   14643         [ -  + ]:          2 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   14644                 :            :                         "HMAC_MD5 crypto op processing failed");
   14645                 :            : 
   14646                 :            :         return TEST_SUCCESS;
   14647                 :            : }
   14648                 :            : 
   14649                 :            : static int
   14650                 :          1 : test_MD5_HMAC_generate_case_1(void)
   14651                 :            : {
   14652                 :          1 :         return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
   14653                 :            : }
   14654                 :            : 
   14655                 :            : static int
   14656                 :          1 : test_MD5_HMAC_verify_case_1(void)
   14657                 :            : {
   14658                 :          1 :         return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
   14659                 :            : }
   14660                 :            : 
   14661                 :            : static int
   14662                 :          1 : test_MD5_HMAC_generate_case_2(void)
   14663                 :            : {
   14664                 :          1 :         return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
   14665                 :            : }
   14666                 :            : 
   14667                 :            : static int
   14668                 :          1 : test_MD5_HMAC_verify_case_2(void)
   14669                 :            : {
   14670                 :          1 :         return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
   14671                 :            : }
   14672                 :            : 
   14673                 :            : static int
   14674                 :          1 : test_multi_session(void)
   14675                 :            : {
   14676                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14677                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   14678                 :            :         struct rte_cryptodev_info dev_info;
   14679                 :            :         int i, nb_sess, ret = TEST_SUCCESS;
   14680                 :            :         void **sessions;
   14681                 :            : 
   14682                 :            :         /* Verify the capabilities */
   14683                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14684                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14685                 :          1 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
   14686         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14687                 :            :                         &cap_idx) == NULL)
   14688                 :            :                 return TEST_SKIPPED;
   14689                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   14690                 :          1 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
   14691         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14692                 :            :                         &cap_idx) == NULL)
   14693                 :            :                 return TEST_SKIPPED;
   14694                 :            : 
   14695                 :            :         test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
   14696                 :            :                         aes_cbc_key, hmac_sha512_key);
   14697                 :            : 
   14698                 :            : 
   14699                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   14700                 :            : 
   14701                 :          1 :         sessions = rte_malloc(NULL,
   14702                 :            :                         sizeof(void *) *
   14703                 :            :                         (MAX_NB_SESSIONS + 1), 0);
   14704                 :            : 
   14705                 :            :         /* Create multiple crypto sessions*/
   14706         [ +  + ]:          5 :         for (i = 0; i < MAX_NB_SESSIONS; i++) {
   14707                 :          8 :                 sessions[i] = rte_cryptodev_sym_session_create(
   14708                 :          4 :                         ts_params->valid_devs[0], &ut_params->auth_xform,
   14709                 :            :                                 ts_params->session_mpool);
   14710   [ -  +  -  - ]:          4 :                 if (sessions[i] == NULL && rte_errno == ENOTSUP) {
   14711                 :            :                         nb_sess = i;
   14712                 :            :                         ret = TEST_SKIPPED;
   14713                 :            :                         break;
   14714                 :            :                 }
   14715                 :            : 
   14716         [ -  + ]:          4 :                 TEST_ASSERT_NOT_NULL(sessions[i],
   14717                 :            :                                 "Session creation failed at session number %u",
   14718                 :            :                                 i);
   14719                 :            : 
   14720                 :            :                 /* Attempt to send a request on each session */
   14721                 :          4 :                 ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
   14722                 :            :                         sessions[i],
   14723                 :            :                         ut_params,
   14724                 :            :                         ts_params,
   14725                 :            :                         catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
   14726                 :            :                         catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
   14727                 :            :                         aes_cbc_iv);
   14728                 :            : 
   14729                 :            :                 /* free crypto operation structure */
   14730                 :          4 :                 rte_crypto_op_free(ut_params->op);
   14731                 :            : 
   14732                 :            :                 /*
   14733                 :            :                  * free mbuf - both obuf and ibuf are usually the same,
   14734                 :            :                  * so check if they point at the same address is necessary,
   14735                 :            :                  * to avoid freeing the mbuf twice.
   14736                 :            :                  */
   14737         [ +  - ]:          4 :                 if (ut_params->obuf) {
   14738                 :          4 :                         rte_pktmbuf_free(ut_params->obuf);
   14739         [ +  - ]:          4 :                         if (ut_params->ibuf == ut_params->obuf)
   14740                 :          4 :                                 ut_params->ibuf = 0;
   14741                 :          4 :                         ut_params->obuf = 0;
   14742                 :            :                 }
   14743         [ -  + ]:          4 :                 if (ut_params->ibuf) {
   14744                 :          0 :                         rte_pktmbuf_free(ut_params->ibuf);
   14745                 :          0 :                         ut_params->ibuf = 0;
   14746                 :            :                 }
   14747                 :            : 
   14748         [ -  + ]:          4 :                 if (ret != TEST_SUCCESS) {
   14749                 :          0 :                         i++;
   14750                 :          0 :                         break;
   14751                 :            :                 }
   14752                 :            :         }
   14753                 :            : 
   14754                 :            :         nb_sess = i;
   14755                 :            : 
   14756         [ +  + ]:          5 :         for (i = 0; i < nb_sess; i++) {
   14757                 :          4 :                 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
   14758                 :          4 :                                 sessions[i]);
   14759                 :            :         }
   14760                 :            : 
   14761                 :          1 :         rte_free(sessions);
   14762                 :            : 
   14763         [ +  - ]:          1 :         if (ret != TEST_SKIPPED)
   14764         [ -  + ]:          1 :                 TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
   14765                 :            : 
   14766                 :            :         return ret;
   14767                 :            : }
   14768                 :            : 
   14769                 :            : struct multi_session_params {
   14770                 :            :         struct crypto_unittest_params ut_params;
   14771                 :            :         uint8_t *cipher_key;
   14772                 :            :         uint8_t *hmac_key;
   14773                 :            :         const uint8_t *cipher;
   14774                 :            :         const uint8_t *digest;
   14775                 :            :         uint8_t *iv;
   14776                 :            : };
   14777                 :            : 
   14778                 :            : #define MB_SESSION_NUMBER 3
   14779                 :            : 
   14780                 :            : static int
   14781                 :          1 : test_multi_session_random_usage(void)
   14782                 :            : {
   14783                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14784                 :            :         struct rte_cryptodev_info dev_info;
   14785                 :            :         int index = 0, ret = TEST_SUCCESS;
   14786                 :            :         uint32_t nb_sess, i, j;
   14787                 :            :         void **sessions;
   14788                 :          1 :         struct multi_session_params ut_paramz[] = {
   14789                 :            : 
   14790                 :            :                 {
   14791                 :            :                         .cipher_key = ms_aes_cbc_key0,
   14792                 :            :                         .hmac_key = ms_hmac_key0,
   14793                 :            :                         .cipher = ms_aes_cbc_cipher0,
   14794                 :            :                         .digest = ms_hmac_digest0,
   14795                 :            :                         .iv = ms_aes_cbc_iv0
   14796                 :            :                 },
   14797                 :            :                 {
   14798                 :            :                         .cipher_key = ms_aes_cbc_key1,
   14799                 :            :                         .hmac_key = ms_hmac_key1,
   14800                 :            :                         .cipher = ms_aes_cbc_cipher1,
   14801                 :            :                         .digest = ms_hmac_digest1,
   14802                 :            :                         .iv = ms_aes_cbc_iv1
   14803                 :            :                 },
   14804                 :            :                 {
   14805                 :            :                         .cipher_key = ms_aes_cbc_key2,
   14806                 :            :                         .hmac_key = ms_hmac_key2,
   14807                 :            :                         .cipher = ms_aes_cbc_cipher2,
   14808                 :            :                         .digest = ms_hmac_digest2,
   14809                 :            :                         .iv = ms_aes_cbc_iv2
   14810                 :            :                 },
   14811                 :            : 
   14812                 :            :         };
   14813                 :            : 
   14814                 :            :         /* Verify the capabilities */
   14815                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   14816                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14817                 :          1 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
   14818         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14819                 :            :                         &cap_idx) == NULL)
   14820                 :            :                 return TEST_SKIPPED;
   14821                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   14822                 :          1 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
   14823         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   14824                 :            :                         &cap_idx) == NULL)
   14825                 :            :                 return TEST_SKIPPED;
   14826                 :            : 
   14827                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   14828                 :            : 
   14829                 :          1 :         sessions = rte_malloc(NULL, (sizeof(void *)
   14830                 :            :                                         * MAX_NB_SESSIONS) + 1, 0);
   14831                 :            : 
   14832         [ +  + ]:          4 :         for (i = 0; i < MB_SESSION_NUMBER; i++) {
   14833                 :            : 
   14834         [ +  + ]:          3 :                 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
   14835                 :            :                                 sizeof(struct crypto_unittest_params));
   14836                 :            : 
   14837                 :          3 :                 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
   14838                 :            :                                 &ut_paramz[i].ut_params,
   14839                 :            :                                 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
   14840                 :            : 
   14841                 :            :                 /* Create multiple crypto sessions*/
   14842                 :          6 :                 sessions[i] = rte_cryptodev_sym_session_create(
   14843                 :          3 :                                 ts_params->valid_devs[0],
   14844                 :            :                                 &ut_paramz[i].ut_params.auth_xform,
   14845                 :            :                                 ts_params->session_mpool);
   14846   [ -  +  -  - ]:          3 :                 if (sessions[i] == NULL && rte_errno == ENOTSUP) {
   14847                 :            :                         nb_sess = i;
   14848                 :            :                         ret = TEST_SKIPPED;
   14849                 :          0 :                         goto session_clear;
   14850                 :            :                 }
   14851                 :            : 
   14852         [ -  + ]:          3 :                 TEST_ASSERT_NOT_NULL(sessions[i],
   14853                 :            :                                 "Session creation failed at session number %u",
   14854                 :            :                                 i);
   14855                 :            :         }
   14856                 :            : 
   14857                 :            :         nb_sess = i;
   14858                 :            : 
   14859                 :          1 :         srand(time(NULL));
   14860         [ +  - ]:          1 :         for (i = 0; i < 40000; i++) {
   14861                 :            : 
   14862                 :          1 :                 j = rand() % MB_SESSION_NUMBER;
   14863                 :            : 
   14864                 :          1 :                 ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
   14865                 :          1 :                                         sessions[j],
   14866                 :            :                                         &ut_paramz[j].ut_params,
   14867                 :            :                                         ts_params, ut_paramz[j].cipher,
   14868                 :            :                                         ut_paramz[j].digest,
   14869                 :          1 :                                         ut_paramz[j].iv);
   14870                 :            : 
   14871                 :          1 :                 rte_crypto_op_free(ut_paramz[j].ut_params.op);
   14872                 :            : 
   14873                 :            :                 /*
   14874                 :            :                  * free mbuf - both obuf and ibuf are usually the same,
   14875                 :            :                  * so check if they point at the same address is necessary,
   14876                 :            :                  * to avoid freeing the mbuf twice.
   14877                 :            :                  */
   14878         [ +  - ]:          1 :                 if (ut_paramz[j].ut_params.obuf) {
   14879                 :          1 :                         rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
   14880                 :          1 :                         if (ut_paramz[j].ut_params.ibuf
   14881         [ +  - ]:          1 :                                         == ut_paramz[j].ut_params.obuf)
   14882                 :          1 :                                 ut_paramz[j].ut_params.ibuf = 0;
   14883                 :          1 :                         ut_paramz[j].ut_params.obuf = 0;
   14884                 :            :                 }
   14885         [ -  + ]:          1 :                 if (ut_paramz[j].ut_params.ibuf) {
   14886                 :          0 :                         rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
   14887                 :          0 :                         ut_paramz[j].ut_params.ibuf = 0;
   14888                 :            :                 }
   14889                 :            : 
   14890         [ +  - ]:          1 :                 if (ret != TEST_SKIPPED) {
   14891                 :          1 :                         index = i;
   14892                 :          1 :                         break;
   14893                 :            :                 }
   14894                 :            :         }
   14895                 :            : 
   14896                 :          0 : session_clear:
   14897         [ +  + ]:          4 :         for (i = 0; i < nb_sess; i++) {
   14898                 :          3 :                 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
   14899                 :          3 :                                 sessions[i]);
   14900                 :            :         }
   14901                 :            : 
   14902                 :          1 :         rte_free(sessions);
   14903                 :            : 
   14904         [ +  - ]:          1 :         if (ret != TEST_SKIPPED)
   14905         [ -  + ]:          1 :                 TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
   14906                 :            : 
   14907                 :            :         return TEST_SUCCESS;
   14908                 :            : }
   14909                 :            : 
   14910                 :            : uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
   14911                 :            :                         0xab, 0xab, 0xab, 0xab,
   14912                 :            :                         0xab, 0xab, 0xab, 0xab,
   14913                 :            :                         0xab, 0xab, 0xab, 0xab};
   14914                 :            : 
   14915                 :            : static int
   14916                 :          0 : test_null_invalid_operation(void)
   14917                 :            : {
   14918                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14919                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   14920                 :            : 
   14921                 :            :         /* This test is for NULL PMD only */
   14922         [ #  # ]:          0 :         if (gbl_driver_id != rte_cryptodev_driver_id_get(
   14923                 :            :                         RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
   14924                 :            :                 return TEST_SKIPPED;
   14925                 :            : 
   14926                 :            :         /* Setup Cipher Parameters */
   14927                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   14928                 :          0 :         ut_params->cipher_xform.next = NULL;
   14929                 :            : 
   14930                 :          0 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
   14931                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
   14932                 :            : 
   14933                 :            :         /* Create Crypto session*/
   14934                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(
   14935                 :          0 :                         ts_params->valid_devs[0], &ut_params->cipher_xform,
   14936                 :            :                         ts_params->session_mpool);
   14937         [ #  # ]:          0 :         TEST_ASSERT(ut_params->sess == NULL,
   14938                 :            :                         "Session creation succeeded unexpectedly");
   14939                 :            : 
   14940                 :            :         /* Setup HMAC Parameters */
   14941                 :          0 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14942                 :          0 :         ut_params->auth_xform.next = NULL;
   14943                 :            : 
   14944                 :          0 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
   14945                 :          0 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
   14946                 :            : 
   14947                 :            :         /* Create Crypto session*/
   14948                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(
   14949                 :          0 :                         ts_params->valid_devs[0], &ut_params->auth_xform,
   14950                 :            :                         ts_params->session_mpool);
   14951         [ #  # ]:          0 :         TEST_ASSERT(ut_params->sess == NULL,
   14952                 :            :                         "Session creation succeeded unexpectedly");
   14953                 :            : 
   14954                 :            :         return TEST_SUCCESS;
   14955                 :            : }
   14956                 :            : 
   14957                 :            : 
   14958                 :            : #define NULL_BURST_LENGTH (32)
   14959                 :            : 
   14960                 :            : static int
   14961                 :          0 : test_null_burst_operation(void)
   14962                 :            : {
   14963                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   14964                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   14965                 :            : 
   14966                 :            :         unsigned i, burst_len = NULL_BURST_LENGTH;
   14967                 :            : 
   14968                 :          0 :         struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
   14969                 :          0 :         struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
   14970                 :            : 
   14971                 :            :         /* This test is for NULL PMD only */
   14972         [ #  # ]:          0 :         if (gbl_driver_id != rte_cryptodev_driver_id_get(
   14973                 :            :                         RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
   14974                 :            :                 return TEST_SKIPPED;
   14975                 :            : 
   14976                 :            :         /* Setup Cipher Parameters */
   14977                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   14978                 :          0 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
   14979                 :            : 
   14980                 :          0 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
   14981                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
   14982                 :            : 
   14983                 :            :         /* Setup HMAC Parameters */
   14984                 :          0 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   14985                 :          0 :         ut_params->auth_xform.next = NULL;
   14986                 :            : 
   14987                 :          0 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
   14988                 :          0 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
   14989                 :            : 
   14990                 :            :         /* Create Crypto session*/
   14991                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(
   14992                 :          0 :                                 ts_params->valid_devs[0],
   14993                 :            :                                 &ut_params->auth_xform,
   14994                 :            :                                 ts_params->session_mpool);
   14995   [ #  #  #  # ]:          0 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   14996                 :            :                 return TEST_SKIPPED;
   14997         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   14998                 :            : 
   14999         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
   15000                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
   15001                 :            :                         burst_len, "failed to generate burst of crypto ops");
   15002                 :            : 
   15003                 :            :         /* Generate an operation for each mbuf in burst */
   15004         [ #  # ]:          0 :         for (i = 0; i < burst_len; i++) {
   15005                 :          0 :                 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   15006                 :            : 
   15007         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
   15008                 :            : 
   15009                 :            :                 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
   15010                 :            :                                 sizeof(unsigned));
   15011                 :          0 :                 *data = i;
   15012                 :            : 
   15013         [ #  # ]:          0 :                 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
   15014                 :            : 
   15015                 :          0 :                 burst[i]->sym->m_src = m;
   15016                 :            :         }
   15017                 :            : 
   15018                 :            :         /* Process crypto operation */
   15019         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
   15020                 :            :                         0, burst, burst_len),
   15021                 :            :                         burst_len,
   15022                 :            :                         "Error enqueuing burst");
   15023                 :            : 
   15024         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
   15025                 :            :                         0, burst_dequeued, burst_len),
   15026                 :            :                         burst_len,
   15027                 :            :                         "Error dequeuing burst");
   15028                 :            : 
   15029                 :            : 
   15030         [ #  # ]:          0 :         for (i = 0; i < burst_len; i++) {
   15031         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(
   15032                 :            :                         *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
   15033                 :            :                         *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
   15034                 :            :                                         uint32_t *),
   15035                 :            :                         "data not as expected");
   15036                 :            : 
   15037                 :          0 :                 rte_pktmbuf_free(burst[i]->sym->m_src);
   15038                 :          0 :                 rte_crypto_op_free(burst[i]);
   15039                 :            :         }
   15040                 :            : 
   15041                 :            :         return TEST_SUCCESS;
   15042                 :            : }
   15043                 :            : 
   15044                 :            : static uint16_t
   15045                 :          0 : test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
   15046                 :            :                   uint16_t nb_ops, void *user_param)
   15047                 :            : {
   15048                 :            :         RTE_SET_USED(dev_id);
   15049                 :            :         RTE_SET_USED(qp_id);
   15050                 :            :         RTE_SET_USED(ops);
   15051                 :            :         RTE_SET_USED(user_param);
   15052                 :            : 
   15053                 :          0 :         enq_cb_called = true;
   15054                 :            :         printf("crypto enqueue callback called\n");
   15055                 :          0 :         return nb_ops;
   15056                 :            : }
   15057                 :            : 
   15058                 :            : static uint16_t
   15059                 :          0 : test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
   15060                 :            :                   uint16_t nb_ops, void *user_param)
   15061                 :            : {
   15062                 :            :         RTE_SET_USED(dev_id);
   15063                 :            :         RTE_SET_USED(qp_id);
   15064                 :            :         RTE_SET_USED(ops);
   15065                 :            :         RTE_SET_USED(user_param);
   15066                 :            : 
   15067                 :          0 :         deq_cb_called = true;
   15068                 :            :         printf("crypto dequeue callback called\n");
   15069                 :          0 :         return nb_ops;
   15070                 :            : }
   15071                 :            : 
   15072                 :            : /*
   15073                 :            :  * Process enqueue/dequeue NULL crypto request to verify callback with RCU.
   15074                 :            :  */
   15075                 :            : static int
   15076                 :          0 : test_enqdeq_callback_null_cipher(void)
   15077                 :            : {
   15078                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15079                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15080                 :            : 
   15081                 :            :         /* Setup Cipher Parameters */
   15082                 :          0 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   15083                 :          0 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
   15084                 :            : 
   15085                 :          0 :         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
   15086                 :          0 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
   15087                 :            : 
   15088                 :            :         /* Setup Auth Parameters */
   15089                 :          0 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15090                 :          0 :         ut_params->auth_xform.next = NULL;
   15091                 :            : 
   15092                 :          0 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
   15093                 :          0 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
   15094                 :            : 
   15095                 :            :         /* Create Crypto session */
   15096                 :          0 :         ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
   15097                 :            :                                 &ut_params->auth_xform, ts_params->session_mpool);
   15098         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   15099                 :            : 
   15100                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   15101         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
   15102                 :            : 
   15103                 :            :         /* Allocate mbuf */
   15104                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   15105         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf, "Failed to allocate mbuf");
   15106                 :            : 
   15107                 :            :         /* Append some random data */
   15108         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->ibuf, sizeof(unsigned int)),
   15109                 :            :                         "no room to append data");
   15110                 :            : 
   15111         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   15112                 :            : 
   15113                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
   15114                 :            : 
   15115                 :            :         /* Process crypto operation */
   15116         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], ut_params->op),
   15117                 :            :                         "failed to process sym crypto op");
   15118                 :            : 
   15119                 :            :         return 0;
   15120                 :            : }
   15121                 :            : 
   15122                 :            : static int
   15123                 :          1 : test_enq_callback_setup(void)
   15124                 :            : {
   15125                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15126                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   15127                 :            :         struct rte_cryptodev_info dev_info;
   15128                 :          1 :         struct rte_cryptodev_qp_conf qp_conf = {
   15129                 :            :                 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
   15130                 :            :         };
   15131                 :            : 
   15132                 :            :         struct rte_cryptodev_cb *cb;
   15133                 :            :         uint16_t qp_id = 0;
   15134                 :            :         int j = 0;
   15135                 :            : 
   15136                 :            :         /* Skip test if synchronous API is used */
   15137         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   15138                 :            :                 return TEST_SKIPPED;
   15139                 :            : 
   15140                 :            :         /* Verify the crypto capabilities for which enqueue/dequeue is done. */
   15141                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15142                 :          1 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
   15143         [ -  + ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15144                 :            :                         &cap_idx) == NULL)
   15145                 :            :                 return TEST_SKIPPED;
   15146                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   15147                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
   15148         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15149                 :            :                         &cap_idx) == NULL)
   15150                 :            :                 return TEST_SKIPPED;
   15151                 :            : 
   15152                 :            :         /* Stop the device in case it's started so it can be configured */
   15153                 :          0 :         rte_cryptodev_stop(ts_params->valid_devs[0]);
   15154                 :            : 
   15155                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   15156                 :            : 
   15157         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
   15158                 :            :                         &ts_params->conf),
   15159                 :            :                         "Failed to configure cryptodev %u",
   15160                 :            :                         ts_params->valid_devs[0]);
   15161                 :            : 
   15162                 :          0 :         qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
   15163                 :          0 :         qp_conf.mp_session = ts_params->session_mpool;
   15164                 :            : 
   15165         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
   15166                 :            :                         ts_params->valid_devs[0], qp_id, &qp_conf,
   15167                 :            :                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
   15168                 :            :                         "Failed test for "
   15169                 :            :                         "rte_cryptodev_queue_pair_setup: num_inflights "
   15170                 :            :                         "%u on qp %u on cryptodev %u",
   15171                 :            :                         qp_conf.nb_descriptors, qp_id,
   15172                 :            :                         ts_params->valid_devs[0]);
   15173                 :            : 
   15174                 :          0 :         enq_cb_called = false;
   15175                 :            :         /* Test with invalid crypto device */
   15176                 :          0 :         cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
   15177                 :            :                         qp_id, test_enq_callback, NULL);
   15178         [ #  # ]:          0 :         if (rte_errno == ENOTSUP) {
   15179                 :          0 :                 RTE_LOG(ERR, USER1, "%s line %d: "
   15180                 :            :                         "rte_cryptodev_add_enq_callback() "
   15181                 :            :                         "Not supported, skipped\n", __func__, __LINE__);
   15182                 :          0 :                 return TEST_SKIPPED;
   15183                 :            :         }
   15184         [ #  # ]:          0 :         TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
   15185                 :            :                         "cryptodev %u did not fail",
   15186                 :            :                         qp_id, RTE_CRYPTO_MAX_DEVS);
   15187                 :            : 
   15188                 :            :         /* Test with invalid queue pair */
   15189                 :          0 :         cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
   15190                 :          0 :                         dev_info.max_nb_queue_pairs + 1,
   15191                 :            :                         test_enq_callback, NULL);
   15192         [ #  # ]:          0 :         TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
   15193                 :            :                         "cryptodev %u did not fail",
   15194                 :            :                         dev_info.max_nb_queue_pairs + 1,
   15195                 :            :                         ts_params->valid_devs[0]);
   15196                 :            : 
   15197                 :            :         /* Test with NULL callback */
   15198                 :          0 :         cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
   15199                 :            :                         qp_id, NULL, NULL);
   15200         [ #  # ]:          0 :         TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
   15201                 :            :                         "cryptodev %u did not fail",
   15202                 :            :                         qp_id, ts_params->valid_devs[0]);
   15203                 :            : 
   15204                 :            :         /* Test with valid configuration */
   15205                 :          0 :         cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
   15206                 :            :                         qp_id, test_enq_callback, NULL);
   15207         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
   15208                 :            :                         "qp %u on cryptodev %u",
   15209                 :            :                         qp_id, ts_params->valid_devs[0]);
   15210                 :            : 
   15211                 :          0 :         rte_cryptodev_start(ts_params->valid_devs[0]);
   15212                 :            : 
   15213         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto Processing failed");
   15214                 :            : 
   15215                 :            :         /* Wait until callback not called. */
   15216   [ #  #  #  # ]:          0 :         while (!enq_cb_called && (j++ < 10))
   15217                 :            :                 rte_delay_ms(10);
   15218                 :            : 
   15219                 :            :         /* Test with invalid crypto device */
   15220         [ #  # ]:          0 :         TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
   15221                 :            :                         RTE_CRYPTO_MAX_DEVS, qp_id, cb),
   15222                 :            :                         "Expected call to fail as crypto device is invalid");
   15223                 :            : 
   15224                 :            :         /* Test with invalid queue pair */
   15225         [ #  # ]:          0 :         TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
   15226                 :            :                         ts_params->valid_devs[0],
   15227                 :            :                         dev_info.max_nb_queue_pairs + 1, cb),
   15228                 :            :                         "Expected call to fail as queue pair is invalid");
   15229                 :            : 
   15230                 :            :         /* Test with NULL callback */
   15231         [ #  # ]:          0 :         TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
   15232                 :            :                         ts_params->valid_devs[0], qp_id, NULL),
   15233                 :            :                         "Expected call to fail as callback is NULL");
   15234                 :            : 
   15235                 :            :         /* Test with valid configuration */
   15236         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
   15237                 :            :                         ts_params->valid_devs[0], qp_id, cb),
   15238                 :            :                         "Failed test to remove callback on "
   15239                 :            :                         "qp %u on cryptodev %u",
   15240                 :            :                         qp_id, ts_params->valid_devs[0]);
   15241                 :            : 
   15242         [ #  # ]:          0 :         TEST_ASSERT(enq_cb_called == true, "Crypto enqueue callback not called");
   15243                 :            : 
   15244                 :            :         return TEST_SUCCESS;
   15245                 :            : }
   15246                 :            : 
   15247                 :            : static int
   15248                 :          1 : test_deq_callback_setup(void)
   15249                 :            : {
   15250                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15251                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   15252                 :            :         struct rte_cryptodev_info dev_info;
   15253                 :          1 :         struct rte_cryptodev_qp_conf qp_conf = {
   15254                 :            :                 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
   15255                 :            :         };
   15256                 :            : 
   15257                 :            :         struct rte_cryptodev_cb *cb;
   15258                 :            :         uint16_t qp_id = 0;
   15259                 :            :         int j = 0;
   15260                 :            : 
   15261                 :            :         /* Skip test if synchronous API is used */
   15262         [ +  - ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   15263                 :            :                 return TEST_SKIPPED;
   15264                 :            : 
   15265                 :            :         /* Verify the crypto capabilities for which enqueue/dequeue is done. */
   15266                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15267                 :          1 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
   15268         [ -  + ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15269                 :            :                         &cap_idx) == NULL)
   15270                 :            :                 return TEST_SKIPPED;
   15271                 :          0 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   15272                 :          0 :         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
   15273         [ #  # ]:          0 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15274                 :            :                         &cap_idx) == NULL)
   15275                 :            :                 return TEST_SKIPPED;
   15276                 :            : 
   15277                 :            :         /* Stop the device in case it's started so it can be configured */
   15278                 :          0 :         rte_cryptodev_stop(ts_params->valid_devs[0]);
   15279                 :            : 
   15280                 :          0 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   15281                 :            : 
   15282         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
   15283                 :            :                         &ts_params->conf),
   15284                 :            :                         "Failed to configure cryptodev %u",
   15285                 :            :                         ts_params->valid_devs[0]);
   15286                 :            : 
   15287                 :          0 :         qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
   15288                 :          0 :         qp_conf.mp_session = ts_params->session_mpool;
   15289                 :            : 
   15290         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
   15291                 :            :                         ts_params->valid_devs[0], qp_id, &qp_conf,
   15292                 :            :                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
   15293                 :            :                         "Failed test for "
   15294                 :            :                         "rte_cryptodev_queue_pair_setup: num_inflights "
   15295                 :            :                         "%u on qp %u on cryptodev %u",
   15296                 :            :                         qp_conf.nb_descriptors, qp_id,
   15297                 :            :                         ts_params->valid_devs[0]);
   15298                 :            : 
   15299                 :          0 :         deq_cb_called = false;
   15300                 :            :         /* Test with invalid crypto device */
   15301                 :          0 :         cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
   15302                 :            :                         qp_id, test_deq_callback, NULL);
   15303         [ #  # ]:          0 :         if (rte_errno == ENOTSUP) {
   15304                 :          0 :                 RTE_LOG(ERR, USER1, "%s line %d: "
   15305                 :            :                         "rte_cryptodev_add_deq_callback() "
   15306                 :            :                         "Not supported, skipped\n", __func__, __LINE__);
   15307                 :          0 :                 return TEST_SKIPPED;
   15308                 :            :         }
   15309         [ #  # ]:          0 :         TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
   15310                 :            :                         "cryptodev %u did not fail",
   15311                 :            :                         qp_id, RTE_CRYPTO_MAX_DEVS);
   15312                 :            : 
   15313                 :            :         /* Test with invalid queue pair */
   15314                 :          0 :         cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
   15315                 :          0 :                         dev_info.max_nb_queue_pairs + 1,
   15316                 :            :                         test_deq_callback, NULL);
   15317         [ #  # ]:          0 :         TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
   15318                 :            :                         "cryptodev %u did not fail",
   15319                 :            :                         dev_info.max_nb_queue_pairs + 1,
   15320                 :            :                         ts_params->valid_devs[0]);
   15321                 :            : 
   15322                 :            :         /* Test with NULL callback */
   15323                 :          0 :         cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
   15324                 :            :                         qp_id, NULL, NULL);
   15325         [ #  # ]:          0 :         TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
   15326                 :            :                         "cryptodev %u did not fail",
   15327                 :            :                         qp_id, ts_params->valid_devs[0]);
   15328                 :            : 
   15329                 :            :         /* Test with valid configuration */
   15330                 :          0 :         cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
   15331                 :            :                         qp_id, test_deq_callback, NULL);
   15332         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
   15333                 :            :                         "qp %u on cryptodev %u",
   15334                 :            :                         qp_id, ts_params->valid_devs[0]);
   15335                 :            : 
   15336                 :          0 :         rte_cryptodev_start(ts_params->valid_devs[0]);
   15337                 :            : 
   15338         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto processing failed");
   15339                 :            : 
   15340                 :            :         /* Wait until callback not called. */
   15341   [ #  #  #  # ]:          0 :         while (!deq_cb_called && (j++ < 10))
   15342                 :            :                 rte_delay_ms(10);
   15343                 :            : 
   15344                 :            :         /* Test with invalid crypto device */
   15345         [ #  # ]:          0 :         TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
   15346                 :            :                         RTE_CRYPTO_MAX_DEVS, qp_id, cb),
   15347                 :            :                         "Expected call to fail as crypto device is invalid");
   15348                 :            : 
   15349                 :            :         /* Test with invalid queue pair */
   15350         [ #  # ]:          0 :         TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
   15351                 :            :                         ts_params->valid_devs[0],
   15352                 :            :                         dev_info.max_nb_queue_pairs + 1, cb),
   15353                 :            :                         "Expected call to fail as queue pair is invalid");
   15354                 :            : 
   15355                 :            :         /* Test with NULL callback */
   15356         [ #  # ]:          0 :         TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
   15357                 :            :                         ts_params->valid_devs[0], qp_id, NULL),
   15358                 :            :                         "Expected call to fail as callback is NULL");
   15359                 :            : 
   15360                 :            :         /* Test with valid configuration */
   15361         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
   15362                 :            :                         ts_params->valid_devs[0], qp_id, cb),
   15363                 :            :                         "Failed test to remove callback on "
   15364                 :            :                         "qp %u on cryptodev %u",
   15365                 :            :                         qp_id, ts_params->valid_devs[0]);
   15366                 :            : 
   15367         [ #  # ]:          0 :         TEST_ASSERT(deq_cb_called == true, "Crypto dequeue callback not called");
   15368                 :            : 
   15369                 :            :         return TEST_SUCCESS;
   15370                 :            : }
   15371                 :            : 
   15372                 :            : static void
   15373                 :            : generate_gmac_large_plaintext(uint8_t *data)
   15374                 :            : {
   15375                 :            :         uint16_t i;
   15376                 :            : 
   15377   [ +  +  +  + ]:       4084 :         for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
   15378                 :       4082 :                 memcpy(&data[i], &data[0], 32);
   15379                 :            : }
   15380                 :            : 
   15381                 :            : static int
   15382                 :          8 : create_gmac_operation(enum rte_crypto_auth_operation op,
   15383                 :            :                 const struct gmac_test_data *tdata)
   15384                 :            : {
   15385                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15386                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15387                 :            :         struct rte_crypto_sym_op *sym_op;
   15388                 :            : 
   15389                 :          8 :         uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
   15390                 :            : 
   15391                 :            :         /* Generate Crypto op data structure */
   15392                 :          8 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   15393                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   15394         [ -  + ]:          8 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   15395                 :            :                         "Failed to allocate symmetric crypto operation struct");
   15396                 :            : 
   15397                 :            :         sym_op = ut_params->op->sym;
   15398                 :            : 
   15399                 :         16 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
   15400                 :          8 :                         ut_params->ibuf, tdata->gmac_tag.len);
   15401         [ -  + ]:          8 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
   15402                 :            :                         "no room to append digest");
   15403                 :            : 
   15404         [ +  + ]:          8 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
   15405                 :            :                         ut_params->ibuf, plaintext_pad_len);
   15406                 :            : 
   15407         [ +  + ]:          8 :         if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
   15408                 :          4 :                 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
   15409         [ -  + ]:          4 :                                 tdata->gmac_tag.len);
   15410                 :          4 :                 debug_hexdump(stdout, "digest:",
   15411                 :          4 :                                 sym_op->auth.digest.data,
   15412                 :          4 :                                 tdata->gmac_tag.len);
   15413                 :            :         }
   15414                 :            : 
   15415                 :          8 :         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
   15416                 :            :                         uint8_t *, IV_OFFSET);
   15417                 :            : 
   15418         [ -  + ]:          8 :         rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
   15419                 :            : 
   15420                 :          8 :         debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
   15421                 :            : 
   15422                 :          8 :         sym_op->cipher.data.length = 0;
   15423                 :          8 :         sym_op->cipher.data.offset = 0;
   15424                 :            : 
   15425                 :          8 :         sym_op->auth.data.offset = 0;
   15426                 :          8 :         sym_op->auth.data.length = tdata->plaintext.len;
   15427                 :            : 
   15428                 :          8 :         return 0;
   15429                 :            : }
   15430                 :            : 
   15431                 :            : static int
   15432                 :          0 : create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
   15433                 :            :                 const struct gmac_test_data *tdata,
   15434                 :            :                 void *digest_mem, uint64_t digest_phys)
   15435                 :            : {
   15436                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15437                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15438                 :            :         struct rte_crypto_sym_op *sym_op;
   15439                 :            : 
   15440                 :            :         /* Generate Crypto op data structure */
   15441                 :          0 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   15442                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   15443         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   15444                 :            :                         "Failed to allocate symmetric crypto operation struct");
   15445                 :            : 
   15446                 :            :         sym_op = ut_params->op->sym;
   15447                 :            : 
   15448                 :          0 :         sym_op->auth.digest.data = digest_mem;
   15449         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
   15450                 :            :                         "no room to append digest");
   15451                 :            : 
   15452                 :          0 :         sym_op->auth.digest.phys_addr = digest_phys;
   15453                 :            : 
   15454         [ #  # ]:          0 :         if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
   15455                 :          0 :                 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
   15456         [ #  # ]:          0 :                                 tdata->gmac_tag.len);
   15457                 :          0 :                 debug_hexdump(stdout, "digest:",
   15458                 :          0 :                                 sym_op->auth.digest.data,
   15459                 :          0 :                                 tdata->gmac_tag.len);
   15460                 :            :         }
   15461                 :            : 
   15462                 :          0 :         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
   15463                 :            :                         uint8_t *, IV_OFFSET);
   15464                 :            : 
   15465         [ #  # ]:          0 :         rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
   15466                 :            : 
   15467                 :          0 :         debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
   15468                 :            : 
   15469                 :          0 :         sym_op->cipher.data.length = 0;
   15470                 :          0 :         sym_op->cipher.data.offset = 0;
   15471                 :            : 
   15472                 :          0 :         sym_op->auth.data.offset = 0;
   15473                 :          0 :         sym_op->auth.data.length = tdata->plaintext.len;
   15474                 :            : 
   15475                 :          0 :         return 0;
   15476                 :            : }
   15477                 :            : 
   15478                 :          8 : static int create_gmac_session(uint8_t dev_id,
   15479                 :            :                 const struct gmac_test_data *tdata,
   15480                 :            :                 enum rte_crypto_auth_operation auth_op)
   15481                 :          8 : {
   15482                 :          8 :         uint8_t auth_key[tdata->key.len];
   15483                 :            : 
   15484                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15485                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15486                 :            : 
   15487                 :          8 :         memcpy(auth_key, tdata->key.data, tdata->key.len);
   15488                 :            : 
   15489                 :          8 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15490                 :          8 :         ut_params->auth_xform.next = NULL;
   15491                 :            : 
   15492                 :          8 :         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
   15493                 :          8 :         ut_params->auth_xform.auth.op = auth_op;
   15494                 :          8 :         ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
   15495                 :          8 :         ut_params->auth_xform.auth.key.length = tdata->key.len;
   15496                 :          8 :         ut_params->auth_xform.auth.key.data = auth_key;
   15497                 :          8 :         ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
   15498                 :          8 :         ut_params->auth_xform.auth.iv.length = tdata->iv.len;
   15499                 :            : 
   15500                 :            : 
   15501                 :          8 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
   15502                 :            :                         &ut_params->auth_xform, ts_params->session_mpool);
   15503   [ -  +  -  - ]:          8 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   15504                 :            :                 return TEST_SKIPPED;
   15505         [ -  + ]:          8 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   15506                 :            : 
   15507                 :            :         return 0;
   15508                 :            : }
   15509                 :            : 
   15510                 :            : static int
   15511                 :          4 : test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
   15512                 :            : {
   15513                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15514                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15515                 :            :         struct rte_cryptodev_info dev_info;
   15516                 :            : 
   15517                 :          4 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   15518                 :          4 :         uint64_t feat_flags = dev_info.feature_flags;
   15519                 :            : 
   15520         [ -  + ]:          4 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   15521         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   15522                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   15523                 :          0 :                 return TEST_SKIPPED;
   15524                 :            :         }
   15525                 :            : 
   15526                 :            :         int retval;
   15527                 :            : 
   15528                 :            :         uint8_t *auth_tag, *plaintext;
   15529                 :            :         uint16_t plaintext_pad_len;
   15530                 :            : 
   15531         [ -  + ]:          4 :         TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
   15532                 :            :                               "No GMAC length in the source data");
   15533                 :            : 
   15534                 :            :         /* Verify the capabilities */
   15535                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   15536                 :          4 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15537                 :          4 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
   15538         [ +  - ]:          4 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15539                 :            :                         &cap_idx) == NULL)
   15540                 :            :                 return TEST_SKIPPED;
   15541                 :            : 
   15542                 :          4 :         retval = create_gmac_session(ts_params->valid_devs[0],
   15543                 :            :                         tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
   15544                 :            : 
   15545         [ +  - ]:          4 :         if (retval == TEST_SKIPPED)
   15546                 :            :                 return TEST_SKIPPED;
   15547         [ +  - ]:          4 :         if (retval < 0)
   15548                 :            :                 return retval;
   15549                 :            : 
   15550         [ +  + ]:          4 :         if (tdata->plaintext.len > MBUF_SIZE)
   15551                 :          1 :                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
   15552                 :            :         else
   15553                 :          3 :                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   15554         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   15555                 :            :                         "Failed to allocate input buffer in mempool");
   15556                 :            : 
   15557         [ +  + ]:          4 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   15558                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   15559                 :            : 
   15560                 :          4 :         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
   15561                 :            :         /*
   15562                 :            :          * Runtime generate the large plain text instead of use hard code
   15563                 :            :          * plain text vector. It is done to avoid create huge source file
   15564                 :            :          * with the test vector.
   15565                 :            :          */
   15566         [ +  + ]:          4 :         if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
   15567                 :          1 :                 generate_gmac_large_plaintext(tdata->plaintext.data);
   15568                 :            : 
   15569                 :          4 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   15570                 :            :                                 plaintext_pad_len);
   15571         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
   15572                 :            : 
   15573                 :          4 :         memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
   15574                 :          4 :         debug_hexdump(stdout, "plaintext:", plaintext,
   15575                 :          4 :                         tdata->plaintext.len);
   15576                 :            : 
   15577                 :          4 :         retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
   15578                 :            :                         tdata);
   15579                 :            : 
   15580         [ +  - ]:          4 :         if (retval < 0)
   15581                 :            :                 return retval;
   15582                 :            : 
   15583         [ +  - ]:          4 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   15584                 :            : 
   15585                 :          4 :         ut_params->op->sym->m_src = ut_params->ibuf;
   15586                 :            : 
   15587         [ -  + ]:          4 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   15588                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   15589                 :            :                         ut_params->op);
   15590         [ -  + ]:          4 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   15591                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
   15592                 :            :                                                0);
   15593         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   15594                 :            :                         return retval;
   15595                 :            :         } else
   15596         [ -  + ]:          4 :                 TEST_ASSERT_NOT_NULL(
   15597                 :            :                         process_crypto_request(ts_params->valid_devs[0],
   15598                 :            :                         ut_params->op), "failed to process sym crypto op");
   15599                 :            : 
   15600         [ -  + ]:          4 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   15601                 :            :                         "crypto op processing failed");
   15602                 :            : 
   15603         [ -  + ]:          4 :         if (ut_params->op->sym->m_dst) {
   15604                 :          0 :                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
   15605                 :            :                                 uint8_t *, plaintext_pad_len);
   15606                 :            :         } else {
   15607                 :          4 :                 auth_tag = plaintext + plaintext_pad_len;
   15608                 :            :         }
   15609                 :            : 
   15610                 :          4 :         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
   15611                 :            : 
   15612         [ -  + ]:          4 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   15613                 :            :                         auth_tag,
   15614                 :            :                         tdata->gmac_tag.data,
   15615                 :            :                         tdata->gmac_tag.len,
   15616                 :            :                         "GMAC Generated auth tag not as expected");
   15617                 :            : 
   15618                 :            :         return 0;
   15619                 :            : }
   15620                 :            : 
   15621                 :            : static int
   15622                 :          1 : test_AES_GMAC_authentication_test_case_1(void)
   15623                 :            : {
   15624                 :          1 :         return test_AES_GMAC_authentication(&gmac_test_case_1);
   15625                 :            : }
   15626                 :            : 
   15627                 :            : static int
   15628                 :          1 : test_AES_GMAC_authentication_test_case_2(void)
   15629                 :            : {
   15630                 :          1 :         return test_AES_GMAC_authentication(&gmac_test_case_2);
   15631                 :            : }
   15632                 :            : 
   15633                 :            : static int
   15634                 :          1 : test_AES_GMAC_authentication_test_case_3(void)
   15635                 :            : {
   15636                 :          1 :         return test_AES_GMAC_authentication(&gmac_test_case_3);
   15637                 :            : }
   15638                 :            : 
   15639                 :            : static int
   15640                 :          1 : test_AES_GMAC_authentication_test_case_4(void)
   15641                 :            : {
   15642                 :          1 :         return test_AES_GMAC_authentication(&gmac_test_case_4);
   15643                 :            : }
   15644                 :            : 
   15645                 :            : static int
   15646                 :          4 : test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
   15647                 :            : {
   15648                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15649                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15650                 :            :         int retval;
   15651                 :            :         uint32_t plaintext_pad_len;
   15652                 :            :         uint8_t *plaintext;
   15653                 :            :         struct rte_cryptodev_info dev_info;
   15654                 :            : 
   15655                 :          4 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   15656                 :          4 :         uint64_t feat_flags = dev_info.feature_flags;
   15657                 :            : 
   15658         [ -  + ]:          4 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   15659         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   15660                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   15661                 :          0 :                 return TEST_SKIPPED;
   15662                 :            :         }
   15663                 :            : 
   15664         [ -  + ]:          4 :         TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
   15665                 :            :                               "No GMAC length in the source data");
   15666                 :            : 
   15667                 :            :         /* Verify the capabilities */
   15668                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   15669                 :          4 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15670                 :          4 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
   15671         [ +  - ]:          4 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15672                 :            :                         &cap_idx) == NULL)
   15673                 :            :                 return TEST_SKIPPED;
   15674                 :            : 
   15675                 :          4 :         retval = create_gmac_session(ts_params->valid_devs[0],
   15676                 :            :                         tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
   15677                 :            : 
   15678         [ +  - ]:          4 :         if (retval == TEST_SKIPPED)
   15679                 :            :                 return TEST_SKIPPED;
   15680         [ +  - ]:          4 :         if (retval < 0)
   15681                 :            :                 return retval;
   15682                 :            : 
   15683         [ +  + ]:          4 :         if (tdata->plaintext.len > MBUF_SIZE)
   15684                 :          1 :                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
   15685                 :            :         else
   15686                 :          3 :                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   15687         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   15688                 :            :                         "Failed to allocate input buffer in mempool");
   15689                 :            : 
   15690         [ +  + ]:          4 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   15691                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   15692                 :            : 
   15693                 :          4 :         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
   15694                 :            : 
   15695                 :            :         /*
   15696                 :            :          * Runtime generate the large plain text instead of use hard code
   15697                 :            :          * plain text vector. It is done to avoid create huge source file
   15698                 :            :          * with the test vector.
   15699                 :            :          */
   15700         [ +  + ]:          4 :         if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
   15701                 :          1 :                 generate_gmac_large_plaintext(tdata->plaintext.data);
   15702                 :            : 
   15703                 :          4 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   15704                 :            :                                 plaintext_pad_len);
   15705         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
   15706                 :            : 
   15707                 :          4 :         memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
   15708                 :          4 :         debug_hexdump(stdout, "plaintext:", plaintext,
   15709                 :          4 :                         tdata->plaintext.len);
   15710                 :            : 
   15711                 :          4 :         retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
   15712                 :            :                         tdata);
   15713                 :            : 
   15714         [ +  - ]:          4 :         if (retval < 0)
   15715                 :            :                 return retval;
   15716                 :            : 
   15717         [ +  - ]:          4 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   15718                 :            : 
   15719                 :          4 :         ut_params->op->sym->m_src = ut_params->ibuf;
   15720                 :            : 
   15721         [ -  + ]:          4 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   15722                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   15723                 :            :                         ut_params->op);
   15724         [ -  + ]:          4 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   15725                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
   15726                 :            :                                                0);
   15727         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   15728                 :            :                         return retval;
   15729                 :            :         } else
   15730         [ -  + ]:          4 :                 TEST_ASSERT_NOT_NULL(
   15731                 :            :                         process_crypto_request(ts_params->valid_devs[0],
   15732                 :            :                         ut_params->op), "failed to process sym crypto op");
   15733                 :            : 
   15734         [ -  + ]:          4 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   15735                 :            :                         "crypto op processing failed");
   15736                 :            : 
   15737                 :            :         return 0;
   15738                 :            : 
   15739                 :            : }
   15740                 :            : 
   15741                 :            : static int
   15742                 :          1 : test_AES_GMAC_authentication_verify_test_case_1(void)
   15743                 :            : {
   15744                 :          1 :         return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
   15745                 :            : }
   15746                 :            : 
   15747                 :            : static int
   15748                 :          1 : test_AES_GMAC_authentication_verify_test_case_2(void)
   15749                 :            : {
   15750                 :          1 :         return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
   15751                 :            : }
   15752                 :            : 
   15753                 :            : static int
   15754                 :          1 : test_AES_GMAC_authentication_verify_test_case_3(void)
   15755                 :            : {
   15756                 :          1 :         return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
   15757                 :            : }
   15758                 :            : 
   15759                 :            : static int
   15760                 :          1 : test_AES_GMAC_authentication_verify_test_case_4(void)
   15761                 :            : {
   15762                 :          1 :         return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
   15763                 :            : }
   15764                 :            : 
   15765                 :            : static int
   15766                 :          4 : test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
   15767                 :            :                                 uint32_t fragsz)
   15768                 :            : {
   15769                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   15770                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   15771                 :            :         struct rte_cryptodev_info dev_info;
   15772                 :            :         uint64_t feature_flags;
   15773                 :            :         unsigned int trn_data = 0;
   15774                 :            :         void *digest_mem = NULL;
   15775                 :            :         uint32_t segs = 1;
   15776                 :            :         unsigned int to_trn = 0;
   15777                 :            :         struct rte_mbuf *buf = NULL;
   15778                 :            :         uint8_t *auth_tag, *plaintext;
   15779                 :            :         int retval;
   15780                 :            : 
   15781         [ -  + ]:          4 :         TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
   15782                 :            :                               "No GMAC length in the source data");
   15783                 :            : 
   15784                 :            :         /* Verify the capabilities */
   15785                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   15786                 :          4 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   15787                 :          4 :         cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
   15788         [ +  - ]:          4 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   15789                 :            :                         &cap_idx) == NULL)
   15790                 :            :                 return TEST_SKIPPED;
   15791                 :            : 
   15792                 :            :         /* Check for any input SGL support */
   15793                 :          4 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   15794                 :          4 :         feature_flags = dev_info.feature_flags;
   15795                 :            : 
   15796                 :          4 :         if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
   15797         [ -  + ]:          4 :                         (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
   15798                 :            :                         (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
   15799                 :            :                 return TEST_SKIPPED;
   15800                 :            : 
   15801                 :          0 :         if (fragsz > tdata->plaintext.len)
   15802                 :            :                 fragsz = tdata->plaintext.len;
   15803                 :            : 
   15804                 :          0 :         uint16_t plaintext_len = fragsz;
   15805                 :            : 
   15806                 :          0 :         retval = create_gmac_session(ts_params->valid_devs[0],
   15807                 :            :                         tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
   15808                 :            : 
   15809         [ #  # ]:          0 :         if (retval == TEST_SKIPPED)
   15810                 :            :                 return TEST_SKIPPED;
   15811         [ #  # ]:          0 :         if (retval < 0)
   15812                 :            :                 return retval;
   15813                 :            : 
   15814                 :          0 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   15815         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   15816                 :            :                         "Failed to allocate input buffer in mempool");
   15817                 :            : 
   15818                 :          0 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   15819                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   15820                 :            : 
   15821                 :          0 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   15822                 :            :                                 plaintext_len);
   15823         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
   15824                 :            : 
   15825                 :          0 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
   15826                 :            : 
   15827                 :            :         trn_data += plaintext_len;
   15828                 :            : 
   15829                 :          0 :         buf = ut_params->ibuf;
   15830                 :            : 
   15831                 :            :         /*
   15832                 :            :          * Loop until no more fragments
   15833                 :            :          */
   15834                 :            : 
   15835         [ #  # ]:          0 :         while (trn_data < tdata->plaintext.len) {
   15836                 :          0 :                 ++segs;
   15837                 :          0 :                 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
   15838                 :            :                                 (tdata->plaintext.len - trn_data) : fragsz;
   15839                 :            : 
   15840                 :          0 :                 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   15841                 :            :                 buf = buf->next;
   15842                 :            : 
   15843                 :          0 :                 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
   15844                 :            :                                 rte_pktmbuf_tailroom(buf));
   15845                 :            : 
   15846                 :          0 :                 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
   15847                 :            :                                 to_trn);
   15848                 :            : 
   15849         [ #  # ]:          0 :                 memcpy(plaintext, tdata->plaintext.data + trn_data,
   15850                 :            :                                 to_trn);
   15851                 :          0 :                 trn_data += to_trn;
   15852         [ #  # ]:          0 :                 if (trn_data  == tdata->plaintext.len)
   15853                 :          0 :                         digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
   15854                 :          0 :                                         tdata->gmac_tag.len);
   15855                 :            :         }
   15856         [ #  # ]:          0 :         ut_params->ibuf->nb_segs = segs;
   15857                 :            : 
   15858                 :            :         /*
   15859                 :            :          * Place digest at the end of the last buffer
   15860                 :            :          */
   15861                 :          0 :         uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
   15862                 :            : 
   15863         [ #  # ]:          0 :         if (!digest_mem) {
   15864                 :          0 :                 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   15865                 :          0 :                                 + tdata->gmac_tag.len);
   15866                 :          0 :                 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
   15867                 :            :                                 tdata->plaintext.len);
   15868                 :            :         }
   15869                 :            : 
   15870                 :          0 :         retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
   15871                 :            :                         tdata, digest_mem, digest_phys);
   15872                 :            : 
   15873         [ #  # ]:          0 :         if (retval < 0)
   15874                 :            :                 return retval;
   15875                 :            : 
   15876         [ #  # ]:          0 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   15877                 :            : 
   15878                 :          0 :         ut_params->op->sym->m_src = ut_params->ibuf;
   15879                 :            : 
   15880         [ #  # ]:          0 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   15881                 :            :                 return TEST_SKIPPED;
   15882                 :            : 
   15883         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(
   15884                 :            :                 process_crypto_request(ts_params->valid_devs[0],
   15885                 :            :                 ut_params->op), "failed to process sym crypto op");
   15886                 :            : 
   15887         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   15888                 :            :                         "crypto op processing failed");
   15889                 :            : 
   15890                 :            :         auth_tag = digest_mem;
   15891                 :          0 :         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
   15892         [ #  # ]:          0 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   15893                 :            :                         auth_tag,
   15894                 :            :                         tdata->gmac_tag.data,
   15895                 :            :                         tdata->gmac_tag.len,
   15896                 :            :                         "GMAC Generated auth tag not as expected");
   15897                 :            : 
   15898                 :            :         return 0;
   15899                 :            : }
   15900                 :            : 
   15901                 :            : /* Segment size not multiple of block size (16B) */
   15902                 :            : static int
   15903                 :          1 : test_AES_GMAC_authentication_SGL_40B(void)
   15904                 :            : {
   15905                 :          1 :         return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
   15906                 :            : }
   15907                 :            : 
   15908                 :            : static int
   15909                 :          1 : test_AES_GMAC_authentication_SGL_80B(void)
   15910                 :            : {
   15911                 :          1 :         return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
   15912                 :            : }
   15913                 :            : 
   15914                 :            : static int
   15915                 :          1 : test_AES_GMAC_authentication_SGL_2048B(void)
   15916                 :            : {
   15917                 :          1 :         return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
   15918                 :            : }
   15919                 :            : 
   15920                 :            : /* Segment size not multiple of block size (16B) */
   15921                 :            : static int
   15922                 :          1 : test_AES_GMAC_authentication_SGL_2047B(void)
   15923                 :            : {
   15924                 :          1 :         return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
   15925                 :            : }
   15926                 :            : 
   15927                 :            : struct test_crypto_vector {
   15928                 :            :         enum rte_crypto_cipher_algorithm crypto_algo;
   15929                 :            :         unsigned int cipher_offset;
   15930                 :            :         unsigned int cipher_len;
   15931                 :            : 
   15932                 :            :         struct {
   15933                 :            :                 uint8_t data[64];
   15934                 :            :                 unsigned int len;
   15935                 :            :         } cipher_key;
   15936                 :            : 
   15937                 :            :         struct {
   15938                 :            :                 uint8_t data[64];
   15939                 :            :                 unsigned int len;
   15940                 :            :         } iv;
   15941                 :            : 
   15942                 :            :         struct {
   15943                 :            :                 const uint8_t *data;
   15944                 :            :                 unsigned int len;
   15945                 :            :         } plaintext;
   15946                 :            : 
   15947                 :            :         struct {
   15948                 :            :                 const uint8_t *data;
   15949                 :            :                 unsigned int len;
   15950                 :            :         } ciphertext;
   15951                 :            : 
   15952                 :            :         enum rte_crypto_auth_algorithm auth_algo;
   15953                 :            :         unsigned int auth_offset;
   15954                 :            : 
   15955                 :            :         struct {
   15956                 :            :                 uint8_t data[128];
   15957                 :            :                 unsigned int len;
   15958                 :            :         } auth_key;
   15959                 :            : 
   15960                 :            :         struct {
   15961                 :            :                 const uint8_t *data;
   15962                 :            :                 unsigned int len;
   15963                 :            :         } aad;
   15964                 :            : 
   15965                 :            :         struct {
   15966                 :            :                 uint8_t data[128];
   15967                 :            :                 unsigned int len;
   15968                 :            :         } digest;
   15969                 :            : };
   15970                 :            : 
   15971                 :            : static const struct test_crypto_vector
   15972                 :            : hmac_sha1_test_crypto_vector = {
   15973                 :            :         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
   15974                 :            :         .plaintext = {
   15975                 :            :                 .data = plaintext_hash,
   15976                 :            :                 .len = 512
   15977                 :            :         },
   15978                 :            :         .auth_key = {
   15979                 :            :                 .data = {
   15980                 :            :                         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
   15981                 :            :                         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
   15982                 :            :                         0xDE, 0xF4, 0xDE, 0xAD
   15983                 :            :                 },
   15984                 :            :                 .len = 20
   15985                 :            :         },
   15986                 :            :         .digest = {
   15987                 :            :                 .data = {
   15988                 :            :                         0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
   15989                 :            :                         0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
   15990                 :            :                         0x3F, 0x91, 0x64, 0x59
   15991                 :            :                 },
   15992                 :            :                 .len = 20
   15993                 :            :         }
   15994                 :            : };
   15995                 :            : 
   15996                 :            : static const struct test_crypto_vector
   15997                 :            : aes128_gmac_test_vector = {
   15998                 :            :         .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
   15999                 :            :         .plaintext = {
   16000                 :            :                 .data = plaintext_hash,
   16001                 :            :                 .len = 512
   16002                 :            :         },
   16003                 :            :         .iv = {
   16004                 :            :                 .data = {
   16005                 :            :                         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
   16006                 :            :                         0x08, 0x09, 0x0A, 0x0B
   16007                 :            :                 },
   16008                 :            :                 .len = 12
   16009                 :            :         },
   16010                 :            :         .auth_key = {
   16011                 :            :                 .data = {
   16012                 :            :                         0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
   16013                 :            :                         0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
   16014                 :            :                 },
   16015                 :            :                 .len = 16
   16016                 :            :         },
   16017                 :            :         .digest = {
   16018                 :            :                 .data = {
   16019                 :            :                         0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
   16020                 :            :                         0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
   16021                 :            :                 },
   16022                 :            :                 .len = 16
   16023                 :            :         }
   16024                 :            : };
   16025                 :            : 
   16026                 :            : static const struct test_crypto_vector
   16027                 :            : aes128cbc_hmac_sha1_test_vector = {
   16028                 :            :         .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
   16029                 :            :         .cipher_offset = 0,
   16030                 :            :         .cipher_len = 512,
   16031                 :            :         .cipher_key = {
   16032                 :            :                 .data = {
   16033                 :            :                         0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
   16034                 :            :                         0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
   16035                 :            :                 },
   16036                 :            :                 .len = 16
   16037                 :            :         },
   16038                 :            :         .iv = {
   16039                 :            :                 .data = {
   16040                 :            :                         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
   16041                 :            :                         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
   16042                 :            :                 },
   16043                 :            :                 .len = 16
   16044                 :            :         },
   16045                 :            :         .plaintext = {
   16046                 :            :                 .data = plaintext_hash,
   16047                 :            :                 .len = 512
   16048                 :            :         },
   16049                 :            :         .ciphertext = {
   16050                 :            :                 .data = ciphertext512_aes128cbc,
   16051                 :            :                 .len = 512
   16052                 :            :         },
   16053                 :            :         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
   16054                 :            :         .auth_offset = 0,
   16055                 :            :         .auth_key = {
   16056                 :            :                 .data = {
   16057                 :            :                         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
   16058                 :            :                         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
   16059                 :            :                         0xDE, 0xF4, 0xDE, 0xAD
   16060                 :            :                 },
   16061                 :            :                 .len = 20
   16062                 :            :         },
   16063                 :            :         .digest = {
   16064                 :            :                 .data = {
   16065                 :            :                         0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
   16066                 :            :                         0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
   16067                 :            :                         0x18, 0x8C, 0x1D, 0x32
   16068                 :            :                 },
   16069                 :            :                 .len = 20
   16070                 :            :         }
   16071                 :            : };
   16072                 :            : 
   16073                 :            : static const struct test_crypto_vector
   16074                 :            : aes128cbc_hmac_sha1_aad_test_vector = {
   16075                 :            :         .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
   16076                 :            :         .cipher_offset = 8,
   16077                 :            :         .cipher_len = 496,
   16078                 :            :         .cipher_key = {
   16079                 :            :                 .data = {
   16080                 :            :                         0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
   16081                 :            :                         0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
   16082                 :            :                 },
   16083                 :            :                 .len = 16
   16084                 :            :         },
   16085                 :            :         .iv = {
   16086                 :            :                 .data = {
   16087                 :            :                         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
   16088                 :            :                         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
   16089                 :            :                 },
   16090                 :            :                 .len = 16
   16091                 :            :         },
   16092                 :            :         .plaintext = {
   16093                 :            :                 .data = plaintext_hash,
   16094                 :            :                 .len = 512
   16095                 :            :         },
   16096                 :            :         .ciphertext = {
   16097                 :            :                 .data = ciphertext512_aes128cbc_aad,
   16098                 :            :                 .len = 512
   16099                 :            :         },
   16100                 :            :         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
   16101                 :            :         .auth_offset = 0,
   16102                 :            :         .auth_key = {
   16103                 :            :                 .data = {
   16104                 :            :                         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
   16105                 :            :                         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
   16106                 :            :                         0xDE, 0xF4, 0xDE, 0xAD
   16107                 :            :                 },
   16108                 :            :                 .len = 20
   16109                 :            :         },
   16110                 :            :         .digest = {
   16111                 :            :                 .data = {
   16112                 :            :                         0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
   16113                 :            :                         0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
   16114                 :            :                         0x62, 0x0F, 0xFB, 0x10
   16115                 :            :                 },
   16116                 :            :                 .len = 20
   16117                 :            :         }
   16118                 :            : };
   16119                 :            : 
   16120                 :            : static void
   16121                 :            : data_corruption(uint8_t *data)
   16122                 :            : {
   16123                 :          3 :         data[0] += 1;
   16124                 :          3 : }
   16125                 :            : 
   16126                 :            : static void
   16127                 :            : tag_corruption(uint8_t *data, unsigned int tag_offset)
   16128                 :            : {
   16129                 :          3 :         data[tag_offset] += 1;
   16130                 :          3 : }
   16131                 :            : 
   16132                 :            : static int
   16133                 :          2 : create_auth_session(struct crypto_unittest_params *ut_params,
   16134                 :            :                 uint8_t dev_id,
   16135                 :            :                 const struct test_crypto_vector *reference,
   16136                 :            :                 enum rte_crypto_auth_operation auth_op)
   16137                 :          2 : {
   16138                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   16139                 :          2 :         uint8_t auth_key[reference->auth_key.len + 1];
   16140                 :            : 
   16141                 :          2 :         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
   16142                 :            : 
   16143                 :            :         /* Setup Authentication Parameters */
   16144                 :          2 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16145                 :          2 :         ut_params->auth_xform.auth.op = auth_op;
   16146                 :          2 :         ut_params->auth_xform.next = NULL;
   16147                 :          2 :         ut_params->auth_xform.auth.algo = reference->auth_algo;
   16148                 :          2 :         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
   16149                 :          2 :         ut_params->auth_xform.auth.key.data = auth_key;
   16150                 :          2 :         ut_params->auth_xform.auth.digest_length = reference->digest.len;
   16151                 :            : 
   16152                 :            :         /* Create Crypto session*/
   16153                 :          2 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
   16154                 :            :                                 &ut_params->auth_xform,
   16155                 :            :                                 ts_params->session_mpool);
   16156   [ -  +  -  - ]:          2 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   16157                 :          0 :                 return TEST_SKIPPED;
   16158                 :            : 
   16159                 :            :         return 0;
   16160                 :            : }
   16161                 :            : 
   16162                 :            : static int
   16163                 :          4 : create_auth_cipher_session(struct crypto_unittest_params *ut_params,
   16164                 :            :                 uint8_t dev_id,
   16165                 :            :                 const struct test_crypto_vector *reference,
   16166                 :            :                 enum rte_crypto_auth_operation auth_op,
   16167                 :            :                 enum rte_crypto_cipher_operation cipher_op)
   16168                 :          4 : {
   16169                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   16170                 :          4 :         uint8_t cipher_key[reference->cipher_key.len + 1];
   16171                 :          4 :         uint8_t auth_key[reference->auth_key.len + 1];
   16172                 :            : 
   16173         [ +  + ]:          4 :         memcpy(cipher_key, reference->cipher_key.data,
   16174                 :            :                         reference->cipher_key.len);
   16175                 :          4 :         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
   16176                 :            : 
   16177                 :            :         /* Setup Authentication Parameters */
   16178                 :          4 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16179                 :          4 :         ut_params->auth_xform.auth.op = auth_op;
   16180                 :          4 :         ut_params->auth_xform.auth.algo = reference->auth_algo;
   16181                 :          4 :         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
   16182                 :          4 :         ut_params->auth_xform.auth.key.data = auth_key;
   16183                 :          4 :         ut_params->auth_xform.auth.digest_length = reference->digest.len;
   16184                 :            : 
   16185         [ +  + ]:          4 :         if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
   16186                 :          2 :                 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
   16187                 :          2 :                 ut_params->auth_xform.auth.iv.length = reference->iv.len;
   16188                 :            :         } else {
   16189                 :          2 :                 ut_params->auth_xform.next = &ut_params->cipher_xform;
   16190                 :            : 
   16191                 :            :                 /* Setup Cipher Parameters */
   16192                 :          2 :                 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   16193                 :          2 :                 ut_params->cipher_xform.next = NULL;
   16194                 :          2 :                 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
   16195                 :          2 :                 ut_params->cipher_xform.cipher.op = cipher_op;
   16196                 :          2 :                 ut_params->cipher_xform.cipher.key.data = cipher_key;
   16197                 :          2 :                 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
   16198                 :          2 :                 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   16199                 :          2 :                 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
   16200                 :            :         }
   16201                 :            : 
   16202                 :            :         /* Create Crypto session*/
   16203                 :          4 :         ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
   16204                 :            :                                 &ut_params->auth_xform,
   16205                 :            :                                 ts_params->session_mpool);
   16206   [ -  +  -  - ]:          4 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   16207                 :          0 :                 return TEST_SKIPPED;
   16208                 :            : 
   16209                 :            :         return 0;
   16210                 :            : }
   16211                 :            : 
   16212                 :            : static int
   16213                 :          2 : create_auth_operation(struct crypto_testsuite_params *ts_params,
   16214                 :            :                 struct crypto_unittest_params *ut_params,
   16215                 :            :                 const struct test_crypto_vector *reference,
   16216                 :            :                 unsigned int auth_generate)
   16217                 :            : {
   16218                 :            :         /* Generate Crypto op data structure */
   16219                 :          2 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   16220                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   16221         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   16222                 :            :                         "Failed to allocate pktmbuf offload");
   16223                 :            : 
   16224                 :            :         /* Set crypto operation data parameters */
   16225         [ +  - ]:          2 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   16226                 :            : 
   16227                 :          2 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
   16228                 :            : 
   16229                 :            :         /* set crypto operation source mbuf */
   16230                 :          2 :         sym_op->m_src = ut_params->ibuf;
   16231                 :            : 
   16232                 :            :         /* digest */
   16233                 :          4 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
   16234                 :          2 :                         ut_params->ibuf, reference->digest.len);
   16235                 :            : 
   16236         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
   16237                 :            :                         "no room to append auth tag");
   16238                 :            : 
   16239         [ -  + ]:          2 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
   16240                 :            :                         ut_params->ibuf, reference->plaintext.len);
   16241                 :            : 
   16242         [ -  + ]:          2 :         if (auth_generate)
   16243                 :          0 :                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
   16244                 :            :         else
   16245                 :          2 :                 memcpy(sym_op->auth.digest.data,
   16246                 :          2 :                                 reference->digest.data,
   16247                 :          2 :                                 reference->digest.len);
   16248                 :            : 
   16249                 :          2 :         debug_hexdump(stdout, "digest:",
   16250                 :          2 :                         sym_op->auth.digest.data,
   16251                 :          2 :                         reference->digest.len);
   16252                 :            : 
   16253                 :          2 :         sym_op->auth.data.length = reference->plaintext.len;
   16254                 :          2 :         sym_op->auth.data.offset = 0;
   16255                 :            : 
   16256                 :          2 :         return 0;
   16257                 :            : }
   16258                 :            : 
   16259                 :            : static int
   16260                 :          2 : create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
   16261                 :            :                 struct crypto_unittest_params *ut_params,
   16262                 :            :                 const struct test_crypto_vector *reference,
   16263                 :            :                 unsigned int auth_generate)
   16264                 :            : {
   16265                 :            :         /* Generate Crypto op data structure */
   16266                 :          2 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   16267                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   16268         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   16269                 :            :                         "Failed to allocate pktmbuf offload");
   16270                 :            : 
   16271                 :            :         /* Set crypto operation data parameters */
   16272         [ +  - ]:          2 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   16273                 :            : 
   16274                 :          2 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
   16275                 :            : 
   16276                 :            :         /* set crypto operation source mbuf */
   16277                 :          2 :         sym_op->m_src = ut_params->ibuf;
   16278                 :            : 
   16279                 :            :         /* digest */
   16280                 :          4 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
   16281                 :          2 :                         ut_params->ibuf, reference->digest.len);
   16282                 :            : 
   16283         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
   16284                 :            :                         "no room to append auth tag");
   16285                 :            : 
   16286         [ -  + ]:          2 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
   16287                 :            :                         ut_params->ibuf, reference->ciphertext.len);
   16288                 :            : 
   16289         [ -  + ]:          2 :         if (auth_generate)
   16290                 :          0 :                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
   16291                 :            :         else
   16292                 :          2 :                 memcpy(sym_op->auth.digest.data,
   16293                 :          2 :                                 reference->digest.data,
   16294                 :          2 :                                 reference->digest.len);
   16295                 :            : 
   16296                 :          2 :         debug_hexdump(stdout, "digest:",
   16297                 :          2 :                         sym_op->auth.digest.data,
   16298                 :          2 :                         reference->digest.len);
   16299                 :            : 
   16300                 :          2 :         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
   16301         [ -  + ]:          2 :                         reference->iv.data, reference->iv.len);
   16302                 :            : 
   16303                 :          2 :         sym_op->cipher.data.length = 0;
   16304                 :          2 :         sym_op->cipher.data.offset = 0;
   16305                 :            : 
   16306                 :          2 :         sym_op->auth.data.length = reference->plaintext.len;
   16307                 :          2 :         sym_op->auth.data.offset = 0;
   16308                 :            : 
   16309                 :          2 :         return 0;
   16310                 :            : }
   16311                 :            : 
   16312                 :            : static int
   16313                 :          4 : create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
   16314                 :            :                 struct crypto_unittest_params *ut_params,
   16315                 :            :                 const struct test_crypto_vector *reference,
   16316                 :            :                 unsigned int auth_generate)
   16317                 :            : {
   16318                 :            :         /* Generate Crypto op data structure */
   16319                 :          4 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   16320                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   16321         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   16322                 :            :                         "Failed to allocate pktmbuf offload");
   16323                 :            : 
   16324                 :            :         /* Set crypto operation data parameters */
   16325         [ +  - ]:          4 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   16326                 :            : 
   16327                 :          4 :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
   16328                 :            : 
   16329                 :            :         /* set crypto operation source mbuf */
   16330                 :          4 :         sym_op->m_src = ut_params->ibuf;
   16331                 :            : 
   16332                 :            :         /* digest */
   16333                 :          8 :         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
   16334                 :          4 :                         ut_params->ibuf, reference->digest.len);
   16335                 :            : 
   16336         [ -  + ]:          4 :         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
   16337                 :            :                         "no room to append auth tag");
   16338                 :            : 
   16339         [ -  + ]:          4 :         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
   16340                 :            :                         ut_params->ibuf, reference->ciphertext.len);
   16341                 :            : 
   16342         [ -  + ]:          4 :         if (auth_generate)
   16343                 :          0 :                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
   16344                 :            :         else
   16345                 :          4 :                 memcpy(sym_op->auth.digest.data,
   16346                 :          4 :                                 reference->digest.data,
   16347                 :          4 :                                 reference->digest.len);
   16348                 :            : 
   16349                 :          4 :         debug_hexdump(stdout, "digest:",
   16350                 :          4 :                         sym_op->auth.digest.data,
   16351                 :          4 :                         reference->digest.len);
   16352                 :            : 
   16353                 :          4 :         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
   16354         [ -  + ]:          4 :                         reference->iv.data, reference->iv.len);
   16355                 :            : 
   16356                 :          4 :         sym_op->cipher.data.length = reference->cipher_len;
   16357                 :          4 :         sym_op->cipher.data.offset = reference->cipher_offset;
   16358                 :            : 
   16359                 :          4 :         sym_op->auth.data.length = reference->plaintext.len;
   16360                 :          4 :         sym_op->auth.data.offset = reference->auth_offset;
   16361                 :            : 
   16362                 :          4 :         return 0;
   16363                 :            : }
   16364                 :            : 
   16365                 :            : static int
   16366                 :            : create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
   16367                 :            :                 struct crypto_unittest_params *ut_params,
   16368                 :            :                 const struct test_crypto_vector *reference)
   16369                 :            : {
   16370                 :          2 :         return create_auth_operation(ts_params, ut_params, reference, 0);
   16371                 :            : }
   16372                 :            : 
   16373                 :            : static int
   16374                 :            : create_auth_verify_GMAC_operation(
   16375                 :            :                 struct crypto_testsuite_params *ts_params,
   16376                 :            :                 struct crypto_unittest_params *ut_params,
   16377                 :            :                 const struct test_crypto_vector *reference)
   16378                 :            : {
   16379                 :          2 :         return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
   16380                 :            : }
   16381                 :            : 
   16382                 :            : static int
   16383                 :            : create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
   16384                 :            :                 struct crypto_unittest_params *ut_params,
   16385                 :            :                 const struct test_crypto_vector *reference)
   16386                 :            : {
   16387                 :          3 :         return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
   16388                 :            : }
   16389                 :            : 
   16390                 :            : static int
   16391                 :          2 : test_authentication_verify_fail_when_data_corruption(
   16392                 :            :                 struct crypto_testsuite_params *ts_params,
   16393                 :            :                 struct crypto_unittest_params *ut_params,
   16394                 :            :                 const struct test_crypto_vector *reference,
   16395                 :            :                 unsigned int data_corrupted)
   16396                 :            : {
   16397                 :            :         int retval;
   16398                 :            : 
   16399                 :            :         uint8_t *plaintext;
   16400                 :            :         struct rte_cryptodev_info dev_info;
   16401                 :            : 
   16402                 :          2 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   16403                 :          2 :         uint64_t feat_flags = dev_info.feature_flags;
   16404                 :            : 
   16405         [ -  + ]:          2 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   16406         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   16407                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   16408                 :          0 :                 return TEST_SKIPPED;
   16409                 :            :         }
   16410                 :            : 
   16411                 :            :         /* Verify the capabilities */
   16412                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   16413                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16414                 :          2 :         cap_idx.algo.auth = reference->auth_algo;
   16415         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16416                 :            :                         &cap_idx) == NULL)
   16417                 :            :                 return TEST_SKIPPED;
   16418                 :            : 
   16419                 :            : 
   16420                 :            :         /* Create session */
   16421                 :          2 :         retval = create_auth_session(ut_params,
   16422                 :          2 :                         ts_params->valid_devs[0],
   16423                 :            :                         reference,
   16424                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY);
   16425                 :            : 
   16426         [ +  - ]:          2 :         if (retval == TEST_SKIPPED)
   16427                 :            :                 return TEST_SKIPPED;
   16428         [ +  - ]:          2 :         if (retval < 0)
   16429                 :            :                 return retval;
   16430                 :            : 
   16431                 :          2 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   16432         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   16433                 :            :                         "Failed to allocate input buffer in mempool");
   16434                 :            : 
   16435                 :            :         /* clear mbuf payload */
   16436                 :          2 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   16437                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   16438                 :            : 
   16439                 :          2 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   16440                 :          2 :                         reference->plaintext.len);
   16441         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
   16442                 :          2 :         memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
   16443                 :            : 
   16444                 :          2 :         debug_hexdump(stdout, "plaintext:", plaintext,
   16445                 :          2 :                 reference->plaintext.len);
   16446                 :            : 
   16447                 :            :         /* Create operation */
   16448                 :            :         retval = create_auth_verify_operation(ts_params, ut_params, reference);
   16449                 :            : 
   16450         [ +  - ]:          2 :         if (retval < 0)
   16451                 :            :                 return retval;
   16452                 :            : 
   16453         [ +  + ]:          2 :         if (data_corrupted)
   16454                 :            :                 data_corruption(plaintext);
   16455                 :            :         else
   16456                 :          1 :                 tag_corruption(plaintext, reference->plaintext.len);
   16457                 :            : 
   16458         [ -  + ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
   16459                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   16460                 :            :                         ut_params->op);
   16461         [ #  # ]:          0 :                 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
   16462                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   16463                 :            :                         "authentication not failed");
   16464         [ -  + ]:          2 :         } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   16465                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
   16466                 :            :                                                0);
   16467         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   16468                 :            :                         return retval;
   16469                 :            :         } else {
   16470                 :          2 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
   16471                 :            :                         ut_params->op);
   16472                 :            :         }
   16473         [ -  + ]:          2 :         if (ut_params->op == NULL)
   16474                 :            :                 return 0;
   16475         [ #  # ]:          0 :         else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
   16476                 :          0 :                 return 0;
   16477                 :            : 
   16478                 :            :         return -1;
   16479                 :            : }
   16480                 :            : 
   16481                 :            : static int
   16482                 :          2 : test_authentication_verify_GMAC_fail_when_corruption(
   16483                 :            :                 struct crypto_testsuite_params *ts_params,
   16484                 :            :                 struct crypto_unittest_params *ut_params,
   16485                 :            :                 const struct test_crypto_vector *reference,
   16486                 :            :                 unsigned int data_corrupted)
   16487                 :            : {
   16488                 :            :         int retval;
   16489                 :            :         uint8_t *plaintext;
   16490                 :            :         struct rte_cryptodev_info dev_info;
   16491                 :            : 
   16492                 :          2 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   16493                 :          2 :         uint64_t feat_flags = dev_info.feature_flags;
   16494                 :            : 
   16495         [ -  + ]:          2 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   16496         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   16497                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   16498                 :          0 :                 return TEST_SKIPPED;
   16499                 :            :         }
   16500                 :            : 
   16501                 :            :         /* Verify the capabilities */
   16502                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   16503                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16504                 :          2 :         cap_idx.algo.auth = reference->auth_algo;
   16505         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16506                 :            :                         &cap_idx) == NULL)
   16507                 :            :                 return TEST_SKIPPED;
   16508                 :            : 
   16509                 :            :         /* Create session */
   16510                 :          2 :         retval = create_auth_cipher_session(ut_params,
   16511                 :          2 :                         ts_params->valid_devs[0],
   16512                 :            :                         reference,
   16513                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY,
   16514                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
   16515         [ +  - ]:          2 :         if (retval == TEST_SKIPPED)
   16516                 :            :                 return TEST_SKIPPED;
   16517         [ +  - ]:          2 :         if (retval < 0)
   16518                 :            :                 return retval;
   16519                 :            : 
   16520                 :          2 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   16521         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   16522                 :            :                         "Failed to allocate input buffer in mempool");
   16523                 :            : 
   16524                 :            :         /* clear mbuf payload */
   16525                 :          2 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   16526                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   16527                 :            : 
   16528                 :          2 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   16529                 :          2 :                         reference->plaintext.len);
   16530         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
   16531                 :          2 :         memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
   16532                 :            : 
   16533                 :          2 :         debug_hexdump(stdout, "plaintext:", plaintext,
   16534                 :          2 :                 reference->plaintext.len);
   16535                 :            : 
   16536                 :            :         /* Create operation */
   16537                 :            :         retval = create_auth_verify_GMAC_operation(ts_params,
   16538                 :            :                         ut_params,
   16539                 :            :                         reference);
   16540                 :            : 
   16541         [ +  - ]:          2 :         if (retval < 0)
   16542                 :            :                 return retval;
   16543                 :            : 
   16544         [ +  + ]:          2 :         if (data_corrupted)
   16545                 :            :                 data_corruption(plaintext);
   16546                 :            :         else
   16547                 :          1 :                 tag_corruption(plaintext, reference->aad.len);
   16548                 :            : 
   16549         [ -  + ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
   16550                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   16551                 :            :                         ut_params->op);
   16552         [ #  # ]:          0 :                 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
   16553                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   16554                 :            :                         "authentication not failed");
   16555         [ -  + ]:          2 :         } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   16556                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
   16557                 :            :                                                0);
   16558         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   16559                 :          0 :                         return retval;
   16560                 :            :         } else {
   16561                 :          2 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
   16562                 :            :                         ut_params->op);
   16563         [ -  + ]:          2 :                 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
   16564                 :            :         }
   16565                 :            : 
   16566                 :            :         return 0;
   16567                 :            : }
   16568                 :            : 
   16569                 :            : static int
   16570                 :          2 : test_authenticated_decryption_fail_when_corruption(
   16571                 :            :                 struct crypto_testsuite_params *ts_params,
   16572                 :            :                 struct crypto_unittest_params *ut_params,
   16573                 :            :                 const struct test_crypto_vector *reference,
   16574                 :            :                 unsigned int data_corrupted)
   16575                 :            : {
   16576                 :            :         int retval;
   16577                 :            : 
   16578                 :            :         uint8_t *ciphertext;
   16579                 :            :         struct rte_cryptodev_info dev_info;
   16580                 :            : 
   16581                 :          2 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   16582                 :          2 :         uint64_t feat_flags = dev_info.feature_flags;
   16583                 :            : 
   16584         [ -  + ]:          2 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   16585         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   16586                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   16587                 :          0 :                 return TEST_SKIPPED;
   16588                 :            :         }
   16589                 :            : 
   16590                 :            :         /* Verify the capabilities */
   16591                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   16592                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16593                 :          2 :         cap_idx.algo.auth = reference->auth_algo;
   16594         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16595                 :            :                         &cap_idx) == NULL)
   16596                 :            :                 return TEST_SKIPPED;
   16597                 :          2 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   16598                 :          2 :         cap_idx.algo.cipher = reference->crypto_algo;
   16599         [ +  - ]:          2 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16600                 :            :                         &cap_idx) == NULL)
   16601                 :            :                 return TEST_SKIPPED;
   16602                 :            : 
   16603                 :            :         /* Create session */
   16604                 :          2 :         retval = create_auth_cipher_session(ut_params,
   16605                 :          2 :                         ts_params->valid_devs[0],
   16606                 :            :                         reference,
   16607                 :            :                         RTE_CRYPTO_AUTH_OP_VERIFY,
   16608                 :            :                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
   16609         [ +  - ]:          2 :         if (retval == TEST_SKIPPED)
   16610                 :            :                 return TEST_SKIPPED;
   16611         [ +  - ]:          2 :         if (retval < 0)
   16612                 :            :                 return retval;
   16613                 :            : 
   16614                 :          2 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   16615         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   16616                 :            :                         "Failed to allocate input buffer in mempool");
   16617                 :            : 
   16618                 :            :         /* clear mbuf payload */
   16619                 :          2 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   16620                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   16621                 :            : 
   16622                 :          2 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   16623                 :          2 :                         reference->ciphertext.len);
   16624         [ -  + ]:          2 :         TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
   16625                 :          2 :         memcpy(ciphertext, reference->ciphertext.data,
   16626                 :          2 :                         reference->ciphertext.len);
   16627                 :            : 
   16628                 :            :         /* Create operation */
   16629                 :            :         retval = create_cipher_auth_verify_operation(ts_params,
   16630                 :            :                         ut_params,
   16631                 :            :                         reference);
   16632                 :            : 
   16633         [ +  - ]:          2 :         if (retval < 0)
   16634                 :            :                 return retval;
   16635                 :            : 
   16636         [ +  + ]:          2 :         if (data_corrupted)
   16637                 :            :                 data_corruption(ciphertext);
   16638                 :            :         else
   16639                 :          1 :                 tag_corruption(ciphertext, reference->ciphertext.len);
   16640                 :            : 
   16641         [ -  + ]:          2 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
   16642                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   16643                 :            :                         ut_params->op);
   16644         [ #  # ]:          0 :                 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
   16645                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   16646                 :            :                         "authentication not failed");
   16647         [ -  + ]:          2 :         } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   16648                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
   16649                 :            :                                                0);
   16650         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   16651                 :          0 :                         return retval;
   16652                 :            :         } else {
   16653                 :          2 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
   16654                 :            :                         ut_params->op);
   16655         [ -  + ]:          2 :                 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
   16656                 :            :         }
   16657                 :            : 
   16658                 :            :         return 0;
   16659                 :            : }
   16660                 :            : 
   16661                 :            : static int
   16662                 :          1 : test_authenticated_encrypt_with_esn(
   16663                 :            :                 struct crypto_testsuite_params *ts_params,
   16664                 :            :                 struct crypto_unittest_params *ut_params,
   16665                 :            :                 const struct test_crypto_vector *reference)
   16666                 :          1 : {
   16667                 :            :         int retval;
   16668                 :            : 
   16669                 :            :         uint8_t *authciphertext, *plaintext, *auth_tag;
   16670                 :            :         uint16_t plaintext_pad_len;
   16671                 :          1 :         uint8_t cipher_key[reference->cipher_key.len + 1];
   16672                 :          1 :         uint8_t auth_key[reference->auth_key.len + 1];
   16673                 :            :         struct rte_cryptodev_info dev_info;
   16674                 :            : 
   16675                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   16676                 :          1 :         uint64_t feat_flags = dev_info.feature_flags;
   16677                 :            : 
   16678         [ -  + ]:          1 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   16679         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   16680                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   16681                 :          0 :                 return TEST_SKIPPED;
   16682                 :            :         }
   16683                 :            : 
   16684                 :            :         /* Verify the capabilities */
   16685                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   16686                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16687                 :          1 :         cap_idx.algo.auth = reference->auth_algo;
   16688         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16689                 :            :                         &cap_idx) == NULL)
   16690                 :            :                 return TEST_SKIPPED;
   16691                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   16692                 :          1 :         cap_idx.algo.cipher = reference->crypto_algo;
   16693         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16694                 :            :                         &cap_idx) == NULL)
   16695                 :            :                 return TEST_SKIPPED;
   16696                 :            : 
   16697                 :            :         /* Create session */
   16698                 :          1 :         memcpy(cipher_key, reference->cipher_key.data,
   16699                 :          1 :                         reference->cipher_key.len);
   16700                 :          1 :         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
   16701                 :            : 
   16702                 :            :         /* Setup Cipher Parameters */
   16703                 :          1 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   16704                 :          1 :         ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
   16705                 :          1 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
   16706                 :          1 :         ut_params->cipher_xform.cipher.key.data = cipher_key;
   16707                 :          1 :         ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
   16708                 :          1 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   16709                 :          1 :         ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
   16710                 :            : 
   16711                 :          1 :         ut_params->cipher_xform.next = &ut_params->auth_xform;
   16712                 :            : 
   16713                 :            :         /* Setup Authentication Parameters */
   16714                 :          1 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16715                 :          1 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
   16716                 :          1 :         ut_params->auth_xform.auth.algo = reference->auth_algo;
   16717                 :          1 :         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
   16718                 :          1 :         ut_params->auth_xform.auth.key.data = auth_key;
   16719                 :          1 :         ut_params->auth_xform.auth.digest_length = reference->digest.len;
   16720                 :          1 :         ut_params->auth_xform.next = NULL;
   16721                 :            : 
   16722                 :            :         /* Create Crypto session*/
   16723                 :          2 :         ut_params->sess = rte_cryptodev_sym_session_create(
   16724                 :          1 :                         ts_params->valid_devs[0], &ut_params->cipher_xform,
   16725                 :            :                         ts_params->session_mpool);
   16726   [ -  +  -  - ]:          1 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   16727                 :            :                 return TEST_SKIPPED;
   16728         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   16729                 :            : 
   16730                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   16731         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   16732                 :            :                         "Failed to allocate input buffer in mempool");
   16733                 :            : 
   16734                 :            :         /* clear mbuf payload */
   16735                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   16736                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   16737                 :            : 
   16738                 :          1 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   16739                 :          1 :                         reference->plaintext.len);
   16740         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
   16741                 :          1 :         memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
   16742                 :            : 
   16743                 :            :         /* Create operation */
   16744                 :          1 :         retval = create_cipher_auth_operation(ts_params,
   16745                 :            :                         ut_params,
   16746                 :            :                         reference, 0);
   16747                 :            : 
   16748         [ +  - ]:          1 :         if (retval < 0)
   16749                 :            :                 return retval;
   16750                 :            : 
   16751         [ -  + ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   16752                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   16753                 :            :                         ut_params->op);
   16754         [ -  + ]:          1 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   16755                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
   16756                 :            :                                                0);
   16757         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   16758                 :            :                         return retval;
   16759                 :            :         } else
   16760                 :          1 :                 ut_params->op = process_crypto_request(
   16761                 :          1 :                         ts_params->valid_devs[0], ut_params->op);
   16762                 :            : 
   16763         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
   16764                 :            : 
   16765         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   16766                 :            :                         "crypto op processing failed");
   16767                 :            : 
   16768                 :          1 :         plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
   16769                 :            : 
   16770                 :          1 :         authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
   16771                 :            :                         ut_params->op->sym->auth.data.offset);
   16772                 :          1 :         auth_tag = authciphertext + plaintext_pad_len;
   16773                 :          1 :         debug_hexdump(stdout, "ciphertext:", authciphertext,
   16774                 :          1 :                         reference->ciphertext.len);
   16775                 :          1 :         debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
   16776                 :            : 
   16777                 :            :         /* Validate obuf */
   16778         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   16779                 :            :                         authciphertext,
   16780                 :            :                         reference->ciphertext.data,
   16781                 :            :                         reference->ciphertext.len,
   16782                 :            :                         "Ciphertext data not as expected");
   16783                 :            : 
   16784         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   16785                 :            :                         auth_tag,
   16786                 :            :                         reference->digest.data,
   16787                 :            :                         reference->digest.len,
   16788                 :            :                         "Generated digest not as expected");
   16789                 :            : 
   16790                 :            :         return TEST_SUCCESS;
   16791                 :            : 
   16792                 :            : }
   16793                 :            : 
   16794                 :            : static int
   16795                 :          1 : test_authenticated_decrypt_with_esn(
   16796                 :            :                 struct crypto_testsuite_params *ts_params,
   16797                 :            :                 struct crypto_unittest_params *ut_params,
   16798                 :            :                 const struct test_crypto_vector *reference)
   16799                 :          1 : {
   16800                 :            :         int retval;
   16801                 :            : 
   16802                 :            :         uint8_t *ciphertext;
   16803                 :          1 :         uint8_t cipher_key[reference->cipher_key.len + 1];
   16804                 :          1 :         uint8_t auth_key[reference->auth_key.len + 1];
   16805                 :            :         struct rte_cryptodev_info dev_info;
   16806                 :            : 
   16807                 :          1 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   16808                 :          1 :         uint64_t feat_flags = dev_info.feature_flags;
   16809                 :            : 
   16810         [ -  + ]:          1 :         if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   16811         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   16812                 :            :                 printf("Device doesn't support RAW data-path APIs.\n");
   16813                 :          0 :                 return TEST_SKIPPED;
   16814                 :            :         }
   16815                 :            : 
   16816                 :            :         /* Verify the capabilities */
   16817                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   16818                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16819                 :          1 :         cap_idx.algo.auth = reference->auth_algo;
   16820         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16821                 :            :                         &cap_idx) == NULL)
   16822                 :            :                 return TEST_SKIPPED;
   16823                 :          1 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   16824                 :          1 :         cap_idx.algo.cipher = reference->crypto_algo;
   16825         [ +  - ]:          1 :         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
   16826                 :            :                         &cap_idx) == NULL)
   16827                 :            :                 return TEST_SKIPPED;
   16828                 :            : 
   16829                 :            :         /* Create session */
   16830                 :          1 :         memcpy(cipher_key, reference->cipher_key.data,
   16831                 :          1 :                         reference->cipher_key.len);
   16832                 :          1 :         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
   16833                 :            : 
   16834                 :            :         /* Setup Authentication Parameters */
   16835                 :          1 :         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
   16836                 :          1 :         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
   16837                 :          1 :         ut_params->auth_xform.auth.algo = reference->auth_algo;
   16838                 :          1 :         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
   16839                 :          1 :         ut_params->auth_xform.auth.key.data = auth_key;
   16840                 :          1 :         ut_params->auth_xform.auth.digest_length = reference->digest.len;
   16841                 :          1 :         ut_params->auth_xform.next = &ut_params->cipher_xform;
   16842                 :            : 
   16843                 :            :         /* Setup Cipher Parameters */
   16844                 :          1 :         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   16845                 :          1 :         ut_params->cipher_xform.next = NULL;
   16846                 :          1 :         ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
   16847                 :          1 :         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
   16848                 :          1 :         ut_params->cipher_xform.cipher.key.data = cipher_key;
   16849                 :          1 :         ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
   16850                 :          1 :         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
   16851                 :          1 :         ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
   16852                 :            : 
   16853                 :            :         /* Create Crypto session*/
   16854                 :          2 :         ut_params->sess = rte_cryptodev_sym_session_create(
   16855                 :          1 :                         ts_params->valid_devs[0], &ut_params->auth_xform,
   16856                 :            :                         ts_params->session_mpool);
   16857   [ -  +  -  - ]:          1 :         if (ut_params->sess == NULL && rte_errno == ENOTSUP)
   16858                 :            :                 return TEST_SKIPPED;
   16859         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
   16860                 :            : 
   16861                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   16862         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
   16863                 :            :                         "Failed to allocate input buffer in mempool");
   16864                 :            : 
   16865                 :            :         /* clear mbuf payload */
   16866                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   16867                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   16868                 :            : 
   16869                 :          1 :         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   16870                 :          1 :                         reference->ciphertext.len);
   16871         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
   16872                 :          1 :         memcpy(ciphertext, reference->ciphertext.data,
   16873                 :          1 :                         reference->ciphertext.len);
   16874                 :            : 
   16875                 :            :         /* Create operation */
   16876                 :            :         retval = create_cipher_auth_verify_operation(ts_params,
   16877                 :            :                         ut_params,
   16878                 :            :                         reference);
   16879                 :            : 
   16880         [ +  - ]:          1 :         if (retval < 0)
   16881                 :            :                 return retval;
   16882                 :            : 
   16883         [ -  + ]:          1 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   16884                 :          0 :                 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
   16885                 :            :                         ut_params->op);
   16886         [ -  + ]:          1 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   16887                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
   16888                 :            :                                                0);
   16889         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   16890                 :            :                         return retval;
   16891                 :            :         } else
   16892                 :          1 :                 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
   16893                 :            :                         ut_params->op);
   16894                 :            : 
   16895         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
   16896         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status,
   16897                 :            :                         RTE_CRYPTO_OP_STATUS_SUCCESS,
   16898                 :            :                         "crypto op processing passed");
   16899                 :            : 
   16900                 :          1 :         ut_params->obuf = ut_params->op->sym->m_src;
   16901         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
   16902                 :            : 
   16903                 :            :         return 0;
   16904                 :            : }
   16905                 :            : 
   16906                 :            : static int
   16907                 :          1 : create_aead_operation_SGL(enum rte_crypto_aead_operation op,
   16908                 :            :                 const struct aead_test_data *tdata,
   16909                 :            :                 void *digest_mem, uint64_t digest_phys)
   16910                 :            : {
   16911                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   16912                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   16913                 :            : 
   16914                 :          1 :         const unsigned int auth_tag_len = tdata->auth_tag.len;
   16915                 :          1 :         const unsigned int iv_len = tdata->iv.len;
   16916                 :          1 :         unsigned int aad_len = tdata->aad.len;
   16917                 :            :         unsigned int aad_len_pad = 0;
   16918                 :            : 
   16919                 :            :         /* Generate Crypto op data structure */
   16920                 :          1 :         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
   16921                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
   16922         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(ut_params->op,
   16923                 :            :                 "Failed to allocate symmetric crypto operation struct");
   16924                 :            : 
   16925                 :            :         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
   16926                 :            : 
   16927                 :          1 :         sym_op->aead.digest.data = digest_mem;
   16928                 :            : 
   16929         [ -  + ]:          1 :         TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
   16930                 :            :                         "no room to append digest");
   16931                 :            : 
   16932                 :          1 :         sym_op->aead.digest.phys_addr = digest_phys;
   16933                 :            : 
   16934         [ -  + ]:          1 :         if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
   16935         [ #  # ]:          0 :                 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
   16936                 :            :                                 auth_tag_len);
   16937                 :          0 :                 debug_hexdump(stdout, "digest:",
   16938                 :          0 :                                 sym_op->aead.digest.data,
   16939                 :            :                                 auth_tag_len);
   16940                 :            :         }
   16941                 :            : 
   16942                 :            :         /* Append aad data */
   16943         [ -  + ]:          1 :         if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
   16944                 :          0 :                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
   16945                 :            :                                 uint8_t *, IV_OFFSET);
   16946                 :            : 
   16947                 :            :                 /* Copy IV 1 byte after the IV pointer, according to the API */
   16948         [ #  # ]:          0 :                 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
   16949                 :            : 
   16950                 :          0 :                 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
   16951                 :            : 
   16952         [ #  # ]:          0 :                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
   16953                 :            :                                 ut_params->ibuf, aad_len);
   16954         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
   16955                 :            :                                 "no room to prepend aad");
   16956         [ #  # ]:          0 :                 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
   16957                 :            :                                 ut_params->ibuf);
   16958                 :            : 
   16959         [ #  # ]:          0 :                 memset(sym_op->aead.aad.data, 0, aad_len);
   16960                 :            :                 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
   16961         [ #  # ]:          0 :                 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
   16962                 :            : 
   16963                 :          0 :                 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
   16964                 :          0 :                 debug_hexdump(stdout, "aad:",
   16965                 :          0 :                                 sym_op->aead.aad.data, aad_len);
   16966                 :            :         } else {
   16967                 :          1 :                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
   16968                 :            :                                 uint8_t *, IV_OFFSET);
   16969                 :            : 
   16970         [ -  + ]:          1 :                 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
   16971                 :            : 
   16972                 :          1 :                 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
   16973                 :            : 
   16974         [ +  - ]:          1 :                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
   16975                 :            :                                 ut_params->ibuf, aad_len_pad);
   16976         [ -  + ]:          1 :                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
   16977                 :            :                                 "no room to prepend aad");
   16978         [ -  + ]:          1 :                 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
   16979                 :            :                                 ut_params->ibuf);
   16980                 :            : 
   16981         [ -  + ]:          1 :                 memset(sym_op->aead.aad.data, 0, aad_len);
   16982         [ -  + ]:          1 :                 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
   16983                 :            : 
   16984                 :          1 :                 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
   16985                 :          1 :                 debug_hexdump(stdout, "aad:",
   16986                 :          1 :                                 sym_op->aead.aad.data, aad_len);
   16987                 :            :         }
   16988                 :            : 
   16989                 :          1 :         sym_op->aead.data.length = tdata->plaintext.len;
   16990                 :          1 :         sym_op->aead.data.offset = aad_len_pad;
   16991                 :            : 
   16992                 :          1 :         return 0;
   16993                 :            : }
   16994                 :            : 
   16995                 :            : #define SGL_MAX_NO      16
   16996                 :            : 
   16997                 :            : static int
   16998                 :          3 : test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
   16999                 :            :                 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
   17000                 :            : {
   17001                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   17002                 :            :         struct crypto_unittest_params *ut_params = &unittest_params;
   17003                 :            :         struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
   17004                 :            :         int retval;
   17005                 :            :         int to_trn = 0;
   17006                 :            :         int to_trn_tbl[SGL_MAX_NO];
   17007                 :            :         int segs = 1;
   17008                 :            :         unsigned int trn_data = 0;
   17009                 :            :         uint8_t *plaintext, *ciphertext, *auth_tag;
   17010                 :            :         struct rte_cryptodev_info dev_info;
   17011                 :            : 
   17012                 :            :         /* Verify the capabilities */
   17013                 :            :         struct rte_cryptodev_sym_capability_idx cap_idx;
   17014                 :            :         const struct rte_cryptodev_symmetric_capability *capability;
   17015                 :          3 :         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
   17016                 :          3 :         cap_idx.algo.aead = tdata->algo;
   17017                 :          3 :         capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
   17018         [ +  - ]:          3 :         if (capability == NULL)
   17019                 :            :                 return TEST_SKIPPED;
   17020         [ +  - ]:          3 :         if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
   17021                 :          3 :                         tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
   17022                 :            :                 return TEST_SKIPPED;
   17023                 :            : 
   17024                 :            :         /*
   17025                 :            :          * SGL not supported on AESNI_MB PMD CPU crypto,
   17026                 :            :          * OOP not supported on AESNI_GCM CPU crypto
   17027                 :            :          */
   17028         [ -  + ]:          3 :         if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
   17029         [ #  # ]:          0 :                         (gbl_driver_id == rte_cryptodev_driver_id_get(
   17030         [ #  # ]:          0 :                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
   17031                 :            :                 return TEST_SKIPPED;
   17032                 :            : 
   17033                 :            :         /* Detailed check for the particular SGL support flag */
   17034                 :          3 :         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
   17035         [ -  + ]:          3 :         if (!oop) {
   17036                 :          0 :                 unsigned int sgl_in = fragsz < tdata->plaintext.len;
   17037   [ #  #  #  # ]:          0 :                 if (sgl_in && (!(dev_info.feature_flags &
   17038                 :            :                                 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
   17039                 :            :                         return TEST_SKIPPED;
   17040                 :            : 
   17041                 :          0 :                 uint64_t feat_flags = dev_info.feature_flags;
   17042                 :            : 
   17043         [ #  # ]:          0 :                 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
   17044         [ #  # ]:          0 :                         (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
   17045                 :            :                         printf("Device doesn't support RAW data-path APIs.\n");
   17046                 :          0 :                         return TEST_SKIPPED;
   17047                 :            :                 }
   17048                 :            :         } else {
   17049                 :          3 :                 unsigned int sgl_in = fragsz < tdata->plaintext.len;
   17050         [ -  + ]:          3 :                 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
   17051                 :            :                                 tdata->plaintext.len;
   17052                 :            :                 /* Raw data path API does not support OOP */
   17053         [ +  - ]:          3 :                 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
   17054                 :            :                         return TEST_SKIPPED;
   17055         [ +  + ]:          3 :                 if (sgl_in && !sgl_out) {
   17056         [ +  - ]:          1 :                         if (!(dev_info.feature_flags &
   17057                 :            :                                         RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
   17058                 :            :                                 return TEST_SKIPPED;
   17059         [ -  + ]:          2 :                 } else if (!sgl_in && sgl_out) {
   17060         [ #  # ]:          0 :                         if (!(dev_info.feature_flags &
   17061                 :            :                                         RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
   17062                 :            :                                 return TEST_SKIPPED;
   17063         [ +  - ]:          2 :                 } else if (sgl_in && sgl_out) {
   17064         [ -  + ]:          2 :                         if (!(dev_info.feature_flags &
   17065                 :            :                                         RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
   17066                 :            :                                 return TEST_SKIPPED;
   17067                 :            :                 }
   17068                 :            :         }
   17069                 :            : 
   17070                 :          1 :         if (fragsz > tdata->plaintext.len)
   17071                 :            :                 fragsz = tdata->plaintext.len;
   17072                 :            : 
   17073                 :          1 :         uint16_t plaintext_len = fragsz;
   17074         [ +  - ]:          1 :         uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
   17075                 :            : 
   17076         [ -  + ]:          1 :         if (fragsz_oop > tdata->plaintext.len)
   17077                 :          0 :                 frag_size_oop = tdata->plaintext.len;
   17078                 :            : 
   17079                 :            :         int ecx = 0;
   17080                 :            :         void *digest_mem = NULL;
   17081                 :            : 
   17082                 :          1 :         uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
   17083                 :            : 
   17084         [ +  - ]:          1 :         if (tdata->plaintext.len % fragsz != 0) {
   17085         [ +  - ]:          1 :                 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
   17086                 :            :                         return 1;
   17087                 :            :         }       else {
   17088         [ #  # ]:          0 :                 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
   17089                 :            :                         return 1;
   17090                 :            :         }
   17091                 :            : 
   17092                 :            :         /*
   17093                 :            :          * For out-of-place we need to alloc another mbuf
   17094                 :            :          */
   17095         [ +  - ]:          1 :         if (oop) {
   17096                 :          1 :                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   17097                 :            :                 rte_pktmbuf_append(ut_params->obuf,
   17098                 :          1 :                                 frag_size_oop + prepend_len);
   17099                 :          1 :                 buf_oop = ut_params->obuf;
   17100                 :            :         }
   17101                 :            : 
   17102                 :            :         /* Create AEAD session */
   17103                 :          1 :         retval = create_aead_session(ts_params->valid_devs[0],
   17104                 :          1 :                         tdata->algo,
   17105                 :            :                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
   17106                 :          1 :                         tdata->key.data, tdata->key.len,
   17107                 :          1 :                         tdata->aad.len, tdata->auth_tag.len,
   17108                 :          1 :                         tdata->iv.len);
   17109         [ +  - ]:          1 :         if (retval < 0)
   17110                 :            :                 return retval;
   17111                 :            : 
   17112                 :          1 :         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   17113                 :            : 
   17114                 :            :         /* clear mbuf payload */
   17115                 :          1 :         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   17116                 :            :                         rte_pktmbuf_tailroom(ut_params->ibuf));
   17117                 :            : 
   17118                 :          1 :         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   17119                 :            :                         plaintext_len);
   17120                 :            : 
   17121                 :          1 :         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
   17122                 :            : 
   17123                 :            :         trn_data += plaintext_len;
   17124                 :            : 
   17125                 :          1 :         buf = ut_params->ibuf;
   17126                 :            : 
   17127                 :            :         /*
   17128                 :            :          * Loop until no more fragments
   17129                 :            :          */
   17130                 :            : 
   17131         [ +  + ]:          6 :         while (trn_data < tdata->plaintext.len) {
   17132                 :          5 :                 ++segs;
   17133                 :          5 :                 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
   17134                 :          5 :                                 (tdata->plaintext.len - trn_data) : fragsz;
   17135                 :            : 
   17136                 :          5 :                 to_trn_tbl[ecx++] = to_trn;
   17137                 :            : 
   17138         [ -  + ]:          5 :                 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
   17139                 :            :                 buf = buf->next;
   17140                 :            : 
   17141         [ -  + ]:          5 :                 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
   17142                 :            :                                 rte_pktmbuf_tailroom(buf));
   17143                 :            : 
   17144                 :            :                 /* OOP */
   17145         [ -  + ]:          5 :                 if (oop && !fragsz_oop) {
   17146                 :          0 :                         buf_last_oop = buf_oop->next =
   17147                 :          0 :                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
   17148                 :            :                         buf_oop = buf_oop->next;
   17149                 :          0 :                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
   17150                 :            :                                         0, rte_pktmbuf_tailroom(buf_oop));
   17151                 :          0 :                         rte_pktmbuf_append(buf_oop, to_trn);
   17152                 :            :                 }
   17153                 :            : 
   17154                 :          5 :                 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
   17155                 :            :                                 to_trn);
   17156                 :            : 
   17157         [ +  + ]:          5 :                 memcpy(plaintext, tdata->plaintext.data + trn_data,
   17158                 :            :                                 to_trn);
   17159                 :          5 :                 trn_data += to_trn;
   17160         [ +  + ]:          5 :                 if (trn_data  == tdata->plaintext.len) {
   17161         [ +  - ]:          1 :                         if (oop) {
   17162         [ -  + ]:          1 :                                 if (!fragsz_oop)
   17163                 :          0 :                                         digest_mem = rte_pktmbuf_append(buf_oop,
   17164                 :          0 :                                                 tdata->auth_tag.len);
   17165                 :            :                         } else
   17166                 :          0 :                                 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
   17167                 :          0 :                                         tdata->auth_tag.len);
   17168                 :            :                 }
   17169                 :            :         }
   17170                 :            : 
   17171                 :            :         uint64_t digest_phys = 0;
   17172                 :            : 
   17173                 :          1 :         ut_params->ibuf->nb_segs = segs;
   17174                 :            : 
   17175                 :            :         segs = 1;
   17176         [ +  - ]:          1 :         if (fragsz_oop && oop) {
   17177                 :            :                 to_trn = 0;
   17178                 :            :                 ecx = 0;
   17179                 :            : 
   17180         [ +  - ]:          1 :                 if (frag_size_oop == tdata->plaintext.len) {
   17181                 :          1 :                         digest_mem = rte_pktmbuf_append(ut_params->obuf,
   17182                 :          1 :                                 tdata->auth_tag.len);
   17183                 :            : 
   17184                 :          1 :                         digest_phys = rte_pktmbuf_iova_offset(
   17185                 :            :                                         ut_params->obuf,
   17186                 :            :                                         tdata->plaintext.len + prepend_len);
   17187                 :            :                 }
   17188                 :            : 
   17189                 :            :                 trn_data = frag_size_oop;
   17190         [ -  + ]:          1 :                 while (trn_data < tdata->plaintext.len) {
   17191                 :          0 :                         ++segs;
   17192                 :          0 :                         to_trn =
   17193                 :          0 :                                 (tdata->plaintext.len - trn_data <
   17194                 :            :                                                 frag_size_oop) ?
   17195                 :          0 :                                 (tdata->plaintext.len - trn_data) :
   17196                 :            :                                                 frag_size_oop;
   17197                 :            : 
   17198                 :          0 :                         to_trn_tbl[ecx++] = to_trn;
   17199                 :            : 
   17200                 :          0 :                         buf_last_oop = buf_oop->next =
   17201                 :          0 :                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
   17202                 :            :                         buf_oop = buf_oop->next;
   17203                 :          0 :                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
   17204                 :            :                                         0, rte_pktmbuf_tailroom(buf_oop));
   17205                 :          0 :                         rte_pktmbuf_append(buf_oop, to_trn);
   17206                 :            : 
   17207                 :          0 :                         trn_data += to_trn;
   17208                 :            : 
   17209         [ #  # ]:          0 :                         if (trn_data  == tdata->plaintext.len) {
   17210                 :          0 :                                 digest_mem = rte_pktmbuf_append(buf_oop,
   17211                 :          0 :                                         tdata->auth_tag.len);
   17212                 :            :                         }
   17213                 :            :                 }
   17214                 :            : 
   17215                 :          1 :                 ut_params->obuf->nb_segs = segs;
   17216                 :            :         }
   17217                 :            : 
   17218                 :            :         /*
   17219                 :            :          * Place digest at the end of the last buffer
   17220                 :            :          */
   17221         [ -  + ]:          1 :         if (!digest_phys)
   17222                 :          0 :                 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
   17223         [ -  + ]:          1 :         if (oop && buf_last_oop)
   17224                 :          0 :                 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
   17225                 :            : 
   17226         [ -  + ]:          1 :         if (!digest_mem && !oop) {
   17227                 :          0 :                 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
   17228                 :          0 :                                 + tdata->auth_tag.len);
   17229                 :          0 :                 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
   17230                 :            :                                 tdata->plaintext.len);
   17231                 :            :         }
   17232                 :            : 
   17233                 :            :         /* Create AEAD operation */
   17234                 :          1 :         retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
   17235                 :            :                         tdata, digest_mem, digest_phys);
   17236                 :            : 
   17237         [ +  - ]:          1 :         if (retval < 0)
   17238                 :            :                 return retval;
   17239                 :            : 
   17240         [ +  - ]:          1 :         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
   17241                 :            : 
   17242                 :          1 :         ut_params->op->sym->m_src = ut_params->ibuf;
   17243         [ +  - ]:          1 :         if (oop)
   17244                 :          1 :                 ut_params->op->sym->m_dst = ut_params->obuf;
   17245                 :            : 
   17246                 :            :         /* Process crypto operation */
   17247         [ -  + ]:          1 :         if (oop == IN_PLACE &&
   17248         [ #  # ]:          0 :                         gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
   17249                 :          0 :                 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
   17250         [ -  + ]:          1 :         else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
   17251                 :          0 :                 retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
   17252                 :            :                                                0);
   17253         [ #  # ]:          0 :                 if (retval != TEST_SUCCESS)
   17254                 :            :                         return retval;
   17255                 :            :         } else
   17256         [ -  + ]:          1 :                 TEST_ASSERT_NOT_NULL(
   17257                 :            :                         process_crypto_request(ts_params->valid_devs[0],
   17258                 :            :                         ut_params->op), "failed to process sym crypto op");
   17259                 :            : 
   17260         [ -  + ]:          1 :         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
   17261                 :            :                         "crypto op processing failed");
   17262                 :            : 
   17263                 :            : 
   17264                 :          1 :         ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
   17265                 :            :                         uint8_t *, prepend_len);
   17266         [ +  - ]:          1 :         if (oop) {
   17267                 :          1 :                 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
   17268                 :            :                                 uint8_t *, prepend_len);
   17269                 :            :         }
   17270                 :            : 
   17271         [ +  - ]:          1 :         if (fragsz_oop)
   17272                 :            :                 fragsz = fragsz_oop;
   17273                 :            : 
   17274         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   17275                 :            :                         ciphertext,
   17276                 :            :                         tdata->ciphertext.data,
   17277                 :            :                         fragsz,
   17278                 :            :                         "Ciphertext data not as expected");
   17279                 :            : 
   17280                 :          1 :         buf = ut_params->op->sym->m_src->next;
   17281         [ +  - ]:          1 :         if (oop)
   17282                 :          1 :                 buf = ut_params->op->sym->m_dst->next;
   17283                 :            : 
   17284                 :            :         unsigned int off = fragsz;
   17285                 :            : 
   17286                 :            :         ecx = 0;
   17287         [ -  + ]:          1 :         while (buf) {
   17288                 :          0 :                 ciphertext = rte_pktmbuf_mtod(buf,
   17289                 :            :                                 uint8_t *);
   17290                 :            : 
   17291         [ #  # ]:          0 :                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
   17292                 :            :                                 ciphertext,
   17293                 :            :                                 tdata->ciphertext.data + off,
   17294                 :            :                                 to_trn_tbl[ecx],
   17295                 :            :                                 "Ciphertext data not as expected");
   17296                 :            : 
   17297                 :          0 :                 off += to_trn_tbl[ecx++];
   17298                 :          0 :                 buf = buf->next;
   17299                 :            :         }
   17300                 :            : 
   17301                 :            :         auth_tag = digest_mem;
   17302         [ -  + ]:          1 :         TEST_ASSERT_BUFFERS_ARE_EQUAL(
   17303                 :            :                         auth_tag,
   17304                 :            :                         tdata->auth_tag.data,
   17305                 :            :                         tdata->auth_tag.len,
   17306                 :            :                         "Generated auth tag not as expected");
   17307                 :            : 
   17308                 :            :         return 0;
   17309                 :            : }
   17310                 :            : 
   17311                 :            : static int
   17312                 :          1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
   17313                 :            : {
   17314                 :          1 :         return test_authenticated_encryption_SGL(
   17315                 :            :                         &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
   17316                 :            : }
   17317                 :            : 
   17318                 :            : static int
   17319                 :          1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
   17320                 :            : {
   17321                 :          1 :         return test_authenticated_encryption_SGL(
   17322                 :            :                         &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
   17323                 :            : }
   17324                 :            : 
   17325                 :            : static int
   17326                 :          1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
   17327                 :            : {
   17328                 :          1 :         return test_authenticated_encryption_SGL(
   17329                 :            :                         &gcm_test_case_8, OUT_OF_PLACE, 400,
   17330                 :            :                         gcm_test_case_8.plaintext.len);
   17331                 :            : }
   17332                 :            : 
   17333                 :            : static int
   17334                 :          1 : test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
   17335                 :            : {
   17336                 :            :         /* This test is not for OPENSSL PMD */
   17337         [ -  + ]:          1 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   17338                 :            :                         RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
   17339                 :            :                 return TEST_SKIPPED;
   17340                 :            : 
   17341                 :          0 :         return test_authenticated_encryption_SGL(
   17342                 :            :                         &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
   17343                 :            : }
   17344                 :            : 
   17345                 :            : static int
   17346                 :            : test_authentication_verify_fail_when_data_corrupted(
   17347                 :            :                 struct crypto_testsuite_params *ts_params,
   17348                 :            :                 struct crypto_unittest_params *ut_params,
   17349                 :            :                 const struct test_crypto_vector *reference)
   17350                 :            : {
   17351                 :          1 :         return test_authentication_verify_fail_when_data_corruption(
   17352                 :            :                         ts_params, ut_params, reference, 1);
   17353                 :            : }
   17354                 :            : 
   17355                 :            : static int
   17356                 :            : test_authentication_verify_fail_when_tag_corrupted(
   17357                 :            :                 struct crypto_testsuite_params *ts_params,
   17358                 :            :                 struct crypto_unittest_params *ut_params,
   17359                 :            :                 const struct test_crypto_vector *reference)
   17360                 :            : {
   17361                 :          1 :         return test_authentication_verify_fail_when_data_corruption(
   17362                 :            :                         ts_params, ut_params, reference, 0);
   17363                 :            : }
   17364                 :            : 
   17365                 :            : static int
   17366                 :            : test_authentication_verify_GMAC_fail_when_data_corrupted(
   17367                 :            :                 struct crypto_testsuite_params *ts_params,
   17368                 :            :                 struct crypto_unittest_params *ut_params,
   17369                 :            :                 const struct test_crypto_vector *reference)
   17370                 :            : {
   17371                 :          1 :         return test_authentication_verify_GMAC_fail_when_corruption(
   17372                 :            :                         ts_params, ut_params, reference, 1);
   17373                 :            : }
   17374                 :            : 
   17375                 :            : static int
   17376                 :            : test_authentication_verify_GMAC_fail_when_tag_corrupted(
   17377                 :            :                 struct crypto_testsuite_params *ts_params,
   17378                 :            :                 struct crypto_unittest_params *ut_params,
   17379                 :            :                 const struct test_crypto_vector *reference)
   17380                 :            : {
   17381                 :          1 :         return test_authentication_verify_GMAC_fail_when_corruption(
   17382                 :            :                         ts_params, ut_params, reference, 0);
   17383                 :            : }
   17384                 :            : 
   17385                 :            : static int
   17386                 :            : test_authenticated_decryption_fail_when_data_corrupted(
   17387                 :            :                 struct crypto_testsuite_params *ts_params,
   17388                 :            :                 struct crypto_unittest_params *ut_params,
   17389                 :            :                 const struct test_crypto_vector *reference)
   17390                 :            : {
   17391                 :          1 :         return test_authenticated_decryption_fail_when_corruption(
   17392                 :            :                         ts_params, ut_params, reference, 1);
   17393                 :            : }
   17394                 :            : 
   17395                 :            : static int
   17396                 :            : test_authenticated_decryption_fail_when_tag_corrupted(
   17397                 :            :                 struct crypto_testsuite_params *ts_params,
   17398                 :            :                 struct crypto_unittest_params *ut_params,
   17399                 :            :                 const struct test_crypto_vector *reference)
   17400                 :            : {
   17401                 :          1 :         return test_authenticated_decryption_fail_when_corruption(
   17402                 :            :                         ts_params, ut_params, reference, 0);
   17403                 :            : }
   17404                 :            : 
   17405                 :            : static int
   17406                 :          1 : authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
   17407                 :            : {
   17408                 :          1 :         return test_authentication_verify_fail_when_data_corrupted(
   17409                 :            :                         &testsuite_params, &unittest_params,
   17410                 :            :                         &hmac_sha1_test_crypto_vector);
   17411                 :            : }
   17412                 :            : 
   17413                 :            : static int
   17414                 :          1 : authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
   17415                 :            : {
   17416                 :          1 :         return test_authentication_verify_fail_when_tag_corrupted(
   17417                 :            :                         &testsuite_params, &unittest_params,
   17418                 :            :                         &hmac_sha1_test_crypto_vector);
   17419                 :            : }
   17420                 :            : 
   17421                 :            : static int
   17422                 :          1 : authentication_verify_AES128_GMAC_fail_data_corrupt(void)
   17423                 :            : {
   17424                 :          1 :         return test_authentication_verify_GMAC_fail_when_data_corrupted(
   17425                 :            :                         &testsuite_params, &unittest_params,
   17426                 :            :                         &aes128_gmac_test_vector);
   17427                 :            : }
   17428                 :            : 
   17429                 :            : static int
   17430                 :          1 : authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
   17431                 :            : {
   17432                 :          1 :         return test_authentication_verify_GMAC_fail_when_tag_corrupted(
   17433                 :            :                         &testsuite_params, &unittest_params,
   17434                 :            :                         &aes128_gmac_test_vector);
   17435                 :            : }
   17436                 :            : 
   17437                 :            : static int
   17438                 :          1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
   17439                 :            : {
   17440                 :          1 :         return test_authenticated_decryption_fail_when_data_corrupted(
   17441                 :            :                         &testsuite_params,
   17442                 :            :                         &unittest_params,
   17443                 :            :                         &aes128cbc_hmac_sha1_test_vector);
   17444                 :            : }
   17445                 :            : 
   17446                 :            : static int
   17447                 :          1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
   17448                 :            : {
   17449                 :          1 :         return test_authenticated_decryption_fail_when_tag_corrupted(
   17450                 :            :                         &testsuite_params,
   17451                 :            :                         &unittest_params,
   17452                 :            :                         &aes128cbc_hmac_sha1_test_vector);
   17453                 :            : }
   17454                 :            : 
   17455                 :            : static int
   17456                 :          1 : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
   17457                 :            : {
   17458                 :          1 :         return test_authenticated_encrypt_with_esn(
   17459                 :            :                         &testsuite_params,
   17460                 :            :                         &unittest_params,
   17461                 :            :                         &aes128cbc_hmac_sha1_aad_test_vector);
   17462                 :            : }
   17463                 :            : 
   17464                 :            : static int
   17465                 :          1 : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
   17466                 :            : {
   17467                 :          1 :         return test_authenticated_decrypt_with_esn(
   17468                 :            :                         &testsuite_params,
   17469                 :            :                         &unittest_params,
   17470                 :            :                         &aes128cbc_hmac_sha1_aad_test_vector);
   17471                 :            : }
   17472                 :            : 
   17473                 :            : static int
   17474                 :          0 : test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
   17475                 :            : {
   17476                 :          0 :         return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
   17477                 :            : }
   17478                 :            : 
   17479                 :            : static int
   17480                 :          0 : test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
   17481                 :            : {
   17482                 :          0 :         return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
   17483                 :            : }
   17484                 :            : 
   17485                 :            : static int
   17486                 :          0 : test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
   17487                 :            : {
   17488                 :          0 :         return test_authenticated_encryption_SGL(
   17489                 :            :                 &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
   17490                 :            :                 chacha20_poly1305_case_2.plaintext.len);
   17491                 :            : }
   17492                 :            : 
   17493                 :            : #ifdef RTE_CRYPTO_SCHEDULER
   17494                 :            : 
   17495                 :            : /* global AESNI worker IDs for the scheduler test */
   17496                 :            : uint8_t aesni_ids[2];
   17497                 :            : 
   17498                 :            : static int
   17499                 :          0 : scheduler_testsuite_setup(void)
   17500                 :            : {
   17501                 :            :         uint32_t i = 0;
   17502                 :            :         int32_t nb_devs, ret;
   17503                 :          0 :         char vdev_args[VDEV_ARGS_SIZE] = {""};
   17504                 :          0 :         char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
   17505                 :            :                 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
   17506                 :            :         uint16_t worker_core_count = 0;
   17507                 :            :         uint16_t socket_id = 0;
   17508                 :            : 
   17509         [ #  # ]:          0 :         if (gbl_driver_id == rte_cryptodev_driver_id_get(
   17510                 :            :                         RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
   17511                 :            : 
   17512                 :            :                 /* Identify the Worker Cores
   17513                 :            :                  * Use 2 worker cores for the device args
   17514                 :            :                  */
   17515         [ #  # ]:          0 :                 RTE_LCORE_FOREACH_WORKER(i) {
   17516         [ #  # ]:          0 :                         if (worker_core_count > 1)
   17517                 :            :                                 break;
   17518                 :            :                         snprintf(vdev_args, sizeof(vdev_args),
   17519                 :            :                                         "%s%d", temp_str, i);
   17520                 :            :                         strcpy(temp_str, vdev_args);
   17521                 :          0 :                         strlcat(temp_str, ";", sizeof(temp_str));
   17522                 :          0 :                         worker_core_count++;
   17523                 :          0 :                         socket_id = rte_lcore_to_socket_id(i);
   17524                 :            :                 }
   17525         [ #  # ]:          0 :                 if (worker_core_count != 2) {
   17526                 :          0 :                         RTE_LOG(ERR, USER1,
   17527                 :            :                                 "Cryptodev scheduler test require at least "
   17528                 :            :                                 "two worker cores to run. "
   17529                 :            :                                 "Please use the correct coremask.\n");
   17530                 :          0 :                         return TEST_FAILED;
   17531                 :            :                 }
   17532                 :            :                 strcpy(temp_str, vdev_args);
   17533                 :          0 :                 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
   17534                 :            :                                 temp_str, socket_id);
   17535                 :          0 :                 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
   17536                 :          0 :                 nb_devs = rte_cryptodev_device_count_by_driver(
   17537                 :          0 :                                 rte_cryptodev_driver_id_get(
   17538                 :            :                                 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
   17539         [ #  # ]:          0 :                 if (nb_devs < 1) {
   17540                 :          0 :                         ret = rte_vdev_init(
   17541                 :            :                                 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
   17542                 :            :                                         vdev_args);
   17543         [ #  # ]:          0 :                         TEST_ASSERT(ret == 0,
   17544                 :            :                                 "Failed to create instance %u of pmd : %s",
   17545                 :            :                                 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
   17546                 :            :                 }
   17547                 :            :         }
   17548                 :          0 :         return testsuite_setup();
   17549                 :            : }
   17550                 :            : 
   17551                 :            : static int
   17552                 :          0 : test_scheduler_attach_worker_op(void)
   17553                 :            : {
   17554                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   17555                 :          0 :         uint8_t sched_id = ts_params->valid_devs[0];
   17556                 :            :         uint32_t i, nb_devs_attached = 0;
   17557                 :            :         int ret;
   17558                 :            :         char vdev_name[32];
   17559                 :          0 :         unsigned int count = rte_cryptodev_count();
   17560                 :            : 
   17561                 :            :         /* create 2 AESNI_MB vdevs on top of existing devices */
   17562         [ #  # ]:          0 :         for (i = count; i < count + 2; i++) {
   17563                 :            :                 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
   17564                 :            :                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
   17565                 :            :                                 i);
   17566                 :          0 :                 ret = rte_vdev_init(vdev_name, NULL);
   17567                 :            : 
   17568         [ #  # ]:          0 :                 TEST_ASSERT(ret == 0,
   17569                 :            :                         "Failed to create instance %u of"
   17570                 :            :                         " pmd : %s",
   17571                 :            :                         i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
   17572                 :            : 
   17573                 :            :                 if (ret < 0) {
   17574                 :            :                         RTE_LOG(ERR, USER1,
   17575                 :            :                                 "Failed to create 2 AESNI MB PMDs.\n");
   17576                 :            :                         return TEST_SKIPPED;
   17577                 :            :                 }
   17578                 :            :         }
   17579                 :            : 
   17580                 :            :         /* attach 2 AESNI_MB cdevs */
   17581         [ #  # ]:          0 :         for (i = count; i < count + 2; i++) {
   17582                 :            :                 struct rte_cryptodev_info info;
   17583                 :            :                 unsigned int session_size;
   17584                 :            : 
   17585                 :          0 :                 rte_cryptodev_info_get(i, &info);
   17586         [ #  # ]:          0 :                 if (info.driver_id != rte_cryptodev_driver_id_get(
   17587                 :            :                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
   17588                 :          0 :                         continue;
   17589                 :            : 
   17590                 :          0 :                 session_size = rte_cryptodev_sym_get_private_session_size(i);
   17591                 :            :                 /*
   17592                 :            :                  * Create the session mempool again, since now there are new devices
   17593                 :            :                  * to use the mempool.
   17594                 :            :                  */
   17595         [ #  # ]:          0 :                 if (ts_params->session_mpool) {
   17596                 :          0 :                         rte_mempool_free(ts_params->session_mpool);
   17597                 :          0 :                         ts_params->session_mpool = NULL;
   17598                 :            :                 }
   17599                 :            : 
   17600         [ #  # ]:          0 :                 if (info.sym.max_nb_sessions != 0 &&
   17601                 :            :                                 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
   17602                 :          0 :                         RTE_LOG(ERR, USER1,
   17603                 :            :                                         "Device does not support "
   17604                 :            :                                         "at least %u sessions\n",
   17605                 :            :                                         MAX_NB_SESSIONS);
   17606                 :          0 :                         return TEST_FAILED;
   17607                 :            :                 }
   17608                 :            :                 /*
   17609                 :            :                  * Create mempool with maximum number of sessions,
   17610                 :            :                  * to include the session headers
   17611                 :            :                  */
   17612         [ #  # ]:          0 :                 if (ts_params->session_mpool == NULL) {
   17613                 :          0 :                         ts_params->session_mpool =
   17614                 :          0 :                                 rte_cryptodev_sym_session_pool_create(
   17615                 :            :                                                 "test_sess_mp",
   17616                 :            :                                                 MAX_NB_SESSIONS, session_size,
   17617                 :            :                                                 0, 0, SOCKET_ID_ANY);
   17618         [ #  # ]:          0 :                         TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
   17619                 :            :                                         "session mempool allocation failed");
   17620                 :            :                 }
   17621                 :            : 
   17622                 :          0 :                 ts_params->qp_conf.mp_session = ts_params->session_mpool;
   17623                 :            : 
   17624                 :          0 :                 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
   17625                 :            :                                 (uint8_t)i);
   17626                 :            : 
   17627         [ #  # ]:          0 :                 TEST_ASSERT(ret == 0,
   17628                 :            :                         "Failed to attach device %u of pmd : %s", i,
   17629                 :            :                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
   17630                 :            : 
   17631                 :          0 :                 aesni_ids[nb_devs_attached] = (uint8_t)i;
   17632                 :            : 
   17633                 :          0 :                 nb_devs_attached++;
   17634                 :            :         }
   17635                 :            : 
   17636                 :            :         return 0;
   17637                 :            : }
   17638                 :            : 
   17639                 :            : static int
   17640                 :          0 : test_scheduler_detach_worker_op(void)
   17641                 :            : {
   17642                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   17643                 :          0 :         uint8_t sched_id = ts_params->valid_devs[0];
   17644                 :            :         uint32_t i;
   17645                 :            :         int ret;
   17646                 :            : 
   17647         [ #  # ]:          0 :         for (i = 0; i < 2; i++) {
   17648                 :          0 :                 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
   17649                 :          0 :                                 aesni_ids[i]);
   17650         [ #  # ]:          0 :                 TEST_ASSERT(ret == 0,
   17651                 :            :                         "Failed to detach device %u", aesni_ids[i]);
   17652                 :            :         }
   17653                 :            : 
   17654                 :            :         return 0;
   17655                 :            : }
   17656                 :            : 
   17657                 :            : static int
   17658                 :            : test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
   17659                 :            : {
   17660                 :            :         struct crypto_testsuite_params *ts_params = &testsuite_params;
   17661                 :          0 :         uint8_t sched_id = ts_params->valid_devs[0];
   17662                 :            :         /* set mode */
   17663                 :          0 :         return rte_cryptodev_scheduler_mode_set(sched_id,
   17664                 :            :                 scheduler_mode);
   17665                 :            : }
   17666                 :            : 
   17667                 :            : static int
   17668                 :          0 : test_scheduler_mode_roundrobin_op(void)
   17669                 :            : {
   17670         [ #  # ]:          0 :         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
   17671                 :            :                         0, "Failed to set roundrobin mode");
   17672                 :            :         return 0;
   17673                 :            : 
   17674                 :            : }
   17675                 :            : 
   17676                 :            : static int
   17677                 :          0 : test_scheduler_mode_multicore_op(void)
   17678                 :            : {
   17679         [ #  # ]:          0 :         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
   17680                 :            :                         0, "Failed to set multicore mode");
   17681                 :            : 
   17682                 :            :         return 0;
   17683                 :            : }
   17684                 :            : 
   17685                 :            : static int
   17686                 :          0 : test_scheduler_mode_failover_op(void)
   17687                 :            : {
   17688         [ #  # ]:          0 :         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
   17689                 :            :                         0, "Failed to set failover mode");
   17690                 :            : 
   17691                 :            :         return 0;
   17692                 :            : }
   17693                 :            : 
   17694                 :            : static int
   17695                 :          0 : test_scheduler_mode_pkt_size_distr_op(void)
   17696                 :            : {
   17697         [ #  # ]:          0 :         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
   17698                 :            :                         0, "Failed to set pktsize mode");
   17699                 :            : 
   17700                 :            :         return 0;
   17701                 :            : }
   17702                 :            : 
   17703                 :            : static int
   17704                 :          0 : scheduler_multicore_testsuite_setup(void)
   17705                 :            : {
   17706         [ #  # ]:          0 :         if (test_scheduler_attach_worker_op() < 0)
   17707                 :            :                 return TEST_SKIPPED;
   17708         [ #  # ]:          0 :         if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
   17709                 :          0 :                 return TEST_SKIPPED;
   17710                 :            :         return 0;
   17711                 :            : }
   17712                 :            : 
   17713                 :            : static int
   17714                 :          0 : scheduler_roundrobin_testsuite_setup(void)
   17715                 :            : {
   17716         [ #  # ]:          0 :         if (test_scheduler_attach_worker_op() < 0)
   17717                 :            :                 return TEST_SKIPPED;
   17718         [ #  # ]:          0 :         if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
   17719                 :          0 :                 return TEST_SKIPPED;
   17720                 :            :         return 0;
   17721                 :            : }
   17722                 :            : 
   17723                 :            : static int
   17724                 :          0 : scheduler_failover_testsuite_setup(void)
   17725                 :            : {
   17726         [ #  # ]:          0 :         if (test_scheduler_attach_worker_op() < 0)
   17727                 :            :                 return TEST_SKIPPED;
   17728         [ #  # ]:          0 :         if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
   17729                 :          0 :                 return TEST_SKIPPED;
   17730                 :            :         return 0;
   17731                 :            : }
   17732                 :            : 
   17733                 :            : static int
   17734                 :          0 : scheduler_pkt_size_distr_testsuite_setup(void)
   17735                 :            : {
   17736         [ #  # ]:          0 :         if (test_scheduler_attach_worker_op() < 0)
   17737                 :            :                 return TEST_SKIPPED;
   17738         [ #  # ]:          0 :         if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
   17739                 :          0 :                 return TEST_SKIPPED;
   17740                 :            :         return 0;
   17741                 :            : }
   17742                 :            : 
   17743                 :            : static void
   17744                 :          0 : scheduler_mode_testsuite_teardown(void)
   17745                 :            : {
   17746                 :          0 :         test_scheduler_detach_worker_op();
   17747                 :          0 : }
   17748                 :            : 
   17749                 :            : #endif /* RTE_CRYPTO_SCHEDULER */
   17750                 :            : 
   17751                 :            : static struct unit_test_suite end_testsuite = {
   17752                 :            :         .suite_name = NULL,
   17753                 :            :         .setup = NULL,
   17754                 :            :         .teardown = NULL,
   17755                 :            :         .unit_test_suites = NULL
   17756                 :            : };
   17757                 :            : 
   17758                 :            : #ifdef RTE_LIB_SECURITY
   17759                 :            : static struct unit_test_suite ipsec_proto_testsuite  = {
   17760                 :            :         .suite_name = "IPsec Proto Unit Test Suite",
   17761                 :            :         .setup = ipsec_proto_testsuite_setup,
   17762                 :            :         .unit_test_cases = {
   17763                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17764                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
   17765                 :            :                         ut_setup_security, ut_teardown,
   17766                 :            :                         test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
   17767                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17768                 :            :                         "Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
   17769                 :            :                         ut_setup_security, ut_teardown,
   17770                 :            :                         test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
   17771                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17772                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
   17773                 :            :                         ut_setup_security, ut_teardown,
   17774                 :            :                         test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
   17775                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17776                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
   17777                 :            :                         ut_setup_security, ut_teardown,
   17778                 :            :                         test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
   17779                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17780                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
   17781                 :            :                         ut_setup_security, ut_teardown,
   17782                 :            :                         test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
   17783                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17784                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
   17785                 :            :                         ut_setup_security, ut_teardown,
   17786                 :            :                         test_ipsec_proto_known_vec,
   17787                 :            :                         &pkt_aes_128_cbc_md5),
   17788                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17789                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
   17790                 :            :                         ut_setup_security, ut_teardown,
   17791                 :            :                         test_ipsec_proto_known_vec,
   17792                 :            :                         &pkt_aes_128_cbc_hmac_sha256),
   17793                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17794                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
   17795                 :            :                         ut_setup_security, ut_teardown,
   17796                 :            :                         test_ipsec_proto_known_vec,
   17797                 :            :                         &pkt_aes_128_cbc_hmac_sha384),
   17798                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17799                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
   17800                 :            :                         ut_setup_security, ut_teardown,
   17801                 :            :                         test_ipsec_proto_known_vec,
   17802                 :            :                         &pkt_aes_128_cbc_hmac_sha512),
   17803                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17804                 :            :                         "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
   17805                 :            :                         ut_setup_security, ut_teardown,
   17806                 :            :                         test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
   17807                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17808                 :            :                         "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
   17809                 :            :                         ut_setup_security, ut_teardown,
   17810                 :            :                         test_ipsec_proto_known_vec,
   17811                 :            :                         &pkt_aes_128_cbc_hmac_sha256_v6),
   17812                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17813                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
   17814                 :            :                         ut_setup_security, ut_teardown,
   17815                 :            :                         test_ipsec_proto_known_vec,
   17816                 :            :                         &pkt_null_aes_xcbc),
   17817                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17818                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
   17819                 :            :                         ut_setup_security, ut_teardown,
   17820                 :            :                         test_ipsec_proto_known_vec,
   17821                 :            :                         &pkt_des_cbc_hmac_sha256),
   17822                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17823                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
   17824                 :            :                         ut_setup_security, ut_teardown,
   17825                 :            :                         test_ipsec_proto_known_vec,
   17826                 :            :                         &pkt_des_cbc_hmac_sha384),
   17827                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17828                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
   17829                 :            :                         ut_setup_security, ut_teardown,
   17830                 :            :                         test_ipsec_proto_known_vec,
   17831                 :            :                         &pkt_des_cbc_hmac_sha512),
   17832                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17833                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
   17834                 :            :                         ut_setup_security, ut_teardown,
   17835                 :            :                         test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
   17836                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17837                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
   17838                 :            :                         ut_setup_security, ut_teardown,
   17839                 :            :                         test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
   17840                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17841                 :            :                         "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
   17842                 :            :                         ut_setup_security, ut_teardown,
   17843                 :            :                         test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
   17844                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17845                 :            :                         "Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
   17846                 :            :                         ut_setup_security, ut_teardown,
   17847                 :            :                         test_ipsec_proto_known_vec,
   17848                 :            :                         &pkt_des_cbc_hmac_sha256_v6),
   17849                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17850                 :            :                         "Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
   17851                 :            :                         ut_setup_security, ut_teardown,
   17852                 :            :                         test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
   17853                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17854                 :            :                         "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
   17855                 :            :                         ut_setup_security, ut_teardown,
   17856                 :            :                         test_ipsec_proto_known_vec,
   17857                 :            :                         &pkt_ah_tunnel_sha256),
   17858                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17859                 :            :                         "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
   17860                 :            :                         ut_setup_security, ut_teardown,
   17861                 :            :                         test_ipsec_proto_known_vec,
   17862                 :            :                         &pkt_ah_transport_sha256),
   17863                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17864                 :            :                         "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
   17865                 :            :                         ut_setup_security, ut_teardown,
   17866                 :            :                         test_ipsec_proto_known_vec,
   17867                 :            :                         &pkt_ah_ipv4_aes_gmac_128),
   17868                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17869                 :            :                         "Outbound fragmented packet",
   17870                 :            :                         ut_setup_security, ut_teardown,
   17871                 :            :                         test_ipsec_proto_known_vec_fragmented,
   17872                 :            :                         &pkt_aes_128_gcm_frag),
   17873                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17874                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
   17875                 :            :                         ut_setup_security, ut_teardown,
   17876                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
   17877                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17878                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
   17879                 :            :                         ut_setup_security, ut_teardown,
   17880                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
   17881                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17882                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
   17883                 :            :                         ut_setup_security, ut_teardown,
   17884                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
   17885                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17886                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
   17887                 :            :                         ut_setup_security, ut_teardown,
   17888                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
   17889                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17890                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
   17891                 :            :                         ut_setup_security, ut_teardown,
   17892                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
   17893                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17894                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
   17895                 :            :                         ut_setup_security, ut_teardown,
   17896                 :            :                         test_ipsec_proto_known_vec_inb,
   17897                 :            :                         &pkt_aes_128_cbc_md5),
   17898                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17899                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
   17900                 :            :                         ut_setup_security, ut_teardown,
   17901                 :            :                         test_ipsec_proto_known_vec_inb,
   17902                 :            :                         &pkt_aes_128_cbc_hmac_sha256),
   17903                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17904                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
   17905                 :            :                         ut_setup_security, ut_teardown,
   17906                 :            :                         test_ipsec_proto_known_vec_inb,
   17907                 :            :                         &pkt_aes_128_cbc_hmac_sha384),
   17908                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17909                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
   17910                 :            :                         ut_setup_security, ut_teardown,
   17911                 :            :                         test_ipsec_proto_known_vec_inb,
   17912                 :            :                         &pkt_aes_128_cbc_hmac_sha512),
   17913                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17914                 :            :                         "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
   17915                 :            :                         ut_setup_security, ut_teardown,
   17916                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
   17917                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17918                 :            :                         "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
   17919                 :            :                         ut_setup_security, ut_teardown,
   17920                 :            :                         test_ipsec_proto_known_vec_inb,
   17921                 :            :                         &pkt_aes_128_cbc_hmac_sha256_v6),
   17922                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17923                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
   17924                 :            :                         ut_setup_security, ut_teardown,
   17925                 :            :                         test_ipsec_proto_known_vec_inb,
   17926                 :            :                         &pkt_null_aes_xcbc),
   17927                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17928                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
   17929                 :            :                         ut_setup_security, ut_teardown,
   17930                 :            :                         test_ipsec_proto_known_vec_inb,
   17931                 :            :                         &pkt_des_cbc_hmac_sha256),
   17932                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17933                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
   17934                 :            :                         ut_setup_security, ut_teardown,
   17935                 :            :                         test_ipsec_proto_known_vec_inb,
   17936                 :            :                         &pkt_des_cbc_hmac_sha384),
   17937                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17938                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
   17939                 :            :                         ut_setup_security, ut_teardown,
   17940                 :            :                         test_ipsec_proto_known_vec_inb,
   17941                 :            :                         &pkt_des_cbc_hmac_sha512),
   17942                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17943                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
   17944                 :            :                         ut_setup_security, ut_teardown,
   17945                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
   17946                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17947                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
   17948                 :            :                         ut_setup_security, ut_teardown,
   17949                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
   17950                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17951                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
   17952                 :            :                         ut_setup_security, ut_teardown,
   17953                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
   17954                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17955                 :            :                         "Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
   17956                 :            :                         ut_setup_security, ut_teardown,
   17957                 :            :                         test_ipsec_proto_known_vec_inb,
   17958                 :            :                         &pkt_des_cbc_hmac_sha256_v6),
   17959                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17960                 :            :                         "Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
   17961                 :            :                         ut_setup_security, ut_teardown,
   17962                 :            :                         test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
   17963                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17964                 :            :                         "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
   17965                 :            :                         ut_setup_security, ut_teardown,
   17966                 :            :                         test_ipsec_proto_known_vec_inb,
   17967                 :            :                         &pkt_ah_tunnel_sha256),
   17968                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17969                 :            :                         "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
   17970                 :            :                         ut_setup_security, ut_teardown,
   17971                 :            :                         test_ipsec_proto_known_vec_inb,
   17972                 :            :                         &pkt_ah_transport_sha256),
   17973                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   17974                 :            :                         "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
   17975                 :            :                         ut_setup_security, ut_teardown,
   17976                 :            :                         test_ipsec_proto_known_vec_inb,
   17977                 :            :                         &pkt_ah_ipv4_aes_gmac_128),
   17978                 :            :                 TEST_CASE_NAMED_ST(
   17979                 :            :                         "Combined test alg list",
   17980                 :            :                         ut_setup_security, ut_teardown,
   17981                 :            :                         test_ipsec_proto_display_list),
   17982                 :            :                 TEST_CASE_NAMED_ST(
   17983                 :            :                         "Combined test alg list (AH)",
   17984                 :            :                         ut_setup_security, ut_teardown,
   17985                 :            :                         test_ipsec_proto_ah_tunnel_ipv4),
   17986                 :            :                 TEST_CASE_NAMED_ST(
   17987                 :            :                         "IV generation",
   17988                 :            :                         ut_setup_security, ut_teardown,
   17989                 :            :                         test_ipsec_proto_iv_gen),
   17990                 :            :                 TEST_CASE_NAMED_ST(
   17991                 :            :                         "UDP encapsulation",
   17992                 :            :                         ut_setup_security, ut_teardown,
   17993                 :            :                         test_ipsec_proto_udp_encap),
   17994                 :            :                 TEST_CASE_NAMED_ST(
   17995                 :            :                         "UDP encapsulation with custom ports",
   17996                 :            :                         ut_setup_security, ut_teardown,
   17997                 :            :                         test_ipsec_proto_udp_encap_custom_ports),
   17998                 :            :                 TEST_CASE_NAMED_ST(
   17999                 :            :                         "UDP encapsulation ports verification test",
   18000                 :            :                         ut_setup_security, ut_teardown,
   18001                 :            :                         test_ipsec_proto_udp_ports_verify),
   18002                 :            :                 TEST_CASE_NAMED_ST(
   18003                 :            :                         "SA expiry packets soft",
   18004                 :            :                         ut_setup_security, ut_teardown,
   18005                 :            :                         test_ipsec_proto_sa_exp_pkts_soft),
   18006                 :            :                 TEST_CASE_NAMED_ST(
   18007                 :            :                         "SA expiry packets hard",
   18008                 :            :                         ut_setup_security, ut_teardown,
   18009                 :            :                         test_ipsec_proto_sa_exp_pkts_hard),
   18010                 :            :                 TEST_CASE_NAMED_ST(
   18011                 :            :                         "Negative test: ICV corruption",
   18012                 :            :                         ut_setup_security, ut_teardown,
   18013                 :            :                         test_ipsec_proto_err_icv_corrupt),
   18014                 :            :                 TEST_CASE_NAMED_ST(
   18015                 :            :                         "Tunnel dst addr verification",
   18016                 :            :                         ut_setup_security, ut_teardown,
   18017                 :            :                         test_ipsec_proto_tunnel_dst_addr_verify),
   18018                 :            :                 TEST_CASE_NAMED_ST(
   18019                 :            :                         "Tunnel src and dst addr verification",
   18020                 :            :                         ut_setup_security, ut_teardown,
   18021                 :            :                         test_ipsec_proto_tunnel_src_dst_addr_verify),
   18022                 :            :                 TEST_CASE_NAMED_ST(
   18023                 :            :                         "Inner IP checksum",
   18024                 :            :                         ut_setup_security, ut_teardown,
   18025                 :            :                         test_ipsec_proto_inner_ip_csum),
   18026                 :            :                 TEST_CASE_NAMED_ST(
   18027                 :            :                         "Inner L4 checksum",
   18028                 :            :                         ut_setup_security, ut_teardown,
   18029                 :            :                         test_ipsec_proto_inner_l4_csum),
   18030                 :            :                 TEST_CASE_NAMED_ST(
   18031                 :            :                         "Tunnel IPv4 in IPv4",
   18032                 :            :                         ut_setup_security, ut_teardown,
   18033                 :            :                         test_ipsec_proto_tunnel_v4_in_v4),
   18034                 :            :                 TEST_CASE_NAMED_ST(
   18035                 :            :                         "Tunnel IPv6 in IPv6",
   18036                 :            :                         ut_setup_security, ut_teardown,
   18037                 :            :                         test_ipsec_proto_tunnel_v6_in_v6),
   18038                 :            :                 TEST_CASE_NAMED_ST(
   18039                 :            :                         "Tunnel IPv4 in IPv6",
   18040                 :            :                         ut_setup_security, ut_teardown,
   18041                 :            :                         test_ipsec_proto_tunnel_v4_in_v6),
   18042                 :            :                 TEST_CASE_NAMED_ST(
   18043                 :            :                         "Tunnel IPv6 in IPv4",
   18044                 :            :                         ut_setup_security, ut_teardown,
   18045                 :            :                         test_ipsec_proto_tunnel_v6_in_v4),
   18046                 :            :                 TEST_CASE_NAMED_ST(
   18047                 :            :                         "Transport IPv4",
   18048                 :            :                         ut_setup_security, ut_teardown,
   18049                 :            :                         test_ipsec_proto_transport_v4),
   18050                 :            :                 TEST_CASE_NAMED_ST(
   18051                 :            :                         "AH transport IPv4",
   18052                 :            :                         ut_setup_security, ut_teardown,
   18053                 :            :                         test_ipsec_proto_ah_transport_ipv4),
   18054                 :            :                 TEST_CASE_NAMED_ST(
   18055                 :            :                         "Transport l4 checksum",
   18056                 :            :                         ut_setup_security, ut_teardown,
   18057                 :            :                         test_ipsec_proto_transport_l4_csum),
   18058                 :            :                 TEST_CASE_NAMED_ST(
   18059                 :            :                         "Statistics: success",
   18060                 :            :                         ut_setup_security, ut_teardown,
   18061                 :            :                         test_ipsec_proto_stats),
   18062                 :            :                 TEST_CASE_NAMED_ST(
   18063                 :            :                         "Fragmented packet",
   18064                 :            :                         ut_setup_security, ut_teardown,
   18065                 :            :                         test_ipsec_proto_pkt_fragment),
   18066                 :            :                 TEST_CASE_NAMED_ST(
   18067                 :            :                         "Tunnel header copy DF (inner 0)",
   18068                 :            :                         ut_setup_security, ut_teardown,
   18069                 :            :                         test_ipsec_proto_copy_df_inner_0),
   18070                 :            :                 TEST_CASE_NAMED_ST(
   18071                 :            :                         "Tunnel header copy DF (inner 1)",
   18072                 :            :                         ut_setup_security, ut_teardown,
   18073                 :            :                         test_ipsec_proto_copy_df_inner_1),
   18074                 :            :                 TEST_CASE_NAMED_ST(
   18075                 :            :                         "Tunnel header set DF 0 (inner 1)",
   18076                 :            :                         ut_setup_security, ut_teardown,
   18077                 :            :                         test_ipsec_proto_set_df_0_inner_1),
   18078                 :            :                 TEST_CASE_NAMED_ST(
   18079                 :            :                         "Tunnel header set DF 1 (inner 0)",
   18080                 :            :                         ut_setup_security, ut_teardown,
   18081                 :            :                         test_ipsec_proto_set_df_1_inner_0),
   18082                 :            :                 TEST_CASE_NAMED_ST(
   18083                 :            :                         "Tunnel header IPv4 copy DSCP (inner 0)",
   18084                 :            :                         ut_setup_security, ut_teardown,
   18085                 :            :                         test_ipsec_proto_ipv4_copy_dscp_inner_0),
   18086                 :            :                 TEST_CASE_NAMED_ST(
   18087                 :            :                         "Tunnel header IPv4 copy DSCP (inner 1)",
   18088                 :            :                         ut_setup_security, ut_teardown,
   18089                 :            :                         test_ipsec_proto_ipv4_copy_dscp_inner_1),
   18090                 :            :                 TEST_CASE_NAMED_ST(
   18091                 :            :                         "Tunnel header IPv4 set DSCP 0 (inner 1)",
   18092                 :            :                         ut_setup_security, ut_teardown,
   18093                 :            :                         test_ipsec_proto_ipv4_set_dscp_0_inner_1),
   18094                 :            :                 TEST_CASE_NAMED_ST(
   18095                 :            :                         "Tunnel header IPv4 set DSCP 1 (inner 0)",
   18096                 :            :                         ut_setup_security, ut_teardown,
   18097                 :            :                         test_ipsec_proto_ipv4_set_dscp_1_inner_0),
   18098                 :            :                 TEST_CASE_NAMED_ST(
   18099                 :            :                         "Tunnel header IPv6 copy DSCP (inner 0)",
   18100                 :            :                         ut_setup_security, ut_teardown,
   18101                 :            :                         test_ipsec_proto_ipv6_copy_dscp_inner_0),
   18102                 :            :                 TEST_CASE_NAMED_ST(
   18103                 :            :                         "Tunnel header IPv6 copy DSCP (inner 1)",
   18104                 :            :                         ut_setup_security, ut_teardown,
   18105                 :            :                         test_ipsec_proto_ipv6_copy_dscp_inner_1),
   18106                 :            :                 TEST_CASE_NAMED_ST(
   18107                 :            :                         "Tunnel header IPv6 set DSCP 0 (inner 1)",
   18108                 :            :                         ut_setup_security, ut_teardown,
   18109                 :            :                         test_ipsec_proto_ipv6_set_dscp_0_inner_1),
   18110                 :            :                 TEST_CASE_NAMED_ST(
   18111                 :            :                         "Tunnel header IPv6 set DSCP 1 (inner 0)",
   18112                 :            :                         ut_setup_security, ut_teardown,
   18113                 :            :                         test_ipsec_proto_ipv6_set_dscp_1_inner_0),
   18114                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18115                 :            :                         "Antireplay with window size 1024",
   18116                 :            :                         ut_setup_security, ut_teardown,
   18117                 :            :                         test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
   18118                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18119                 :            :                         "Antireplay with window size 2048",
   18120                 :            :                         ut_setup_security, ut_teardown,
   18121                 :            :                         test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
   18122                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18123                 :            :                         "Antireplay with window size 4096",
   18124                 :            :                         ut_setup_security, ut_teardown,
   18125                 :            :                         test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
   18126                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18127                 :            :                         "ESN and Antireplay with window size 1024",
   18128                 :            :                         ut_setup_security, ut_teardown,
   18129                 :            :                         test_ipsec_proto_pkt_esn_antireplay1024,
   18130                 :            :                         &pkt_aes_128_gcm),
   18131                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18132                 :            :                         "ESN and Antireplay with window size 2048",
   18133                 :            :                         ut_setup_security, ut_teardown,
   18134                 :            :                         test_ipsec_proto_pkt_esn_antireplay2048,
   18135                 :            :                         &pkt_aes_128_gcm),
   18136                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18137                 :            :                         "ESN and Antireplay with window size 4096",
   18138                 :            :                         ut_setup_security, ut_teardown,
   18139                 :            :                         test_ipsec_proto_pkt_esn_antireplay4096,
   18140                 :            :                         &pkt_aes_128_gcm),
   18141                 :            :                 TEST_CASE_NAMED_ST(
   18142                 :            :                         "Tunnel header IPv4 decrement inner TTL",
   18143                 :            :                         ut_setup_security, ut_teardown,
   18144                 :            :                         test_ipsec_proto_ipv4_ttl_decrement),
   18145                 :            :                 TEST_CASE_NAMED_ST(
   18146                 :            :                         "Tunnel header IPv6 decrement inner hop limit",
   18147                 :            :                         ut_setup_security, ut_teardown,
   18148                 :            :                         test_ipsec_proto_ipv6_hop_limit_decrement),
   18149                 :            :                 TEST_CASE_NAMED_ST(
   18150                 :            :                         "Multi-segmented mode",
   18151                 :            :                         ut_setup_security, ut_teardown,
   18152                 :            :                         test_ipsec_proto_sgl),
   18153                 :            :                 TEST_CASE_NAMED_ST(
   18154                 :            :                         "Multi-segmented external mbuf mode",
   18155                 :            :                         ut_setup_security, ut_teardown,
   18156                 :            :                         test_ipsec_proto_sgl_ext_mbuf),
   18157                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18158                 :            :                         "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
   18159                 :            :                         ut_setup_security_rx_inject, ut_teardown_rx_inject,
   18160                 :            :                         test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
   18161                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18162                 :            :         }
   18163                 :            : };
   18164                 :            : 
   18165                 :            : static struct unit_test_suite pdcp_proto_testsuite  = {
   18166                 :            :         .suite_name = "PDCP Proto Unit Test Suite",
   18167                 :            :         .setup = pdcp_proto_testsuite_setup,
   18168                 :            :         .unit_test_cases = {
   18169                 :            :                 TEST_CASE_ST(ut_setup_security, ut_teardown,
   18170                 :            :                         test_PDCP_PROTO_all),
   18171                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18172                 :            :         }
   18173                 :            : };
   18174                 :            : 
   18175                 :            : static struct unit_test_suite tls12_record_proto_testsuite  = {
   18176                 :            :         .suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
   18177                 :            :         .setup = tls_record_proto_testsuite_setup,
   18178                 :            :         .unit_test_cases = {
   18179                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18180                 :            :                         "Write record known vector AES-GCM-128 (vector 1)",
   18181                 :            :                         ut_setup_security, ut_teardown,
   18182                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
   18183                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18184                 :            :                         "Write record known vector AES-GCM-128 (vector 2)",
   18185                 :            :                         ut_setup_security, ut_teardown,
   18186                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
   18187                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18188                 :            :                         "Write record known vector AES-GCM-256",
   18189                 :            :                         ut_setup_security, ut_teardown,
   18190                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
   18191                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18192                 :            :                         "Write record known vector AES-CBC-128-SHA1",
   18193                 :            :                         ut_setup_security, ut_teardown,
   18194                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
   18195                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18196                 :            :                         "Write record known vector AES-128-CBC-SHA256",
   18197                 :            :                         ut_setup_security, ut_teardown,
   18198                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
   18199                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18200                 :            :                         "Write record known vector AES-256-CBC-SHA1",
   18201                 :            :                         ut_setup_security, ut_teardown,
   18202                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
   18203                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18204                 :            :                         "Write record known vector AES-256-CBC-SHA256",
   18205                 :            :                         ut_setup_security, ut_teardown,
   18206                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
   18207                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18208                 :            :                         "Write record known vector AES-256-CBC-SHA384",
   18209                 :            :                         ut_setup_security, ut_teardown,
   18210                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha384_hmac),
   18211                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18212                 :            :                         "Write record known vector 3DES-CBC-SHA1-HMAC",
   18213                 :            :                         ut_setup_security, ut_teardown,
   18214                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
   18215                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18216                 :            :                         "Write record known vector NULL-SHA1-HMAC",
   18217                 :            :                         ut_setup_security, ut_teardown,
   18218                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
   18219                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18220                 :            :                         "Write record known vector CHACHA20-POLY1305",
   18221                 :            :                         ut_setup_security, ut_teardown,
   18222                 :            :                         test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
   18223                 :            : 
   18224                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18225                 :            :                         "Read record known vector AES-GCM-128 (vector 1)",
   18226                 :            :                         ut_setup_security, ut_teardown,
   18227                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
   18228                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18229                 :            :                         "Read record known vector AES-GCM-128 (vector 2)",
   18230                 :            :                         ut_setup_security, ut_teardown,
   18231                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
   18232                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18233                 :            :                         "Read record known vector AES-GCM-256",
   18234                 :            :                         ut_setup_security, ut_teardown,
   18235                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
   18236                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18237                 :            :                         "Read record known vector AES-128-CBC-SHA1",
   18238                 :            :                         ut_setup_security, ut_teardown,
   18239                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
   18240                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18241                 :            :                         "Read record known vector AES-128-CBC-SHA256",
   18242                 :            :                         ut_setup_security, ut_teardown,
   18243                 :            :                         test_tls_record_proto_known_vec_read,
   18244                 :            :                         &tls_test_data_aes_128_cbc_sha256_hmac),
   18245                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18246                 :            :                         "Read record known vector AES-256-CBC-SHA1",
   18247                 :            :                         ut_setup_security, ut_teardown,
   18248                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
   18249                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18250                 :            :                         "Read record known vector AES-256-CBC-SHA256",
   18251                 :            :                         ut_setup_security, ut_teardown,
   18252                 :            :                         test_tls_record_proto_known_vec_read,
   18253                 :            :                         &tls_test_data_aes_256_cbc_sha256_hmac),
   18254                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18255                 :            :                         "Read record known vector AES-256-CBC-SHA384",
   18256                 :            :                         ut_setup_security, ut_teardown,
   18257                 :            :                         test_tls_record_proto_known_vec_read,
   18258                 :            :                         &tls_test_data_aes_256_cbc_sha384_hmac),
   18259                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18260                 :            :                         "Read record known vector 3DES-CBC-SHA1-HMAC",
   18261                 :            :                         ut_setup_security, ut_teardown,
   18262                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
   18263                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18264                 :            :                         "Read record known vector NULL-SHA1-HMAC",
   18265                 :            :                         ut_setup_security, ut_teardown,
   18266                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
   18267                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18268                 :            :                         "Read record known vector CHACHA20-POLY1305",
   18269                 :            :                         ut_setup_security, ut_teardown,
   18270                 :            :                         test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
   18271                 :            : 
   18272                 :            :                 TEST_CASE_NAMED_ST(
   18273                 :            :                         "Combined test alg list",
   18274                 :            :                         ut_setup_security, ut_teardown,
   18275                 :            :                         test_tls_1_2_record_proto_display_list),
   18276                 :            :                 TEST_CASE_NAMED_ST(
   18277                 :            :                         "Data walkthrough combined test alg list",
   18278                 :            :                         ut_setup_security, ut_teardown,
   18279                 :            :                         test_tls_1_2_record_proto_data_walkthrough),
   18280                 :            :                 TEST_CASE_NAMED_ST(
   18281                 :            :                         "Multi-segmented mode",
   18282                 :            :                         ut_setup_security, ut_teardown,
   18283                 :            :                         test_tls_1_2_record_proto_sgl),
   18284                 :            :                 TEST_CASE_NAMED_ST(
   18285                 :            :                         "Multi-segmented mode data walkthrough",
   18286                 :            :                         ut_setup_security, ut_teardown,
   18287                 :            :                         test_tls_1_2_record_proto_sgl_data_walkthrough),
   18288                 :            :                 TEST_CASE_NAMED_ST(
   18289                 :            :                         "Multi-segmented mode out of place",
   18290                 :            :                         ut_setup_security, ut_teardown,
   18291                 :            :                         test_tls_1_2_record_proto_sgl_oop),
   18292                 :            :                 TEST_CASE_NAMED_ST(
   18293                 :            :                         "TLS packet header corruption",
   18294                 :            :                         ut_setup_security, ut_teardown,
   18295                 :            :                         test_tls_record_proto_corrupt_pkt),
   18296                 :            :                 TEST_CASE_NAMED_ST(
   18297                 :            :                         "Custom content type",
   18298                 :            :                         ut_setup_security, ut_teardown,
   18299                 :            :                         test_tls_record_proto_custom_content_type),
   18300                 :            :                 TEST_CASE_NAMED_ST(
   18301                 :            :                         "Zero len TLS record with content type as app",
   18302                 :            :                         ut_setup_security, ut_teardown,
   18303                 :            :                         test_tls_record_proto_zero_len),
   18304                 :            :                 TEST_CASE_NAMED_ST(
   18305                 :            :                         "Zero len TLS record with content type as ctrl",
   18306                 :            :                         ut_setup_security, ut_teardown,
   18307                 :            :                         test_tls_record_proto_zero_len_non_app),
   18308                 :            :                 TEST_CASE_NAMED_ST(
   18309                 :            :                         "TLS record DM mode with optional padding < 2 blocks",
   18310                 :            :                         ut_setup_security, ut_teardown,
   18311                 :            :                         test_tls_record_proto_dm_opt_padding),
   18312                 :            :                 TEST_CASE_NAMED_ST(
   18313                 :            :                         "TLS record DM mode with optional padding > 2 blocks",
   18314                 :            :                         ut_setup_security, ut_teardown,
   18315                 :            :                         test_tls_record_proto_dm_opt_padding_1),
   18316                 :            :                 TEST_CASE_NAMED_ST(
   18317                 :            :                         "TLS record SG mode with optional padding < 2 blocks",
   18318                 :            :                         ut_setup_security, ut_teardown,
   18319                 :            :                         test_tls_record_proto_sg_opt_padding),
   18320                 :            :                 TEST_CASE_NAMED_ST(
   18321                 :            :                         "TLS record SG mode with optional padding > 2 blocks",
   18322                 :            :                         ut_setup_security, ut_teardown,
   18323                 :            :                         test_tls_record_proto_sg_opt_padding_1),
   18324                 :            :                 TEST_CASE_NAMED_ST(
   18325                 :            :                         "TLS record SG mode with optional padding > 2 blocks",
   18326                 :            :                         ut_setup_security, ut_teardown,
   18327                 :            :                         test_tls_record_proto_sg_opt_padding_2),
   18328                 :            :                 TEST_CASE_NAMED_ST(
   18329                 :            :                         "TLS record SG mode with optional padding > max range",
   18330                 :            :                         ut_setup_security, ut_teardown,
   18331                 :            :                         test_tls_record_proto_sg_opt_padding_max),
   18332                 :            :                 TEST_CASE_NAMED_ST(
   18333                 :            :                         "TLS record SG mode with padding corruption",
   18334                 :            :                         ut_setup_security, ut_teardown,
   18335                 :            :                         test_tls_record_proto_sg_opt_padding_corrupt),
   18336                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18337                 :            :         }
   18338                 :            : };
   18339                 :            : 
   18340                 :            : static struct unit_test_suite dtls12_record_proto_testsuite  = {
   18341                 :            :         .suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
   18342                 :            :         .setup = tls_record_proto_testsuite_setup,
   18343                 :            :         .unit_test_cases = {
   18344                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18345                 :            :                         "Write record known vector AES-GCM-128",
   18346                 :            :                         ut_setup_security, ut_teardown,
   18347                 :            :                         test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
   18348                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18349                 :            :                         "Write record known vector AES-GCM-256",
   18350                 :            :                         ut_setup_security, ut_teardown,
   18351                 :            :                         test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
   18352                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18353                 :            :                         "Write record known vector AES-128-CBC-SHA1",
   18354                 :            :                         ut_setup_security, ut_teardown,
   18355                 :            :                         test_tls_record_proto_known_vec,
   18356                 :            :                         &dtls_test_data_aes_128_cbc_sha1_hmac),
   18357                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18358                 :            :                         "Write record known vector AES-128-CBC-SHA256",
   18359                 :            :                         ut_setup_security, ut_teardown,
   18360                 :            :                         test_tls_record_proto_known_vec,
   18361                 :            :                         &dtls_test_data_aes_128_cbc_sha256_hmac),
   18362                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18363                 :            :                         "Write record known vector AES-256-CBC-SHA1",
   18364                 :            :                         ut_setup_security, ut_teardown,
   18365                 :            :                         test_tls_record_proto_known_vec,
   18366                 :            :                         &dtls_test_data_aes_256_cbc_sha1_hmac),
   18367                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18368                 :            :                         "Write record known vector AES-256-CBC-SHA256",
   18369                 :            :                         ut_setup_security, ut_teardown,
   18370                 :            :                         test_tls_record_proto_known_vec,
   18371                 :            :                         &dtls_test_data_aes_256_cbc_sha256_hmac),
   18372                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18373                 :            :                         "Write record known vector AES-256-CBC-SHA384",
   18374                 :            :                         ut_setup_security, ut_teardown,
   18375                 :            :                         test_tls_record_proto_known_vec,
   18376                 :            :                         &dtls_test_data_aes_256_cbc_sha384_hmac),
   18377                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18378                 :            :                         "Write record known vector 3DES-CBC-SHA1-HMAC",
   18379                 :            :                         ut_setup_security, ut_teardown,
   18380                 :            :                         test_tls_record_proto_known_vec,
   18381                 :            :                         &dtls_test_data_3des_cbc_sha1_hmac),
   18382                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18383                 :            :                         "Write record known vector NULL-SHA1-HMAC",
   18384                 :            :                         ut_setup_security, ut_teardown,
   18385                 :            :                         test_tls_record_proto_known_vec,
   18386                 :            :                         &dtls_test_data_null_cipher_sha1_hmac),
   18387                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18388                 :            :                         "Write record known vector CHACHA20-POLY1305",
   18389                 :            :                         ut_setup_security, ut_teardown,
   18390                 :            :                         test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
   18391                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18392                 :            :                         "Read record known vector AES-GCM-128",
   18393                 :            :                         ut_setup_security, ut_teardown,
   18394                 :            :                         test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
   18395                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18396                 :            :                         "Read record known vector AES-GCM-256",
   18397                 :            :                         ut_setup_security, ut_teardown,
   18398                 :            :                         test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
   18399                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18400                 :            :                         "Read record known vector AES-128-CBC-SHA1",
   18401                 :            :                         ut_setup_security, ut_teardown,
   18402                 :            :                         test_tls_record_proto_known_vec_read,
   18403                 :            :                         &dtls_test_data_aes_128_cbc_sha1_hmac),
   18404                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18405                 :            :                         "Read record known vector AES-128-CBC-SHA256",
   18406                 :            :                         ut_setup_security, ut_teardown,
   18407                 :            :                         test_tls_record_proto_known_vec_read,
   18408                 :            :                         &dtls_test_data_aes_128_cbc_sha256_hmac),
   18409                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18410                 :            :                         "Read record known vector AES-256-CBC-SHA1",
   18411                 :            :                         ut_setup_security, ut_teardown,
   18412                 :            :                         test_tls_record_proto_known_vec_read,
   18413                 :            :                         &dtls_test_data_aes_256_cbc_sha1_hmac),
   18414                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18415                 :            :                         "Read record known vector AES-256-CBC-SHA256",
   18416                 :            :                         ut_setup_security, ut_teardown,
   18417                 :            :                         test_tls_record_proto_known_vec_read,
   18418                 :            :                         &dtls_test_data_aes_256_cbc_sha256_hmac),
   18419                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18420                 :            :                         "Read record known vector AES-256-CBC-SHA384",
   18421                 :            :                         ut_setup_security, ut_teardown,
   18422                 :            :                         test_tls_record_proto_known_vec_read,
   18423                 :            :                         &dtls_test_data_aes_256_cbc_sha384_hmac),
   18424                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18425                 :            :                         "Read record known vector 3DES-CBC-SHA1-HMAC",
   18426                 :            :                         ut_setup_security, ut_teardown,
   18427                 :            :                         test_tls_record_proto_known_vec_read,
   18428                 :            :                         &dtls_test_data_3des_cbc_sha1_hmac),
   18429                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18430                 :            :                         "Read record known vector NULL-SHA1-HMAC",
   18431                 :            :                         ut_setup_security, ut_teardown,
   18432                 :            :                         test_tls_record_proto_known_vec_read,
   18433                 :            :                         &dtls_test_data_null_cipher_sha1_hmac),
   18434                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18435                 :            :                         "Read record known vector CHACHA20-POLY1305",
   18436                 :            :                         ut_setup_security, ut_teardown,
   18437                 :            :                         test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
   18438                 :            : 
   18439                 :            :                 TEST_CASE_NAMED_ST(
   18440                 :            :                         "Combined test alg list",
   18441                 :            :                         ut_setup_security, ut_teardown,
   18442                 :            :                         test_dtls_1_2_record_proto_display_list),
   18443                 :            :                 TEST_CASE_NAMED_ST(
   18444                 :            :                         "Data walkthrough combined test alg list",
   18445                 :            :                         ut_setup_security, ut_teardown,
   18446                 :            :                         test_dtls_1_2_record_proto_data_walkthrough),
   18447                 :            :                 TEST_CASE_NAMED_ST(
   18448                 :            :                         "Multi-segmented mode",
   18449                 :            :                         ut_setup_security, ut_teardown,
   18450                 :            :                         test_dtls_1_2_record_proto_sgl),
   18451                 :            :                 TEST_CASE_NAMED_ST(
   18452                 :            :                         "Multi-segmented mode data walkthrough",
   18453                 :            :                         ut_setup_security, ut_teardown,
   18454                 :            :                         test_dtls_1_2_record_proto_sgl_data_walkthrough),
   18455                 :            :                 TEST_CASE_NAMED_ST(
   18456                 :            :                         "Multi-segmented mode out of place",
   18457                 :            :                         ut_setup_security, ut_teardown,
   18458                 :            :                         test_dtls_1_2_record_proto_sgl_oop),
   18459                 :            :                 TEST_CASE_NAMED_ST(
   18460                 :            :                         "Packet corruption",
   18461                 :            :                         ut_setup_security, ut_teardown,
   18462                 :            :                         test_dtls_1_2_record_proto_corrupt_pkt),
   18463                 :            :                 TEST_CASE_NAMED_ST(
   18464                 :            :                         "Custom content type",
   18465                 :            :                         ut_setup_security, ut_teardown,
   18466                 :            :                         test_dtls_1_2_record_proto_custom_content_type),
   18467                 :            :                 TEST_CASE_NAMED_ST(
   18468                 :            :                         "Zero len DTLS record with content type as app",
   18469                 :            :                         ut_setup_security, ut_teardown,
   18470                 :            :                         test_dtls_1_2_record_proto_zero_len),
   18471                 :            :                 TEST_CASE_NAMED_ST(
   18472                 :            :                         "Zero len DTLS record with content type as ctrl",
   18473                 :            :                         ut_setup_security, ut_teardown,
   18474                 :            :                         test_dtls_1_2_record_proto_zero_len_non_app),
   18475                 :            :                 TEST_CASE_NAMED_ST(
   18476                 :            :                         "Antireplay with window size 64",
   18477                 :            :                         ut_setup_security, ut_teardown,
   18478                 :            :                         test_dtls_1_2_record_proto_antireplay64),
   18479                 :            :                 TEST_CASE_NAMED_ST(
   18480                 :            :                         "Antireplay with window size 128",
   18481                 :            :                         ut_setup_security, ut_teardown,
   18482                 :            :                         test_dtls_1_2_record_proto_antireplay128),
   18483                 :            :                 TEST_CASE_NAMED_ST(
   18484                 :            :                         "Antireplay with window size 256",
   18485                 :            :                         ut_setup_security, ut_teardown,
   18486                 :            :                         test_dtls_1_2_record_proto_antireplay256),
   18487                 :            :                 TEST_CASE_NAMED_ST(
   18488                 :            :                         "Antireplay with window size 512",
   18489                 :            :                         ut_setup_security, ut_teardown,
   18490                 :            :                         test_dtls_1_2_record_proto_antireplay512),
   18491                 :            :                 TEST_CASE_NAMED_ST(
   18492                 :            :                         "Antireplay with window size 1024",
   18493                 :            :                         ut_setup_security, ut_teardown,
   18494                 :            :                         test_dtls_1_2_record_proto_antireplay1024),
   18495                 :            :                 TEST_CASE_NAMED_ST(
   18496                 :            :                         "Antireplay with window size 2048",
   18497                 :            :                         ut_setup_security, ut_teardown,
   18498                 :            :                         test_dtls_1_2_record_proto_antireplay2048),
   18499                 :            :                 TEST_CASE_NAMED_ST(
   18500                 :            :                         "Antireplay with window size 4096",
   18501                 :            :                         ut_setup_security, ut_teardown,
   18502                 :            :                         test_dtls_1_2_record_proto_antireplay4096),
   18503                 :            :                 TEST_CASE_NAMED_ST(
   18504                 :            :                         "DTLS record DM mode with optional padding < 2 blocks",
   18505                 :            :                         ut_setup_security, ut_teardown,
   18506                 :            :                         test_dtls_1_2_record_proto_dm_opt_padding),
   18507                 :            :                 TEST_CASE_NAMED_ST(
   18508                 :            :                         "DTLS record DM mode with optional padding > 2 blocks",
   18509                 :            :                         ut_setup_security, ut_teardown,
   18510                 :            :                         test_dtls_1_2_record_proto_dm_opt_padding_1),
   18511                 :            :                 TEST_CASE_NAMED_ST(
   18512                 :            :                         "DTLS record SG mode with optional padding < 2 blocks",
   18513                 :            :                         ut_setup_security, ut_teardown,
   18514                 :            :                         test_dtls_1_2_record_proto_sg_opt_padding),
   18515                 :            :                 TEST_CASE_NAMED_ST(
   18516                 :            :                         "DTLS record SG mode with optional padding > 2 blocks",
   18517                 :            :                         ut_setup_security, ut_teardown,
   18518                 :            :                         test_dtls_1_2_record_proto_sg_opt_padding_1),
   18519                 :            :                 TEST_CASE_NAMED_ST(
   18520                 :            :                         "DTLS record SG mode with optional padding > 2 blocks",
   18521                 :            :                         ut_setup_security, ut_teardown,
   18522                 :            :                         test_dtls_1_2_record_proto_sg_opt_padding_2),
   18523                 :            :                 TEST_CASE_NAMED_ST(
   18524                 :            :                         "DTLS record SG mode with optional padding > max range",
   18525                 :            :                         ut_setup_security, ut_teardown,
   18526                 :            :                         test_dtls_1_2_record_proto_sg_opt_padding_max),
   18527                 :            :                 TEST_CASE_NAMED_ST(
   18528                 :            :                         "DTLS record SG mode with padding corruption",
   18529                 :            :                         ut_setup_security, ut_teardown,
   18530                 :            :                         test_dtls_1_2_record_proto_sg_opt_padding_corrupt),
   18531                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18532                 :            :         }
   18533                 :            : };
   18534                 :            : 
   18535                 :            : static struct unit_test_suite tls13_record_proto_testsuite  = {
   18536                 :            :         .suite_name = "TLS 1.3 Record Protocol Unit Test Suite",
   18537                 :            :         .setup = tls_record_proto_testsuite_setup,
   18538                 :            :         .unit_test_cases = {
   18539                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18540                 :            :                         "Write record known vector AES-GCM-128",
   18541                 :            :                         ut_setup_security, ut_teardown,
   18542                 :            :                         test_tls_record_proto_known_vec, &tls13_test_data_aes_128_gcm),
   18543                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18544                 :            :                         "Write record known vector AES-GCM-256",
   18545                 :            :                         ut_setup_security, ut_teardown,
   18546                 :            :                         test_tls_record_proto_known_vec, &tls13_test_data_aes_256_gcm),
   18547                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18548                 :            :                         "Write record known vector CHACHA20-POLY1305",
   18549                 :            :                         ut_setup_security, ut_teardown,
   18550                 :            :                         test_tls_record_proto_known_vec, &tls13_test_data_chacha20_poly1305),
   18551                 :            : 
   18552                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18553                 :            :                         "Read record known vector AES-GCM-128",
   18554                 :            :                         ut_setup_security, ut_teardown,
   18555                 :            :                         test_tls_record_proto_known_vec_read, &tls13_test_data_aes_128_gcm),
   18556                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18557                 :            :                         "Read record known vector AES-GCM-256",
   18558                 :            :                         ut_setup_security, ut_teardown,
   18559                 :            :                         test_tls_record_proto_known_vec_read, &tls13_test_data_aes_256_gcm),
   18560                 :            :                 TEST_CASE_NAMED_WITH_DATA(
   18561                 :            :                         "Read record known vector CHACHA20-POLY1305",
   18562                 :            :                         ut_setup_security, ut_teardown,
   18563                 :            :                         test_tls_record_proto_known_vec_read, &tls13_test_data_chacha20_poly1305),
   18564                 :            :                 TEST_CASE_NAMED_ST(
   18565                 :            :                         "TLS-1.3 record header corruption",
   18566                 :            :                         ut_setup_security, ut_teardown,
   18567                 :            :                         test_tls_1_3_record_proto_corrupt_pkt),
   18568                 :            :                 TEST_CASE_NAMED_ST(
   18569                 :            :                         "TLS-1.3 record header with custom content type",
   18570                 :            :                         ut_setup_security, ut_teardown,
   18571                 :            :                         test_tls_1_3_record_proto_custom_content_type),
   18572                 :            :                 TEST_CASE_NAMED_ST(
   18573                 :            :                         "TLS-1.3 record with zero len and content type as app",
   18574                 :            :                         ut_setup_security, ut_teardown,
   18575                 :            :                         test_tls_1_3_record_proto_zero_len),
   18576                 :            :                 TEST_CASE_NAMED_ST(
   18577                 :            :                         "TLS-1.3 record with zero len and content type as ctrl",
   18578                 :            :                         ut_setup_security, ut_teardown,
   18579                 :            :                         test_tls_1_3_record_proto_zero_len_non_app),
   18580                 :            :                 TEST_CASE_NAMED_ST(
   18581                 :            :                         "TLS-1.3 record DM mode with optional padding",
   18582                 :            :                         ut_setup_security, ut_teardown,
   18583                 :            :                         test_tls_1_3_record_proto_dm_opt_padding),
   18584                 :            :                 TEST_CASE_NAMED_ST(
   18585                 :            :                         "TLS-1.3 record SG mode with optional padding - 1",
   18586                 :            :                         ut_setup_security, ut_teardown,
   18587                 :            :                         test_tls_1_3_record_proto_sg_opt_padding),
   18588                 :            :                 TEST_CASE_NAMED_ST(
   18589                 :            :                         "TLS-1.3 record SG mode with optional padding",
   18590                 :            :                         ut_setup_security, ut_teardown,
   18591                 :            :                         test_tls_1_3_record_proto_sg_opt_padding_1),
   18592                 :            :                 TEST_CASE_NAMED_ST(
   18593                 :            :                         "Combined test alg list",
   18594                 :            :                         ut_setup_security, ut_teardown,
   18595                 :            :                         test_tls_1_3_record_proto_display_list),
   18596                 :            :                 TEST_CASE_NAMED_ST(
   18597                 :            :                         "Data walkthrough combined test alg list",
   18598                 :            :                         ut_setup_security, ut_teardown,
   18599                 :            :                         test_tls_1_3_record_proto_data_walkthrough),
   18600                 :            :                 TEST_CASE_NAMED_ST(
   18601                 :            :                         "Multi-segmented mode",
   18602                 :            :                         ut_setup_security, ut_teardown,
   18603                 :            :                         test_tls_1_3_record_proto_sgl),
   18604                 :            :                 TEST_CASE_NAMED_ST(
   18605                 :            :                         "Multi-segmented mode data walkthrough",
   18606                 :            :                         ut_setup_security, ut_teardown,
   18607                 :            :                         test_tls_1_3_record_proto_sgl_data_walkthrough),
   18608                 :            :                 TEST_CASE_NAMED_ST(
   18609                 :            :                         "Multi-segmented mode out of place",
   18610                 :            :                         ut_setup_security, ut_teardown,
   18611                 :            :                         test_tls_1_3_record_proto_sgl_oop),
   18612                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18613                 :            :         }
   18614                 :            : };
   18615                 :            : 
   18616                 :            : #define ADD_UPLINK_TESTCASE(data)                                               \
   18617                 :            :         TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security,    \
   18618                 :            :         ut_teardown, test_docsis_proto_uplink, (const void *) &data),               \
   18619                 :            : 
   18620                 :            : #define ADD_DOWNLINK_TESTCASE(data)                                             \
   18621                 :            :         TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security,  \
   18622                 :            :         ut_teardown, test_docsis_proto_downlink, (const void *) &data),             \
   18623                 :            : 
   18624                 :            : static struct unit_test_suite docsis_proto_testsuite  = {
   18625                 :            :         .suite_name = "DOCSIS Proto Unit Test Suite",
   18626                 :            :         .setup = docsis_proto_testsuite_setup,
   18627                 :            :         .unit_test_cases = {
   18628                 :            :                 /* Uplink */
   18629                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_1)
   18630                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_2)
   18631                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_3)
   18632                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_4)
   18633                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_5)
   18634                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_6)
   18635                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_7)
   18636                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_8)
   18637                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_9)
   18638                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_10)
   18639                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_11)
   18640                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_12)
   18641                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_13)
   18642                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_14)
   18643                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_15)
   18644                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_16)
   18645                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_17)
   18646                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_18)
   18647                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_19)
   18648                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_20)
   18649                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_21)
   18650                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_22)
   18651                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_23)
   18652                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_24)
   18653                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_25)
   18654                 :            :                 ADD_UPLINK_TESTCASE(docsis_test_case_26)
   18655                 :            :                 /* Downlink */
   18656                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
   18657                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
   18658                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
   18659                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
   18660                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
   18661                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
   18662                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
   18663                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
   18664                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
   18665                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
   18666                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
   18667                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
   18668                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
   18669                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
   18670                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
   18671                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
   18672                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
   18673                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
   18674                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
   18675                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
   18676                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
   18677                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
   18678                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
   18679                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
   18680                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
   18681                 :            :                 ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
   18682                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18683                 :            :         }
   18684                 :            : };
   18685                 :            : #endif
   18686                 :            : 
   18687                 :            : static struct unit_test_suite cryptodev_gen_testsuite  = {
   18688                 :            :         .suite_name = "Crypto General Unit Test Suite",
   18689                 :            :         .setup = crypto_gen_testsuite_setup,
   18690                 :            :         .unit_test_cases = {
   18691                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18692                 :            :                                 test_device_reconfigure),
   18693                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18694                 :            :                                 test_device_configure_invalid_dev_id),
   18695                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18696                 :            :                                 test_queue_pair_descriptor_setup),
   18697                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18698                 :            :                                 test_device_configure_invalid_queue_pair_ids),
   18699                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18700                 :            :                                 test_queue_pair_descriptor_count),
   18701                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
   18702                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
   18703                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
   18704                 :            :                 TEST_CASE_NAMED_WITH_DATA("Verify cryptodev error recover", ut_setup, ut_teardown,
   18705                 :            :                                           test_cryptodev_verify_error_recover, &aes_test_data_4),
   18706                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18707                 :            :         }
   18708                 :            : };
   18709                 :            : 
   18710                 :            : static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
   18711                 :            :         .suite_name = "Negative HMAC SHA1 Unit Test Suite",
   18712                 :            :         .setup = negative_hmac_sha1_testsuite_setup,
   18713                 :            :         .unit_test_cases = {
   18714                 :            :                 /** Negative tests */
   18715                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18716                 :            :                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
   18717                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18718                 :            :                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
   18719                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18720                 :            :                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
   18721                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18722                 :            :                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
   18723                 :            : 
   18724                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18725                 :            :         }
   18726                 :            : };
   18727                 :            : 
   18728                 :            : static struct unit_test_suite cryptodev_multi_session_testsuite = {
   18729                 :            :         .suite_name = "Multi Session Unit Test Suite",
   18730                 :            :         .setup = multi_session_testsuite_setup,
   18731                 :            :         .unit_test_cases = {
   18732                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
   18733                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18734                 :            :                                 test_multi_session_random_usage),
   18735                 :            : 
   18736                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
   18737                 :            :         }
   18738                 :            : };
   18739                 :            : 
   18740                 :            : static struct unit_test_suite cryptodev_null_testsuite  = {
   18741                 :            :         .suite_name = "NULL Test Suite",
   18742                 :            :         .setup = null_testsuite_setup,
   18743                 :            :         .unit_test_cases = {
   18744                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18745                 :            :                         test_null_invalid_operation),
   18746                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
   18747                 :            :                 TEST_CASES_END()
   18748                 :            :         }
   18749                 :            : };
   18750                 :            : 
   18751                 :            : static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite  = {
   18752                 :            :         .suite_name = "AES CCM Authenticated Test Suite",
   18753                 :            :         .setup = aes_ccm_auth_testsuite_setup,
   18754                 :            :         .unit_test_cases = {
   18755                 :            :                 /** AES CCM Authenticated Encryption 128 bits key*/
   18756                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18757                 :            :                         test_AES_CCM_authenticated_encryption_test_case_128_1),
   18758                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18759                 :            :                         test_AES_CCM_authenticated_encryption_test_case_128_2),
   18760                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18761                 :            :                         test_AES_CCM_authenticated_encryption_test_case_128_3),
   18762                 :            : 
   18763                 :            :                 /** AES CCM Authenticated Decryption 128 bits key*/
   18764                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18765                 :            :                         test_AES_CCM_authenticated_decryption_test_case_128_1),
   18766                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18767                 :            :                         test_AES_CCM_authenticated_decryption_test_case_128_2),
   18768                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18769                 :            :                         test_AES_CCM_authenticated_decryption_test_case_128_3),
   18770                 :            : 
   18771                 :            :                 /** AES CCM Authenticated Encryption 192 bits key */
   18772                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18773                 :            :                         test_AES_CCM_authenticated_encryption_test_case_192_1),
   18774                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18775                 :            :                         test_AES_CCM_authenticated_encryption_test_case_192_2),
   18776                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18777                 :            :                         test_AES_CCM_authenticated_encryption_test_case_192_3),
   18778                 :            : 
   18779                 :            :                 /** AES CCM Authenticated Decryption 192 bits key*/
   18780                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18781                 :            :                         test_AES_CCM_authenticated_decryption_test_case_192_1),
   18782                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18783                 :            :                         test_AES_CCM_authenticated_decryption_test_case_192_2),
   18784                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18785                 :            :                         test_AES_CCM_authenticated_decryption_test_case_192_3),
   18786                 :            : 
   18787                 :            :                 /** AES CCM Authenticated Encryption 256 bits key */
   18788                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18789                 :            :                         test_AES_CCM_authenticated_encryption_test_case_256_1),
   18790                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18791                 :            :                         test_AES_CCM_authenticated_encryption_test_case_256_2),
   18792                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18793                 :            :                         test_AES_CCM_authenticated_encryption_test_case_256_3),
   18794                 :            : 
   18795                 :            :                 /** AES CCM Authenticated Decryption 256 bits key*/
   18796                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18797                 :            :                         test_AES_CCM_authenticated_decryption_test_case_256_1),
   18798                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18799                 :            :                         test_AES_CCM_authenticated_decryption_test_case_256_2),
   18800                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18801                 :            :                         test_AES_CCM_authenticated_decryption_test_case_256_3),
   18802                 :            :                 TEST_CASES_END()
   18803                 :            :         }
   18804                 :            : };
   18805                 :            : 
   18806                 :            : static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite  = {
   18807                 :            :         .suite_name = "AES GCM Authenticated Test Suite",
   18808                 :            :         .setup = aes_gcm_auth_testsuite_setup,
   18809                 :            :         .unit_test_cases = {
   18810                 :            :                 /** AES GCM Authenticated Encryption */
   18811                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18812                 :            :                         test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
   18813                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18814                 :            :                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
   18815                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18816                 :            :                         test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
   18817                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18818                 :            :                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
   18819                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18820                 :            :                         test_AES_GCM_authenticated_encryption_test_case_1),
   18821                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18822                 :            :                         test_AES_GCM_authenticated_encryption_test_case_2),
   18823                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18824                 :            :                         test_AES_GCM_authenticated_encryption_test_case_3),
   18825                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18826                 :            :                         test_AES_GCM_authenticated_encryption_test_case_4),
   18827                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18828                 :            :                         test_AES_GCM_authenticated_encryption_test_case_5),
   18829                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18830                 :            :                         test_AES_GCM_authenticated_encryption_test_case_6),
   18831                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18832                 :            :                         test_AES_GCM_authenticated_encryption_test_case_7),
   18833                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18834                 :            :                         test_AES_GCM_authenticated_encryption_test_case_8),
   18835                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18836                 :            :                         test_AES_GCM_J0_authenticated_encryption_test_case_1),
   18837                 :            : 
   18838                 :            :                 /** AES GCM Authenticated Decryption */
   18839                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18840                 :            :                         test_AES_GCM_authenticated_decryption_test_case_1),
   18841                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18842                 :            :                         test_AES_GCM_authenticated_decryption_test_case_2),
   18843                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18844                 :            :                         test_AES_GCM_authenticated_decryption_test_case_3),
   18845                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18846                 :            :                         test_AES_GCM_authenticated_decryption_test_case_4),
   18847                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18848                 :            :                         test_AES_GCM_authenticated_decryption_test_case_5),
   18849                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18850                 :            :                         test_AES_GCM_authenticated_decryption_test_case_6),
   18851                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18852                 :            :                         test_AES_GCM_authenticated_decryption_test_case_7),
   18853                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18854                 :            :                         test_AES_GCM_authenticated_decryption_test_case_8),
   18855                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18856                 :            :                         test_AES_GCM_J0_authenticated_decryption_test_case_1),
   18857                 :            : 
   18858                 :            :                 /** AES GCM Authenticated Encryption 192 bits key */
   18859                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18860                 :            :                         test_AES_GCM_auth_encryption_test_case_192_1),
   18861                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18862                 :            :                         test_AES_GCM_auth_encryption_test_case_192_2),
   18863                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18864                 :            :                         test_AES_GCM_auth_encryption_test_case_192_3),
   18865                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18866                 :            :                         test_AES_GCM_auth_encryption_test_case_192_4),
   18867                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18868                 :            :                         test_AES_GCM_auth_encryption_test_case_192_5),
   18869                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18870                 :            :                         test_AES_GCM_auth_encryption_test_case_192_6),
   18871                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18872                 :            :                         test_AES_GCM_auth_encryption_test_case_192_7),
   18873                 :            : 
   18874                 :            :                 /** AES GCM Authenticated Decryption 192 bits key */
   18875                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18876                 :            :                         test_AES_GCM_auth_decryption_test_case_192_1),
   18877                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18878                 :            :                         test_AES_GCM_auth_decryption_test_case_192_2),
   18879                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18880                 :            :                         test_AES_GCM_auth_decryption_test_case_192_3),
   18881                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18882                 :            :                         test_AES_GCM_auth_decryption_test_case_192_4),
   18883                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18884                 :            :                         test_AES_GCM_auth_decryption_test_case_192_5),
   18885                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18886                 :            :                         test_AES_GCM_auth_decryption_test_case_192_6),
   18887                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18888                 :            :                         test_AES_GCM_auth_decryption_test_case_192_7),
   18889                 :            : 
   18890                 :            :                 /** AES GCM Authenticated Encryption 256 bits key */
   18891                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18892                 :            :                         test_AES_GCM_auth_encryption_test_case_256_1),
   18893                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18894                 :            :                         test_AES_GCM_auth_encryption_test_case_256_2),
   18895                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18896                 :            :                         test_AES_GCM_auth_encryption_test_case_256_3),
   18897                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18898                 :            :                         test_AES_GCM_auth_encryption_test_case_256_4),
   18899                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18900                 :            :                         test_AES_GCM_auth_encryption_test_case_256_5),
   18901                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18902                 :            :                         test_AES_GCM_auth_encryption_test_case_256_6),
   18903                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18904                 :            :                         test_AES_GCM_auth_encryption_test_case_256_7),
   18905                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18906                 :            :                         test_AES_GCM_auth_encryption_test_case_256_8),
   18907                 :            : 
   18908                 :            :                 /** AES GCM Authenticated Decryption 256 bits key */
   18909                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18910                 :            :                         test_AES_GCM_auth_decryption_test_case_256_1),
   18911                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18912                 :            :                         test_AES_GCM_auth_decryption_test_case_256_2),
   18913                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18914                 :            :                         test_AES_GCM_auth_decryption_test_case_256_3),
   18915                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18916                 :            :                         test_AES_GCM_auth_decryption_test_case_256_4),
   18917                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18918                 :            :                         test_AES_GCM_auth_decryption_test_case_256_5),
   18919                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18920                 :            :                         test_AES_GCM_auth_decryption_test_case_256_6),
   18921                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18922                 :            :                         test_AES_GCM_auth_decryption_test_case_256_7),
   18923                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18924                 :            :                         test_AES_GCM_auth_decryption_test_case_256_8),
   18925                 :            : 
   18926                 :            :                 /** AES GCM Authenticated Encryption big aad size */
   18927                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18928                 :            :                         test_AES_GCM_auth_encryption_test_case_aad_1),
   18929                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18930                 :            :                         test_AES_GCM_auth_encryption_test_case_aad_2),
   18931                 :            : 
   18932                 :            :                 /** AES GCM Authenticated Decryption big aad size */
   18933                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18934                 :            :                         test_AES_GCM_auth_decryption_test_case_aad_1),
   18935                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18936                 :            :                         test_AES_GCM_auth_decryption_test_case_aad_2),
   18937                 :            : 
   18938                 :            :                 /** Out of place tests */
   18939                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18940                 :            :                         test_AES_GCM_authenticated_encryption_oop_test_case_1),
   18941                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18942                 :            :                         test_AES_GCM_authenticated_decryption_oop_test_case_1),
   18943                 :            : 
   18944                 :            :                 /** Session-less tests */
   18945                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18946                 :            :                         test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
   18947                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18948                 :            :                         test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
   18949                 :            : 
   18950                 :            :                 /** AES GCM external mbuf tests */
   18951                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18952                 :            :                         test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
   18953                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18954                 :            :                         test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
   18955                 :            : 
   18956                 :            :                 TEST_CASES_END()
   18957                 :            :         }
   18958                 :            : };
   18959                 :            : 
   18960                 :            : static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite  = {
   18961                 :            :         .suite_name = "AES GMAC Authentication Test Suite",
   18962                 :            :         .setup = aes_gmac_auth_testsuite_setup,
   18963                 :            :         .unit_test_cases = {
   18964                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18965                 :            :                         test_AES_GMAC_authentication_test_case_1),
   18966                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18967                 :            :                         test_AES_GMAC_authentication_verify_test_case_1),
   18968                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18969                 :            :                         test_AES_GMAC_authentication_test_case_2),
   18970                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18971                 :            :                         test_AES_GMAC_authentication_verify_test_case_2),
   18972                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18973                 :            :                         test_AES_GMAC_authentication_test_case_3),
   18974                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18975                 :            :                         test_AES_GMAC_authentication_verify_test_case_3),
   18976                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18977                 :            :                         test_AES_GMAC_authentication_test_case_4),
   18978                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18979                 :            :                         test_AES_GMAC_authentication_verify_test_case_4),
   18980                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18981                 :            :                         test_AES_GMAC_authentication_SGL_40B),
   18982                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18983                 :            :                         test_AES_GMAC_authentication_SGL_80B),
   18984                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18985                 :            :                         test_AES_GMAC_authentication_SGL_2048B),
   18986                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18987                 :            :                         test_AES_GMAC_authentication_SGL_2047B),
   18988                 :            : 
   18989                 :            :                 TEST_CASES_END()
   18990                 :            :         }
   18991                 :            : };
   18992                 :            : 
   18993                 :            : static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite  = {
   18994                 :            :         .suite_name = "Chacha20-Poly1305 Test Suite",
   18995                 :            :         .setup = chacha20_poly1305_testsuite_setup,
   18996                 :            :         .unit_test_cases = {
   18997                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   18998                 :            :                         test_chacha20_poly1305_encrypt_test_case_rfc8439),
   18999                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19000                 :            :                         test_chacha20_poly1305_decrypt_test_case_rfc8439),
   19001                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19002                 :            :                         test_chacha20_poly1305_encrypt_SGL_out_of_place),
   19003                 :            :                 TEST_CASES_END()
   19004                 :            :         }
   19005                 :            : };
   19006                 :            : 
   19007                 :            : static struct unit_test_suite cryptodev_snow3g_testsuite  = {
   19008                 :            :         .suite_name = "SNOW 3G Test Suite",
   19009                 :            :         .setup = snow3g_testsuite_setup,
   19010                 :            :         .unit_test_cases = {
   19011                 :            :                 /** SNOW 3G encrypt only (UEA2) */
   19012                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19013                 :            :                         test_snow3g_encryption_test_case_1),
   19014                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19015                 :            :                         test_snow3g_encryption_test_case_2),
   19016                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19017                 :            :                         test_snow3g_encryption_test_case_3),
   19018                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19019                 :            :                         test_snow3g_encryption_test_case_4),
   19020                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19021                 :            :                         test_snow3g_encryption_test_case_5),
   19022                 :            : 
   19023                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19024                 :            :                         test_snow3g_encryption_test_case_1_oop),
   19025                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19026                 :            :                         test_snow3g_encryption_test_case_1_oop_sgl),
   19027                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19028                 :            :                         test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
   19029                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19030                 :            :                         test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
   19031                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19032                 :            :                         test_snow3g_encryption_test_case_1_offset_oop),
   19033                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19034                 :            :                         test_snow3g_decryption_test_case_1_oop),
   19035                 :            : 
   19036                 :            :                 /** SNOW 3G generate auth, then encrypt (UEA2) */
   19037                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19038                 :            :                         test_snow3g_auth_cipher_test_case_1),
   19039                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19040                 :            :                         test_snow3g_auth_cipher_test_case_2),
   19041                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19042                 :            :                         test_snow3g_auth_cipher_test_case_2_oop),
   19043                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19044                 :            :                         test_snow3g_auth_cipher_part_digest_enc),
   19045                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19046                 :            :                         test_snow3g_auth_cipher_part_digest_enc_oop),
   19047                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19048                 :            :                         test_snow3g_auth_cipher_test_case_3_sgl),
   19049                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19050                 :            :                         test_snow3g_auth_cipher_test_case_3_oop_sgl),
   19051                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19052                 :            :                         test_snow3g_auth_cipher_part_digest_enc_sgl),
   19053                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19054                 :            :                         test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
   19055                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19056                 :            :                         test_snow3g_auth_cipher_total_digest_enc_1),
   19057                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19058                 :            :                         test_snow3g_auth_cipher_total_digest_enc_1_oop),
   19059                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19060                 :            :                         test_snow3g_auth_cipher_total_digest_enc_1_sgl),
   19061                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19062                 :            :                         test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
   19063                 :            : 
   19064                 :            :                 /** SNOW 3G decrypt (UEA2), then verify auth */
   19065                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19066                 :            :                         test_snow3g_auth_cipher_verify_test_case_1),
   19067                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19068                 :            :                         test_snow3g_auth_cipher_verify_test_case_2),
   19069                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19070                 :            :                         test_snow3g_auth_cipher_verify_test_case_2_oop),
   19071                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19072                 :            :                         test_snow3g_auth_cipher_verify_part_digest_enc),
   19073                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19074                 :            :                         test_snow3g_auth_cipher_verify_part_digest_enc_oop),
   19075                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19076                 :            :                         test_snow3g_auth_cipher_verify_test_case_3_sgl),
   19077                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19078                 :            :                         test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
   19079                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19080                 :            :                         test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
   19081                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19082                 :            :                         test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
   19083                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19084                 :            :                         test_snow3g_auth_cipher_verify_total_digest_enc_1),
   19085                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19086                 :            :                         test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
   19087                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19088                 :            :                         test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
   19089                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19090                 :            :                         test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
   19091                 :            : 
   19092                 :            :                 /** SNOW 3G decrypt only (UEA2) */
   19093                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19094                 :            :                         test_snow3g_decryption_test_case_1),
   19095                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19096                 :            :                         test_snow3g_decryption_test_case_2),
   19097                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19098                 :            :                         test_snow3g_decryption_test_case_3),
   19099                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19100                 :            :                         test_snow3g_decryption_test_case_4),
   19101                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19102                 :            :                         test_snow3g_decryption_test_case_5),
   19103                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19104                 :            :                         test_snow3g_decryption_with_digest_test_case_1),
   19105                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19106                 :            :                         test_snow3g_hash_generate_test_case_1),
   19107                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19108                 :            :                         test_snow3g_hash_generate_test_case_2),
   19109                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19110                 :            :                         test_snow3g_hash_generate_test_case_3),
   19111                 :            : 
   19112                 :            :                 /* Tests with buffers which length is not byte-aligned */
   19113                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19114                 :            :                         test_snow3g_hash_generate_test_case_4),
   19115                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19116                 :            :                         test_snow3g_hash_generate_test_case_5),
   19117                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19118                 :            :                         test_snow3g_hash_generate_test_case_6),
   19119                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19120                 :            :                         test_snow3g_hash_verify_test_case_1),
   19121                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19122                 :            :                         test_snow3g_hash_verify_test_case_2),
   19123                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19124                 :            :                         test_snow3g_hash_verify_test_case_3),
   19125                 :            : 
   19126                 :            :                 /* Tests with buffers which length is not byte-aligned */
   19127                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19128                 :            :                         test_snow3g_hash_verify_test_case_4),
   19129                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19130                 :            :                         test_snow3g_hash_verify_test_case_5),
   19131                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19132                 :            :                         test_snow3g_hash_verify_test_case_6),
   19133                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19134                 :            :                         test_snow3g_cipher_auth_test_case_1),
   19135                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19136                 :            :                         test_snow3g_auth_cipher_with_digest_test_case_1),
   19137                 :            :                 TEST_CASES_END()
   19138                 :            :         }
   19139                 :            : };
   19140                 :            : 
   19141                 :            : static struct unit_test_suite cryptodev_zuc_testsuite  = {
   19142                 :            :         .suite_name = "ZUC Test Suite",
   19143                 :            :         .setup = zuc_testsuite_setup,
   19144                 :            :         .unit_test_cases = {
   19145                 :            :                 /** ZUC encrypt only (EEA3) */
   19146                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19147                 :            :                         test_zuc_encryption_test_case_1),
   19148                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19149                 :            :                         test_zuc_encryption_test_case_2),
   19150                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19151                 :            :                         test_zuc_encryption_test_case_3),
   19152                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19153                 :            :                         test_zuc_encryption_test_case_4),
   19154                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19155                 :            :                         test_zuc_encryption_test_case_5),
   19156                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19157                 :            :                         test_zuc_encryption_test_case_6_sgl),
   19158                 :            : 
   19159                 :            :                 /** ZUC decrypt only (EEA3) */
   19160                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19161                 :            :                         test_zuc_decryption_test_case_1),
   19162                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19163                 :            :                         test_zuc_decryption_test_case_2),
   19164                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19165                 :            :                         test_zuc_decryption_test_case_3),
   19166                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19167                 :            :                         test_zuc_decryption_test_case_4),
   19168                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19169                 :            :                         test_zuc_decryption_test_case_5),
   19170                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19171                 :            :                         test_zuc_decryption_test_case_6_sgl),
   19172                 :            : 
   19173                 :            :                 /** ZUC authenticate (EIA3) */
   19174                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19175                 :            :                         test_zuc_hash_generate_test_case_1),
   19176                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19177                 :            :                         test_zuc_hash_generate_test_case_2),
   19178                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19179                 :            :                         test_zuc_hash_generate_test_case_3),
   19180                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19181                 :            :                         test_zuc_hash_generate_test_case_4),
   19182                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19183                 :            :                         test_zuc_hash_generate_test_case_5),
   19184                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19185                 :            :                         test_zuc_hash_generate_test_case_6),
   19186                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19187                 :            :                         test_zuc_hash_generate_test_case_7),
   19188                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19189                 :            :                         test_zuc_hash_generate_test_case_8),
   19190                 :            : 
   19191                 :            :                 /** ZUC verify (EIA3) */
   19192                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19193                 :            :                         test_zuc_hash_verify_test_case_1),
   19194                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19195                 :            :                         test_zuc_hash_verify_test_case_2),
   19196                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19197                 :            :                         test_zuc_hash_verify_test_case_3),
   19198                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19199                 :            :                         test_zuc_hash_verify_test_case_4),
   19200                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19201                 :            :                         test_zuc_hash_verify_test_case_5),
   19202                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19203                 :            :                         test_zuc_hash_verify_test_case_6),
   19204                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19205                 :            :                         test_zuc_hash_verify_test_case_7),
   19206                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19207                 :            :                         test_zuc_hash_verify_test_case_8),
   19208                 :            : 
   19209                 :            :                 /** ZUC alg-chain (EEA3/EIA3) */
   19210                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19211                 :            :                         test_zuc_cipher_auth_test_case_1),
   19212                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19213                 :            :                         test_zuc_cipher_auth_test_case_2),
   19214                 :            : 
   19215                 :            :                 /** ZUC generate auth, then encrypt (EEA3) */
   19216                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19217                 :            :                         test_zuc_auth_cipher_test_case_1),
   19218                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19219                 :            :                         test_zuc_auth_cipher_test_case_1_oop),
   19220                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19221                 :            :                         test_zuc_auth_cipher_test_case_1_sgl),
   19222                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19223                 :            :                         test_zuc_auth_cipher_test_case_1_oop_sgl),
   19224                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19225                 :            :                         test_zuc_auth_cipher_test_case_2),
   19226                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19227                 :            :                         test_zuc_auth_cipher_test_case_2_oop),
   19228                 :            : 
   19229                 :            :                 /** ZUC decrypt (EEA3), then verify auth */
   19230                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19231                 :            :                         test_zuc_auth_cipher_verify_test_case_1),
   19232                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19233                 :            :                         test_zuc_auth_cipher_verify_test_case_1_oop),
   19234                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19235                 :            :                         test_zuc_auth_cipher_verify_test_case_1_sgl),
   19236                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19237                 :            :                         test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
   19238                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19239                 :            :                         test_zuc_auth_cipher_verify_test_case_2),
   19240                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19241                 :            :                         test_zuc_auth_cipher_verify_test_case_2_oop),
   19242                 :            : 
   19243                 :            :                 /** ZUC-256 encrypt only **/
   19244                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19245                 :            :                         test_zuc256_encryption_test_case_1),
   19246                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19247                 :            :                         test_zuc256_encryption_test_case_2),
   19248                 :            : 
   19249                 :            :                 /** ZUC-256 decrypt only **/
   19250                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19251                 :            :                         test_zuc256_decryption_test_case_1),
   19252                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19253                 :            :                         test_zuc256_decryption_test_case_2),
   19254                 :            : 
   19255                 :            :                 /** ZUC-256 authentication only **/
   19256                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19257                 :            :                         test_zuc256_hash_generate_4b_tag_test_case_1),
   19258                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19259                 :            :                         test_zuc256_hash_generate_4b_tag_test_case_2),
   19260                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19261                 :            :                         test_zuc256_hash_generate_4b_tag_test_case_3),
   19262                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19263                 :            :                         test_zuc256_hash_generate_8b_tag_test_case_1),
   19264                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19265                 :            :                         test_zuc256_hash_generate_16b_tag_test_case_1),
   19266                 :            : 
   19267                 :            :                 /** ZUC-256 authentication verify only **/
   19268                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19269                 :            :                         test_zuc256_hash_verify_4b_tag_test_case_1),
   19270                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19271                 :            :                         test_zuc256_hash_verify_4b_tag_test_case_2),
   19272                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19273                 :            :                         test_zuc256_hash_verify_4b_tag_test_case_3),
   19274                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19275                 :            :                         test_zuc256_hash_verify_8b_tag_test_case_1),
   19276                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19277                 :            :                         test_zuc256_hash_verify_16b_tag_test_case_1),
   19278                 :            : 
   19279                 :            :                 /** ZUC-256 encrypt and authenticate **/
   19280                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19281                 :            :                         test_zuc256_cipher_auth_4b_tag_test_case_1),
   19282                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19283                 :            :                         test_zuc256_cipher_auth_4b_tag_test_case_2),
   19284                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19285                 :            :                         test_zuc256_cipher_auth_8b_tag_test_case_1),
   19286                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19287                 :            :                         test_zuc256_cipher_auth_16b_tag_test_case_1),
   19288                 :            : 
   19289                 :            :                 /** ZUC-256 generate auth, then encrypt */
   19290                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19291                 :            :                         test_zuc256_auth_cipher_4b_tag_test_case_1),
   19292                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19293                 :            :                         test_zuc256_auth_cipher_4b_tag_test_case_2),
   19294                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19295                 :            :                         test_zuc256_auth_cipher_8b_tag_test_case_1),
   19296                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19297                 :            :                         test_zuc256_auth_cipher_16b_tag_test_case_1),
   19298                 :            : 
   19299                 :            :                 /** ZUC-256 decrypt, then verify auth */
   19300                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19301                 :            :                         test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
   19302                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19303                 :            :                         test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
   19304                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19305                 :            :                         test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
   19306                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19307                 :            :                         test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
   19308                 :            : 
   19309                 :            :                 TEST_CASES_END()
   19310                 :            :         }
   19311                 :            : };
   19312                 :            : 
   19313                 :            : static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite  = {
   19314                 :            :         .suite_name = "HMAC_MD5 Authentication Test Suite",
   19315                 :            :         .setup = hmac_md5_auth_testsuite_setup,
   19316                 :            :         .unit_test_cases = {
   19317                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19318                 :            :                         test_MD5_HMAC_generate_case_1),
   19319                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19320                 :            :                         test_MD5_HMAC_verify_case_1),
   19321                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19322                 :            :                         test_MD5_HMAC_generate_case_2),
   19323                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19324                 :            :                         test_MD5_HMAC_verify_case_2),
   19325                 :            :                 TEST_CASES_END()
   19326                 :            :         }
   19327                 :            : };
   19328                 :            : 
   19329                 :            : static struct unit_test_suite cryptodev_kasumi_testsuite  = {
   19330                 :            :         .suite_name = "Kasumi Test Suite",
   19331                 :            :         .setup = kasumi_testsuite_setup,
   19332                 :            :         .unit_test_cases = {
   19333                 :            :                 /** KASUMI hash only (UIA1) */
   19334                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19335                 :            :                         test_kasumi_hash_generate_test_case_1),
   19336                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19337                 :            :                         test_kasumi_hash_generate_test_case_2),
   19338                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19339                 :            :                         test_kasumi_hash_generate_test_case_3),
   19340                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19341                 :            :                         test_kasumi_hash_generate_test_case_4),
   19342                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19343                 :            :                         test_kasumi_hash_generate_test_case_5),
   19344                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19345                 :            :                         test_kasumi_hash_generate_test_case_6),
   19346                 :            : 
   19347                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19348                 :            :                         test_kasumi_hash_verify_test_case_1),
   19349                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19350                 :            :                         test_kasumi_hash_verify_test_case_2),
   19351                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19352                 :            :                         test_kasumi_hash_verify_test_case_3),
   19353                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19354                 :            :                         test_kasumi_hash_verify_test_case_4),
   19355                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19356                 :            :                         test_kasumi_hash_verify_test_case_5),
   19357                 :            : 
   19358                 :            :                 /** KASUMI encrypt only (UEA1) */
   19359                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19360                 :            :                         test_kasumi_encryption_test_case_1),
   19361                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19362                 :            :                         test_kasumi_encryption_test_case_1_sgl),
   19363                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19364                 :            :                         test_kasumi_encryption_test_case_1_oop),
   19365                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19366                 :            :                         test_kasumi_encryption_test_case_1_oop_sgl),
   19367                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19368                 :            :                         test_kasumi_encryption_test_case_2),
   19369                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19370                 :            :                         test_kasumi_encryption_test_case_3),
   19371                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19372                 :            :                         test_kasumi_encryption_test_case_4),
   19373                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19374                 :            :                         test_kasumi_encryption_test_case_5),
   19375                 :            : 
   19376                 :            :                 /** KASUMI decrypt only (UEA1) */
   19377                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19378                 :            :                         test_kasumi_decryption_test_case_1),
   19379                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19380                 :            :                         test_kasumi_decryption_test_case_2),
   19381                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19382                 :            :                         test_kasumi_decryption_test_case_3),
   19383                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19384                 :            :                         test_kasumi_decryption_test_case_4),
   19385                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19386                 :            :                         test_kasumi_decryption_test_case_5),
   19387                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19388                 :            :                         test_kasumi_decryption_test_case_1_oop),
   19389                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19390                 :            :                         test_kasumi_cipher_auth_test_case_1),
   19391                 :            : 
   19392                 :            :                 /** KASUMI generate auth, then encrypt (F8) */
   19393                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19394                 :            :                         test_kasumi_auth_cipher_test_case_1),
   19395                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19396                 :            :                         test_kasumi_auth_cipher_test_case_2),
   19397                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19398                 :            :                         test_kasumi_auth_cipher_test_case_2_oop),
   19399                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19400                 :            :                         test_kasumi_auth_cipher_test_case_2_sgl),
   19401                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19402                 :            :                         test_kasumi_auth_cipher_test_case_2_oop_sgl),
   19403                 :            : 
   19404                 :            :                 /** KASUMI decrypt (F8), then verify auth */
   19405                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19406                 :            :                         test_kasumi_auth_cipher_verify_test_case_1),
   19407                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19408                 :            :                         test_kasumi_auth_cipher_verify_test_case_2),
   19409                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19410                 :            :                         test_kasumi_auth_cipher_verify_test_case_2_oop),
   19411                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19412                 :            :                         test_kasumi_auth_cipher_verify_test_case_2_sgl),
   19413                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19414                 :            :                         test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
   19415                 :            : 
   19416                 :            :                 TEST_CASES_END()
   19417                 :            :         }
   19418                 :            : };
   19419                 :            : 
   19420                 :            : static struct unit_test_suite cryptodev_esn_testsuite  = {
   19421                 :            :         .suite_name = "ESN Test Suite",
   19422                 :            :         .setup = esn_testsuite_setup,
   19423                 :            :         .unit_test_cases = {
   19424                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19425                 :            :                         auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
   19426                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19427                 :            :                         auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
   19428                 :            :                 TEST_CASES_END()
   19429                 :            :         }
   19430                 :            : };
   19431                 :            : 
   19432                 :            : static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite  = {
   19433                 :            :         .suite_name = "Negative AES GCM Test Suite",
   19434                 :            :         .setup = negative_aes_gcm_testsuite_setup,
   19435                 :            :         .unit_test_cases = {
   19436                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19437                 :            :                         test_AES_GCM_auth_encryption_fail_iv_corrupt),
   19438                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19439                 :            :                         test_AES_GCM_auth_encryption_fail_in_data_corrupt),
   19440                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19441                 :            :                         test_AES_GCM_auth_encryption_fail_out_data_corrupt),
   19442                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19443                 :            :                         test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
   19444                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19445                 :            :                         test_AES_GCM_auth_encryption_fail_aad_corrupt),
   19446                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19447                 :            :                         test_AES_GCM_auth_encryption_fail_tag_corrupt),
   19448                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19449                 :            :                         test_AES_GCM_auth_decryption_fail_iv_corrupt),
   19450                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19451                 :            :                         test_AES_GCM_auth_decryption_fail_in_data_corrupt),
   19452                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19453                 :            :                         test_AES_GCM_auth_decryption_fail_out_data_corrupt),
   19454                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19455                 :            :                         test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
   19456                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19457                 :            :                         test_AES_GCM_auth_decryption_fail_aad_corrupt),
   19458                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19459                 :            :                         test_AES_GCM_auth_decryption_fail_tag_corrupt),
   19460                 :            : 
   19461                 :            :                 TEST_CASES_END()
   19462                 :            :         }
   19463                 :            : };
   19464                 :            : 
   19465                 :            : static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite  = {
   19466                 :            :         .suite_name = "Negative AES GMAC Test Suite",
   19467                 :            :         .setup = negative_aes_gmac_testsuite_setup,
   19468                 :            :         .unit_test_cases = {
   19469                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19470                 :            :                         authentication_verify_AES128_GMAC_fail_data_corrupt),
   19471                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19472                 :            :                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
   19473                 :            : 
   19474                 :            :                 TEST_CASES_END()
   19475                 :            :         }
   19476                 :            : };
   19477                 :            : 
   19478                 :            : static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite  = {
   19479                 :            :         .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
   19480                 :            :         .setup = mixed_cipher_hash_testsuite_setup,
   19481                 :            :         .unit_test_cases = {
   19482                 :            :                 /** AUTH AES CMAC + CIPHER AES CTR */
   19483                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19484                 :            :                         test_aes_cmac_aes_ctr_digest_enc_test_case_1),
   19485                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19486                 :            :                         test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
   19487                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19488                 :            :                         test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
   19489                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19490                 :            :                         test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
   19491                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19492                 :            :                         test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
   19493                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19494                 :            :                         test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
   19495                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19496                 :            :                         test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
   19497                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19498                 :            :                         test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
   19499                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19500                 :            :                         test_aes_cmac_aes_ctr_digest_enc_test_case_2),
   19501                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19502                 :            :                         test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
   19503                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19504                 :            :                         test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
   19505                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19506                 :            :                         test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
   19507                 :            : 
   19508                 :            :                 /** AUTH ZUC + CIPHER SNOW3G */
   19509                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19510                 :            :                         test_auth_zuc_cipher_snow_test_case_1),
   19511                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19512                 :            :                         test_verify_auth_zuc_cipher_snow_test_case_1),
   19513                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19514                 :            :                         test_auth_zuc_cipher_snow_test_case_1_inplace),
   19515                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19516                 :            :                         test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
   19517                 :            :                 /** AUTH AES CMAC + CIPHER SNOW3G */
   19518                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19519                 :            :                         test_auth_aes_cmac_cipher_snow_test_case_1),
   19520                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19521                 :            :                         test_verify_auth_aes_cmac_cipher_snow_test_case_1),
   19522                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19523                 :            :                         test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
   19524                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19525                 :            :                         test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
   19526                 :            :                 /** AUTH ZUC + CIPHER AES CTR */
   19527                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19528                 :            :                         test_auth_zuc_cipher_aes_ctr_test_case_1),
   19529                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19530                 :            :                         test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
   19531                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19532                 :            :                         test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
   19533                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19534                 :            :                         test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
   19535                 :            :                 /** AUTH SNOW3G + CIPHER AES CTR */
   19536                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19537                 :            :                         test_auth_snow_cipher_aes_ctr_test_case_1),
   19538                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19539                 :            :                         test_verify_auth_snow_cipher_aes_ctr_test_case_1),
   19540                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19541                 :            :                         test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
   19542                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19543                 :            :                         test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
   19544                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19545                 :            :                         test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
   19546                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19547                 :            :                         test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
   19548                 :            :                 /** AUTH SNOW3G + CIPHER ZUC */
   19549                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19550                 :            :                         test_auth_snow_cipher_zuc_test_case_1),
   19551                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19552                 :            :                         test_verify_auth_snow_cipher_zuc_test_case_1),
   19553                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19554                 :            :                         test_auth_snow_cipher_zuc_test_case_1_inplace),
   19555                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19556                 :            :                         test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
   19557                 :            :                 /** AUTH AES CMAC + CIPHER ZUC */
   19558                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19559                 :            :                         test_auth_aes_cmac_cipher_zuc_test_case_1),
   19560                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19561                 :            :                         test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
   19562                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19563                 :            :                         test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
   19564                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19565                 :            :                         test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
   19566                 :            : 
   19567                 :            :                 /** AUTH NULL + CIPHER SNOW3G */
   19568                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19569                 :            :                         test_auth_null_cipher_snow_test_case_1),
   19570                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19571                 :            :                         test_verify_auth_null_cipher_snow_test_case_1),
   19572                 :            :                 /** AUTH NULL + CIPHER ZUC */
   19573                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19574                 :            :                         test_auth_null_cipher_zuc_test_case_1),
   19575                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19576                 :            :                         test_verify_auth_null_cipher_zuc_test_case_1),
   19577                 :            :                 /** AUTH SNOW3G + CIPHER NULL */
   19578                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19579                 :            :                         test_auth_snow_cipher_null_test_case_1),
   19580                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19581                 :            :                         test_verify_auth_snow_cipher_null_test_case_1),
   19582                 :            :                 /** AUTH ZUC + CIPHER NULL */
   19583                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19584                 :            :                         test_auth_zuc_cipher_null_test_case_1),
   19585                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19586                 :            :                         test_verify_auth_zuc_cipher_null_test_case_1),
   19587                 :            :                 /** AUTH NULL + CIPHER AES CTR */
   19588                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19589                 :            :                         test_auth_null_cipher_aes_ctr_test_case_1),
   19590                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19591                 :            :                         test_verify_auth_null_cipher_aes_ctr_test_case_1),
   19592                 :            :                 /** AUTH AES CMAC + CIPHER NULL */
   19593                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19594                 :            :                         test_auth_aes_cmac_cipher_null_test_case_1),
   19595                 :            :                 TEST_CASE_ST(ut_setup, ut_teardown,
   19596                 :            :                         test_verify_auth_aes_cmac_cipher_null_test_case_1),
   19597                 :            :                 TEST_CASES_END()
   19598                 :            :         }
   19599                 :            : };
   19600                 :            : 
   19601                 :            : static int
   19602                 :          1 : run_cryptodev_testsuite(const char *pmd_name)
   19603                 :            : {
   19604                 :            :         uint8_t ret, j, i = 0, blk_start_idx = 0;
   19605                 :          1 :         const enum blockcipher_test_type blk_suites[] = {
   19606                 :            :                 BLKCIPHER_AES_CHAIN_TYPE,
   19607                 :            :                 BLKCIPHER_AES_CIPHERONLY_TYPE,
   19608                 :            :                 BLKCIPHER_AES_DOCSIS_TYPE,
   19609                 :            :                 BLKCIPHER_3DES_CHAIN_TYPE,
   19610                 :            :                 BLKCIPHER_3DES_CIPHERONLY_TYPE,
   19611                 :            :                 BLKCIPHER_DES_CIPHERONLY_TYPE,
   19612                 :            :                 BLKCIPHER_DES_DOCSIS_TYPE,
   19613                 :            :                 BLKCIPHER_SM4_CHAIN_TYPE,
   19614                 :            :                 BLKCIPHER_SM4_CIPHERONLY_TYPE,
   19615                 :            :                 BLKCIPHER_AUTHONLY_TYPE};
   19616                 :          1 :         struct unit_test_suite *static_suites[] = {
   19617                 :            :                 &cryptodev_multi_session_testsuite,
   19618                 :            :                 &cryptodev_null_testsuite,
   19619                 :            :                 &cryptodev_aes_ccm_auth_testsuite,
   19620                 :            :                 &cryptodev_aes_gcm_auth_testsuite,
   19621                 :            :                 &cryptodev_aes_gmac_auth_testsuite,
   19622                 :            :                 &cryptodev_snow3g_testsuite,
   19623                 :            :                 &cryptodev_chacha20_poly1305_testsuite,
   19624                 :            :                 &cryptodev_zuc_testsuite,
   19625                 :            :                 &cryptodev_hmac_md5_auth_testsuite,
   19626                 :            :                 &cryptodev_kasumi_testsuite,
   19627                 :            :                 &cryptodev_esn_testsuite,
   19628                 :            :                 &cryptodev_negative_aes_gcm_testsuite,
   19629                 :            :                 &cryptodev_negative_aes_gmac_testsuite,
   19630                 :            :                 &cryptodev_mixed_cipher_hash_testsuite,
   19631                 :            :                 &cryptodev_negative_hmac_sha1_testsuite,
   19632                 :            :                 &cryptodev_gen_testsuite,
   19633                 :            : #ifdef RTE_LIB_SECURITY
   19634                 :            :                 &ipsec_proto_testsuite,
   19635                 :            :                 &pdcp_proto_testsuite,
   19636                 :            :                 &docsis_proto_testsuite,
   19637                 :            :                 &tls12_record_proto_testsuite,
   19638                 :            :                 &dtls12_record_proto_testsuite,
   19639                 :            :                 &tls13_record_proto_testsuite,
   19640                 :            : #endif
   19641                 :            :                 &end_testsuite
   19642                 :            :         };
   19643                 :            :         static struct unit_test_suite ts = {
   19644                 :            :                 .suite_name = "Cryptodev Unit Test Suite",
   19645                 :            :                 .setup = testsuite_setup,
   19646                 :            :                 .teardown = testsuite_teardown,
   19647                 :            :                 .unit_test_cases = {TEST_CASES_END()}
   19648                 :            :         };
   19649                 :            : 
   19650                 :          1 :         gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
   19651                 :            : 
   19652         [ -  + ]:          1 :         if (gbl_driver_id == -1) {
   19653                 :          0 :                 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
   19654                 :          0 :                 return TEST_SKIPPED;
   19655                 :            :         }
   19656                 :            : 
   19657                 :          1 :         ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
   19658                 :            :                         (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
   19659                 :            : 
   19660         [ +  + ]:         11 :         ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
   19661         [ +  + ]:         24 :         ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
   19662                 :          1 :         ret = unit_test_suite_runner(&ts);
   19663                 :            : 
   19664         [ +  + ]:         11 :         FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
   19665                 :          1 :         free(ts.unit_test_suites);
   19666                 :          1 :         return ret;
   19667                 :            : }
   19668                 :            : 
   19669                 :            : static int
   19670                 :          0 : require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
   19671                 :            : {
   19672                 :            :         struct rte_cryptodev_info dev_info;
   19673                 :            :         uint8_t i, nb_devs;
   19674                 :            :         int driver_id;
   19675                 :            : 
   19676                 :          0 :         driver_id = rte_cryptodev_driver_id_get(pmd_name);
   19677         [ #  # ]:          0 :         if (driver_id == -1) {
   19678                 :          0 :                 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
   19679                 :          0 :                 return TEST_SKIPPED;
   19680                 :            :         }
   19681                 :            : 
   19682                 :          0 :         nb_devs = rte_cryptodev_count();
   19683         [ #  # ]:          0 :         if (nb_devs < 1) {
   19684                 :          0 :                 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
   19685                 :          0 :                 return TEST_SKIPPED;
   19686                 :            :         }
   19687                 :            : 
   19688         [ #  # ]:          0 :         for (i = 0; i < nb_devs; i++) {
   19689                 :          0 :                 rte_cryptodev_info_get(i, &dev_info);
   19690         [ #  # ]:          0 :                 if (dev_info.driver_id == driver_id) {
   19691         [ #  # ]:          0 :                         if (!(dev_info.feature_flags & flag)) {
   19692                 :          0 :                                 RTE_LOG(INFO, USER1, "%s not supported\n",
   19693                 :            :                                                 flag_name);
   19694                 :          0 :                                 return TEST_SKIPPED;
   19695                 :            :                         }
   19696                 :            :                         return 0; /* found */
   19697                 :            :                 }
   19698                 :            :         }
   19699                 :            : 
   19700                 :          0 :         RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
   19701                 :          0 :         return TEST_SKIPPED;
   19702                 :            : }
   19703                 :            : 
   19704                 :            : static int
   19705                 :          0 : test_cryptodev_qat(void)
   19706                 :            : {
   19707                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
   19708                 :            : }
   19709                 :            : 
   19710                 :            : static int
   19711                 :          0 : test_cryptodev_uadk(void)
   19712                 :            : {
   19713                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
   19714                 :            : }
   19715                 :            : 
   19716                 :            : static int
   19717                 :          0 : test_cryptodev_virtio(void)
   19718                 :            : {
   19719                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
   19720                 :            : }
   19721                 :            : 
   19722                 :            : static int
   19723                 :          0 : test_cryptodev_aesni_mb(void)
   19724                 :            : {
   19725                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
   19726                 :            : }
   19727                 :            : 
   19728                 :            : static int
   19729                 :          0 : test_cryptodev_cpu_aesni_mb(void)
   19730                 :            : {
   19731                 :            :         int32_t rc;
   19732                 :          0 :         enum rte_security_session_action_type at = gbl_action_type;
   19733                 :          0 :         gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
   19734                 :          0 :         rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
   19735                 :          0 :         gbl_action_type = at;
   19736                 :          0 :         return rc;
   19737                 :            : }
   19738                 :            : 
   19739                 :            : static int
   19740                 :          0 : test_cryptodev_chacha_poly_mb(void)
   19741                 :            : {
   19742                 :            :         int32_t rc;
   19743                 :          0 :         enum rte_security_session_action_type at = gbl_action_type;
   19744                 :          0 :         rc = run_cryptodev_testsuite(
   19745                 :            :                         RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
   19746                 :          0 :         gbl_action_type = at;
   19747                 :          0 :         return rc;
   19748                 :            : }
   19749                 :            : 
   19750                 :            : static int
   19751                 :          1 : test_cryptodev_openssl(void)
   19752                 :            : {
   19753                 :          1 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
   19754                 :            : }
   19755                 :            : 
   19756                 :            : static int
   19757                 :          0 : test_cryptodev_aesni_gcm(void)
   19758                 :            : {
   19759                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
   19760                 :            : }
   19761                 :            : 
   19762                 :            : static int
   19763                 :          0 : test_cryptodev_cpu_aesni_gcm(void)
   19764                 :            : {
   19765                 :            :         int32_t rc;
   19766                 :          0 :         enum rte_security_session_action_type at = gbl_action_type;
   19767                 :          0 :         gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
   19768                 :          0 :         rc  = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
   19769                 :          0 :         gbl_action_type = at;
   19770                 :          0 :         return rc;
   19771                 :            : }
   19772                 :            : 
   19773                 :            : static int
   19774                 :          0 : test_cryptodev_mlx5(void)
   19775                 :            : {
   19776                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
   19777                 :            : }
   19778                 :            : 
   19779                 :            : static int
   19780                 :          0 : test_cryptodev_null(void)
   19781                 :            : {
   19782                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
   19783                 :            : }
   19784                 :            : 
   19785                 :            : static int
   19786                 :          0 : test_cryptodev_sw_snow3g(void)
   19787                 :            : {
   19788                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
   19789                 :            : }
   19790                 :            : 
   19791                 :            : static int
   19792                 :          0 : test_cryptodev_sw_kasumi(void)
   19793                 :            : {
   19794                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
   19795                 :            : }
   19796                 :            : 
   19797                 :            : static int
   19798                 :          0 : test_cryptodev_sw_zuc(void)
   19799                 :            : {
   19800                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
   19801                 :            : }
   19802                 :            : 
   19803                 :            : static int
   19804                 :          0 : test_cryptodev_armv8(void)
   19805                 :            : {
   19806                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
   19807                 :            : }
   19808                 :            : 
   19809                 :            : static int
   19810                 :          0 : test_cryptodev_mrvl(void)
   19811                 :            : {
   19812                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
   19813                 :            : }
   19814                 :            : 
   19815                 :            : #ifdef RTE_CRYPTO_SCHEDULER
   19816                 :            : 
   19817                 :            : static int
   19818                 :          0 : test_cryptodev_scheduler(void)
   19819                 :            : {
   19820                 :            :         uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
   19821                 :          0 :         const enum blockcipher_test_type blk_suites[] = {
   19822                 :            :                 BLKCIPHER_AES_CHAIN_TYPE,
   19823                 :            :                 BLKCIPHER_AES_CIPHERONLY_TYPE,
   19824                 :            :                 BLKCIPHER_AUTHONLY_TYPE
   19825                 :            :         };
   19826                 :            :         static struct unit_test_suite scheduler_multicore = {
   19827                 :            :                 .suite_name = "Scheduler Multicore Unit Test Suite",
   19828                 :            :                 .setup = scheduler_multicore_testsuite_setup,
   19829                 :            :                 .teardown = scheduler_mode_testsuite_teardown,
   19830                 :            :                 .unit_test_cases = {TEST_CASES_END()}
   19831                 :            :         };
   19832                 :            :         static struct unit_test_suite scheduler_round_robin = {
   19833                 :            :                 .suite_name = "Scheduler Round Robin Unit Test Suite",
   19834                 :            :                 .setup = scheduler_roundrobin_testsuite_setup,
   19835                 :            :                 .teardown = scheduler_mode_testsuite_teardown,
   19836                 :            :                 .unit_test_cases = {TEST_CASES_END()}
   19837                 :            :         };
   19838                 :            :         static struct unit_test_suite scheduler_failover = {
   19839                 :            :                 .suite_name = "Scheduler Failover Unit Test Suite",
   19840                 :            :                 .setup = scheduler_failover_testsuite_setup,
   19841                 :            :                 .teardown = scheduler_mode_testsuite_teardown,
   19842                 :            :                 .unit_test_cases = {TEST_CASES_END()}
   19843                 :            :         };
   19844                 :            :         static struct unit_test_suite scheduler_pkt_size_distr = {
   19845                 :            :                 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
   19846                 :            :                 .setup = scheduler_pkt_size_distr_testsuite_setup,
   19847                 :            :                 .teardown = scheduler_mode_testsuite_teardown,
   19848                 :            :                 .unit_test_cases = {TEST_CASES_END()}
   19849                 :            :         };
   19850                 :          0 :         struct unit_test_suite *sched_mode_suites[] = {
   19851                 :            :                 &scheduler_multicore,
   19852                 :            :                 &scheduler_round_robin,
   19853                 :            :                 &scheduler_failover,
   19854                 :            :                 &scheduler_pkt_size_distr
   19855                 :            :         };
   19856                 :            :         static struct unit_test_suite scheduler_config = {
   19857                 :            :                 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
   19858                 :            :                 .unit_test_cases = {
   19859                 :            :                         TEST_CASE(test_scheduler_attach_worker_op),
   19860                 :            :                         TEST_CASE(test_scheduler_mode_multicore_op),
   19861                 :            :                         TEST_CASE(test_scheduler_mode_roundrobin_op),
   19862                 :            :                         TEST_CASE(test_scheduler_mode_failover_op),
   19863                 :            :                         TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
   19864                 :            :                         TEST_CASE(test_scheduler_detach_worker_op),
   19865                 :            : 
   19866                 :            :                         TEST_CASES_END() /**< NULL terminate array */
   19867                 :            :                 }
   19868                 :            :         };
   19869                 :          0 :         struct unit_test_suite *static_suites[] = {
   19870                 :            :                 &scheduler_config,
   19871                 :            :                 &end_testsuite
   19872                 :            :         };
   19873                 :          0 :         struct unit_test_suite *sched_mode_static_suites[] = {
   19874                 :            : #ifdef RTE_LIB_SECURITY
   19875                 :            :                 &docsis_proto_testsuite,
   19876                 :            : #endif
   19877                 :            :                 &end_testsuite
   19878                 :            :         };
   19879                 :            :         static struct unit_test_suite ts = {
   19880                 :            :                 .suite_name = "Scheduler Unit Test Suite",
   19881                 :            :                 .setup = scheduler_testsuite_setup,
   19882                 :            :                 .teardown = testsuite_teardown,
   19883                 :            :                 .unit_test_cases = {TEST_CASES_END()}
   19884                 :            :         };
   19885                 :            : 
   19886                 :          0 :         gbl_driver_id = rte_cryptodev_driver_id_get(
   19887                 :            :                         RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
   19888                 :            : 
   19889         [ #  # ]:          0 :         if (gbl_driver_id == -1) {
   19890                 :          0 :                 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
   19891                 :          0 :                 return TEST_SKIPPED;
   19892                 :            :         }
   19893                 :            : 
   19894         [ #  # ]:          0 :         if (rte_cryptodev_driver_id_get(
   19895                 :            :                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
   19896                 :          0 :                 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
   19897                 :          0 :                 return TEST_SKIPPED;
   19898                 :            :         }
   19899                 :            : 
   19900         [ #  # ]:          0 :         for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
   19901                 :            :                 uint8_t blk_i = 0;
   19902                 :          0 :                 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
   19903                 :            :                                 (struct unit_test_suite *) *
   19904                 :            :                                 (RTE_DIM(blk_suites) +
   19905                 :            :                                 RTE_DIM(sched_mode_static_suites) + 1));
   19906         [ #  # ]:          0 :                 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
   19907                 :            :                                 blk_suites, RTE_DIM(blk_suites));
   19908         [ #  # ]:          0 :                 ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
   19909                 :            :                                 sched_mode_static_suites,
   19910                 :            :                                 RTE_DIM(sched_mode_static_suites));
   19911                 :          0 :                 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
   19912                 :            :         }
   19913                 :            : 
   19914                 :          0 :         ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
   19915                 :            :                         (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
   19916         [ #  # ]:          0 :         ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
   19917                 :            :                         RTE_DIM(sched_mode_suites));
   19918         [ #  # ]:          0 :         ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
   19919                 :          0 :         ret = unit_test_suite_runner(&ts);
   19920                 :            : 
   19921         [ #  # ]:          0 :         for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
   19922         [ #  # ]:          0 :                 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
   19923                 :            :                                 (*sched_mode_suites[sched_i]),
   19924                 :            :                                 RTE_DIM(blk_suites));
   19925                 :          0 :                 free(sched_mode_suites[sched_i]->unit_test_suites);
   19926                 :            :         }
   19927                 :          0 :         free(ts.unit_test_suites);
   19928                 :          0 :         return ret;
   19929                 :            : }
   19930                 :            : 
   19931                 :        251 : REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
   19932                 :            : 
   19933                 :            : #endif
   19934                 :            : 
   19935                 :            : static int
   19936                 :          0 : test_cryptodev_dpaa2_sec(void)
   19937                 :            : {
   19938                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
   19939                 :            : }
   19940                 :            : 
   19941                 :            : static int
   19942                 :          0 : test_cryptodev_dpaa_sec(void)
   19943                 :            : {
   19944                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
   19945                 :            : }
   19946                 :            : 
   19947                 :            : static int
   19948                 :          0 : test_cryptodev_ccp(void)
   19949                 :            : {
   19950                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
   19951                 :            : }
   19952                 :            : 
   19953                 :            : static int
   19954                 :          0 : test_cryptodev_octeontx(void)
   19955                 :            : {
   19956                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
   19957                 :            : }
   19958                 :            : 
   19959                 :            : static int
   19960                 :          0 : test_cryptodev_caam_jr(void)
   19961                 :            : {
   19962                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
   19963                 :            : }
   19964                 :            : 
   19965                 :            : static int
   19966                 :          0 : test_cryptodev_nitrox(void)
   19967                 :            : {
   19968                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
   19969                 :            : }
   19970                 :            : 
   19971                 :            : static int
   19972                 :          0 : test_cryptodev_bcmfs(void)
   19973                 :            : {
   19974                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
   19975                 :            : }
   19976                 :            : 
   19977                 :            : static int
   19978                 :          0 : run_cryptodev_raw_testsuite(const char *pmd_name)
   19979                 :            : {
   19980                 :            :         int ret;
   19981                 :            : 
   19982                 :          0 :         ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
   19983         [ #  # ]:          0 :         if (ret)
   19984                 :            :                 return ret;
   19985                 :            : 
   19986                 :          0 :         global_api_test_type = CRYPTODEV_RAW_API_TEST;
   19987                 :          0 :         ret = run_cryptodev_testsuite(pmd_name);
   19988                 :          0 :         global_api_test_type = CRYPTODEV_API_TEST;
   19989                 :            : 
   19990                 :          0 :         return ret;
   19991                 :            : }
   19992                 :            : 
   19993                 :            : static int
   19994                 :          0 : test_cryptodev_qat_raw_api(void)
   19995                 :            : {
   19996                 :          0 :         return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
   19997                 :            : }
   19998                 :            : 
   19999                 :            : static int
   20000                 :          0 : test_cryptodev_cn9k(void)
   20001                 :            : {
   20002                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
   20003                 :            : }
   20004                 :            : 
   20005                 :            : static int
   20006                 :          0 : test_cryptodev_cn10k(void)
   20007                 :            : {
   20008                 :          0 :         return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
   20009                 :            : }
   20010                 :            : 
   20011                 :            : static int
   20012                 :          0 : test_cryptodev_cn10k_raw_api(void)
   20013                 :            : {
   20014                 :          0 :         return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
   20015                 :            : }
   20016                 :            : 
   20017                 :            : static int
   20018                 :          0 : test_cryptodev_dpaa2_sec_raw_api(void)
   20019                 :            : {
   20020                 :          0 :         return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
   20021                 :            : }
   20022                 :            : 
   20023                 :            : static int
   20024                 :          0 : test_cryptodev_dpaa_sec_raw_api(void)
   20025                 :            : {
   20026                 :          0 :         return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
   20027                 :            : }
   20028                 :            : 
   20029                 :        251 : REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
   20030                 :            :                 test_cryptodev_cn10k_raw_api);
   20031                 :        251 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
   20032                 :            :                 test_cryptodev_dpaa2_sec_raw_api);
   20033                 :        251 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
   20034                 :            :                 test_cryptodev_dpaa_sec_raw_api);
   20035                 :        251 : REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
   20036                 :            :                 test_cryptodev_qat_raw_api);
   20037                 :        251 : REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
   20038                 :        251 : REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
   20039                 :        251 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
   20040                 :            :         test_cryptodev_cpu_aesni_mb);
   20041                 :        251 : REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
   20042                 :            :         test_cryptodev_chacha_poly_mb);
   20043                 :        251 : REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
   20044                 :        251 : REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
   20045                 :        251 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
   20046                 :            :         test_cryptodev_cpu_aesni_gcm);
   20047                 :        251 : REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
   20048                 :        251 : REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
   20049                 :        251 : REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
   20050                 :        251 : REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
   20051                 :        251 : REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
   20052                 :        251 : REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
   20053                 :        251 : REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
   20054                 :        251 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
   20055                 :        251 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
   20056                 :        251 : REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
   20057                 :        251 : REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
   20058                 :        251 : REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
   20059                 :        251 : REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
   20060                 :        251 : REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
   20061                 :        251 : REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
   20062                 :        251 : REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
   20063                 :        251 : REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
   20064                 :        251 : REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);

Generated by: LCOV version 1.14